ESM Format modules are not transpiled to ES5.
See original GitHub issueDescribe the bug I am currently encountering the following error when I try import the code into older code base that has ejected create-react-app:
/Users/djohnston/git/project/node_modules/@monaco-editor/react/lib/es/Editor/Editor.js
Module parse failed: Unexpected token (105:6)
You may need an appropriate loader to handle this file type.
| model: defaultModel,
| automaticLayout: true,
| ...options
| }, overrideServices);
| saveViewState && editorRef.current.restoreViewState(viewStates.get(autoCreatedModelPath));
The issue appears to be that it doesn’t like the …spread syntax.
To Reproduce
https://github.com/dwjohnston/cra1-monaco
Expected behavior
Of all of the imports this project has been using, this is the first time this error has been encountered - which suggests that every other dependency we use transpiles down to ES5.
Is it reasonable to ask you to transpile the ESM module to ES5?
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
How to transpile ES modules with webpack and Node.js
Learn how webpack interacts with and supports ES modules in this deep dive tutorial on transpilation in Node.js.
Read more >In Rollup, create ESM module with no babel transpiling except ...
1 Answer 1 · Remove the .babelrc file · Move its configuration to rollup.config.js · Configure rollup-esm.config.js to explicitly handle class ...
Read more >babel/plugin-transform-modules-umd
This plugin transforms ES2015 modules to UMD. Note that only the syntax of import/export statements ( import "./mod.js" ) is transformed, as Babel...
Read more >rollup.js
Importing CommonJS · Publishing ES Modules ... file (see example) --no-esModule Do not add __esModule property --exports <mode> Specify export mode (auto, ...
Read more >How to Build and Publish ES6 Modules Today, with Babel and ...
js 6 but additionally make sure that the import/export statements in the original source code are not transpiled into ES5 module.exports syntax. Let...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Alright, here’s the workaround if you are using ejected CRA at react scripts 1.1.5
Add this to your webpack configs:
I do still think that you should accept the PR/transpile the spread operators though.
FYI I’ve posted this question on Stack Overflow re: odd babel behaviour when trying to transpile your package from my end: https://stackoverflow.com/questions/67051317/babel-is-examining-the-package-json-of-a-target-module-for-configuration-when-tr