diff --git a/build/minify.js b/build/minify.js index 6e1bacb4f..33dfe0373 100755 --- a/build/minify.js +++ b/build/minify.js @@ -371,7 +371,7 @@ fs.unlinkSync(mapPath); output = output - .replace(/[\s;]*$/, '\n//@ sourceMappingURL=' + path.basename(mapPath)); + .replace(/[\s;]*$/, '\n/*\n//@ sourceMappingURL=' + path.basename(mapPath)) + '\n*/'; mapOutput = mapOutput .replace(/("file":)""/, '$1"' + path.basename(outputPath) + '"') diff --git a/build/post-compile.js b/build/post-compile.js index 8091d1d08..bb3581f15 100644 --- a/build/post-compile.js +++ b/build/post-compile.js @@ -41,7 +41,7 @@ // add trailing semicolon if (source) { - source = source.replace(/[\s;]*(\n\/\/.+)?$/, ';$1'); + source = source.replace(/[\s;]*?(\s*\/\/.*\s*|\s*\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/\s*)*$/, ';$1'); } // exit early if version snippet isn't found var snippet = /VERSION\s*[=:]\s*([\'"])(.*?)\1/.exec(source); diff --git a/build/pre-compile.js b/build/pre-compile.js index 280794462..44efa4749 100644 --- a/build/pre-compile.js +++ b/build/pre-compile.js @@ -252,9 +252,6 @@ .replace('"__p += \'"', '"__p+=\'"') .replace('"\';\n"', '"\';"') - // remove `useSourceURL` variable - source = source.replace(/(?:\n +\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/)?\n *try *{(?:\s*\/\/.*)*\n *var useSourceURL[\s\S]+?catch[^}]+}\n/, ''); - // remove debug sourceURL use in `_.template` source = source.replace(/(?:\s*\/\/.*\n)* *var sourceURL[^;]+;|\+ *sourceURL/g, ''); diff --git a/lodash.js b/lodash.js index c20b3ee47..88a248697 100644 --- a/lodash.js +++ b/lodash.js @@ -182,23 +182,6 @@ var noNodeClass = toString.call(document) == objectClass && !({ 'toString': 0 } + ''); } catch(e) { } - /** - * Detect if sourceURL syntax is usable without erroring: - * - * The JS engine embedded in Adobe products will throw a syntax error when - * it encounters a single line comment beginning with the `@` symbol. - * - * The JS engine in Narwhal will generate the function `function anonymous(){//}` - * and throw a syntax error. - * - * Avoid comments beginning `@` symbols in IE because they are part of its - * non-standard conditional compilation support. - * http://msdn.microsoft.com/en-us/library/121hztk3(v=vs.94).aspx - */ - try { - var useSourceURL = (Function('//@')(), !isIeOpera); - } catch(e) { } - /** Used to identify object classifications that `_.clone` supports */ var cloneableClasses = {}; cloneableClasses[funcClass] = false; @@ -4284,11 +4267,11 @@ source + 'return __p\n}'; - // use a sourceURL for easier debugging + // Use a sourceURL for easier debugging and wrap in a multi-line comment to + // avoid issues with Narwhal, IE conditional compilation, and the JS engine + // embedded in Adobe products. // http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl - var sourceURL = useSourceURL - ? '\n//@ sourceURL=' + (options.sourceURL || '/lodash/template/source[' + (templateCounter++) + ']') - : ''; + var sourceURL = '\n/*\n//@ sourceURL=' + (options.sourceURL || '/lodash/template/source[' + (templateCounter++) + ']') + '\n*/'; try { var result = Function(importsKeys, 'return ' + source + sourceURL).apply(undefined, importsValues); diff --git a/lodash.underscore.js b/lodash.underscore.js index b028d48f7..dfc4abc5e 100644 --- a/lodash.underscore.js +++ b/lodash.underscore.js @@ -143,23 +143,6 @@ */ var noCharByIndex = ('x'[0] + Object('x')[0]) != 'xx'; - /** - * Detect if sourceURL syntax is usable without erroring: - * - * The JS engine embedded in Adobe products will throw a syntax error when - * it encounters a single line comment beginning with the `@` symbol. - * - * The JS engine in Narwhal will generate the function `function anonymous(){//}` - * and throw a syntax error. - * - * Avoid comments beginning `@` symbols in IE because they are part of its - * non-standard conditional compilation support. - * http://msdn.microsoft.com/en-us/library/121hztk3(v=vs.94).aspx - */ - try { - var useSourceURL = (Function('//@')(), !isIeOpera); - } catch(e) { } - /** Used to determine if values are of the language type Object */ var objectTypes = { 'boolean': false,