package-build-stats
package-build-stats copied to clipboard
Add support for package shipped as ES2020+ JavaScript
Package shipping ES2020+ JavaScript fails to build with Module parse failed: Unexpected token
errors. Some examples:
Module parse failed: Unexpected token (8:18)
File was processed with these loaders:
* ./node_modules/shebang-loader/index.js
* ./node_modules/string-replace-loader/index.js
You may need an additional loader to handle the result of these loaders.
| const cache = /* @__PURE__ */ new WeakMap();
| class Transition {
> isTransitioning = false;
| transitionEndHandler = null;
| constructor(element) {
Module parse failed: Unexpected token (46:17)
File was processed with these loaders:
* ./node_modules/shebang-loader/index.js
* ./node_modules/string-replace-loader/index.js
You may need an additional loader to handle the result of these loaders.
| }
| class Base extends EventTarget {
> static $isBase = true;
| $parent = null;
| $id;
Adding the esbuild-loader
with the target set to es2019
before the shebang-loader
and string-replace-loader
loaders fixes the errors.
I am not certain about all the side effects that this change could trigger, but the test suites are passing.
Please let me know if this is not the correct solution for the above errors.