mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Revert "Avoid unnecessary Buffer allocations in minifyJs."
This reverts commit ff0d85d391.
This commit is contained in:
@@ -1354,7 +1354,17 @@ class Target {
|
||||
inputHashesByJsFile.set(jsf, file.hash());
|
||||
|
||||
if (file.targetPath.startsWith("dynamic/")) {
|
||||
// Dynamic files consist of a single anonymous function
|
||||
// expression, which some minifiers (e.g. UglifyJS) either fail to
|
||||
// parse or mistakenly eliminate as dead code. To avoid these
|
||||
// problems, we temporarily name the function __minifyJs.
|
||||
file._contents = Buffer.concat([
|
||||
MINIFY_RENAMED_FUNCTION,
|
||||
file.contents().slice(MINIFY_PLAIN_FUNCTION.length)
|
||||
]);
|
||||
|
||||
dynamicFiles.push(jsf);
|
||||
|
||||
} else {
|
||||
staticFiles.push(jsf);
|
||||
}
|
||||
@@ -1382,8 +1392,19 @@ class Target {
|
||||
|
||||
function handle(source, dynamic) {
|
||||
source._minifiedFiles.forEach(file => {
|
||||
if (typeof file.data === "string") {
|
||||
file.data = Buffer.from(file.data, "utf8");
|
||||
// Remove the function name __minifyJs that was added above.
|
||||
if (typeof file.data === 'string') {
|
||||
file.data = Buffer.from(
|
||||
file.data
|
||||
.replace(/^\s*function\s+__minifyJs\s*\(/,
|
||||
"function("),
|
||||
"utf8"
|
||||
);
|
||||
} else if (dynamic) {
|
||||
file.data = Buffer.concat([
|
||||
MINIFY_PLAIN_FUNCTION,
|
||||
file.data.slice(MINIFY_RENAMED_FUNCTION.length)
|
||||
]);
|
||||
}
|
||||
|
||||
const newFile = new File({
|
||||
|
||||
@@ -685,7 +685,7 @@ _.extend(File.prototype, {
|
||||
|
||||
_getClosureHeader() {
|
||||
if (this.meteorInstallOptions) {
|
||||
const headerParts = ["function module("];
|
||||
const headerParts = ["function("];
|
||||
|
||||
if (this.source.match(/\b__dirname\b/)) {
|
||||
headerParts.push("require,exports,module,__filename,__dirname");
|
||||
|
||||
Reference in New Issue
Block a user