Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

πŸ“¦ Update dependency esbuild to v0.11.19 #34147

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 38 additions & 4 deletions build-system/common/esbuild-babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,51 @@ function getEsbuildBabelPlugin(
build.onLoad({filter: /\.[cm]?js$/, namespace: ''}, async (file) => {
const filename = file.path;
const {contents, hash} = await batchedRead(filename, optionsHash);
const transformed = await transformContents(filename, contents, hash, {
...babelOptions,

const transformed = await transformContents(
filename,
filenameRelative: path.basename(filename),
});
contents,
hash,
getFileBabelOptions(babelOptions, filename)
);
return {contents: transformed};
});
},
};
}

const CJS_TRANSFORMS = new Set([
'transform-modules-commonjs',
'proposal-dynamic-import',
'syntax-dynamic-import',
'proposal-export-namespace-from',
'syntax-export-namespace-from',
]);

/**
* @param {!Object} babelOptions
* @param {string} filename
* @return {!Object}
*/
function getFileBabelOptions(babelOptions, filename) {
// Patch for leaving files within node_modules as esm, since esbuild will break when trying
// to process a module file that contains CJS exports. This function is called after
// babel.loadOptions, therefore all of the plugins from preset-env have already been applied.
// and must be disabled individually.
rsimha marked this conversation as resolved.
Show resolved Hide resolved
if (filename.includes('node_modules')) {
const plugins = babelOptions.plugins.filter(
({key}) => !CJS_TRANSFORMS.has(key)
);
babelOptions = {...babelOptions, plugins};
}

return {
...babelOptions,
filename,
filenameRelative: path.basename(filename),
};
}

module.exports = {
getEsbuildBabelPlugin,
};
4 changes: 4 additions & 0 deletions build-system/tasks/runtime-test/runtime-test-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,10 @@ class RuntimeTestConfig {
},
plugins: [importPathPlugin, babelPlugin],
sourcemap: 'inline',
// TODO(rsimha): Remove this workaround once evanw/esbuild#1202 is fixed.
banner: {
js: "function require(x) { throw new Error('Cannot require ' + x) }",
},
};
}

Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
"del": "6.0.0",
"enzyme": "3.11.0",
"enzyme-adapter-preact-pure": "3.1.0",
"esbuild": "0.9.7",
"esbuild": "0.11.19",
"escodegen": "2.0.0",
"eslint": "7.25.0",
"eslint-config-prettier": "8.3.0",
Expand Down