Skip to content

Commit c95db66

Browse files
committed
Provide better error message with AST parsing fails. Fixes requirejs#71.
1 parent dbfe7f1 commit c95db66

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

build/jslib/requirePatch.js

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,13 @@ function (file, pragma, parse) {
167167
//and to make sure this file is first, so that define calls work.
168168
//This situation mainly occurs when the build is done on top of the output
169169
//of another build, where the first build may include require somewhere in it.
170-
if (!layer.existingRequireUrl && parse.definesRequire(url, contents)) {
171-
layer.existingRequireUrl = url;
170+
try {
171+
if (!layer.existingRequireUrl && parse.definesRequire(url, contents)) {
172+
layer.existingRequireUrl = url;
173+
}
174+
} catch (e1) {
175+
throw new Error('Parse error using UglifyJS ' +
176+
'for file: ' + url + '\n' + e1);
172177
}
173178

174179
if (moduleName in context.plugins) {
@@ -185,12 +190,17 @@ function (file, pragma, parse) {
185190
//Parse out the require and define calls.
186191
//Do this even for plugins in case they have their own
187192
//dependencies that may be separate to how the pluginBuilder works.
188-
if (!context.needFullExec[moduleName]) {
189-
contents = parse(moduleName, url, contents, {
190-
insertNeedsDefine: true,
191-
has: context.config.has,
192-
findNestedDependencies: context.config.findNestedDependencies
193-
});
193+
try {
194+
if (!context.needFullExec[moduleName]) {
195+
contents = parse(moduleName, url, contents, {
196+
insertNeedsDefine: true,
197+
has: context.config.has,
198+
findNestedDependencies: context.config.findNestedDependencies
199+
});
200+
}
201+
} catch (e2) {
202+
throw new Error('Parse error using UglifyJS ' +
203+
'for file: ' + url + '\n' + e2);
194204
}
195205

196206
require._cachedFileContents[url] = contents;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy