Module parse failed: Unexpected token. You may need an appropriate loader to handle this file type
See original GitHub issueWhat’s the current behavior?
I simply added the library to my package.json, and now I can’t even bundle my code:
Seems like it comes from the following files:
➜ node_modules master✗ ack 'autoFocus, decorate = defaultDecorate, onDOMBeforeInput'
slate-react/dist/slate-react.js
1215: const { autoFocus, decorate = defaultDecorate, onDOMBeforeInput: propsOnDOMBeforeInput, placeholder, readOnly = false, renderElement, renderLeaf, style = {}, as: Component = 'div', ...attributes } = props;
slate-react/dist/index.js
579: const { autoFocus, decorate = defaultDecorate, onDOMBeforeInput: propsOnDOMBeforeInput, placeholder, readOnly = false, renderElement, renderLeaf, style = {}, as: Component = 'div', ...attributes } = props;
slate-react/dist/index.es.js
572: const { autoFocus, decorate = defaultDecorate, onDOMBeforeInput: propsOnDOMBeforeInput, placeholder, readOnly = false, renderElement, renderLeaf, style = {}, as: Component = 'div', ...attributes } = props;
Slate: 0.57.1 Browser: Chrome 79 & Firefox 72 OS: macOs
My package.json:
"@rails/webpacker": "3.4",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-2": "^6.24.1",
"react-dom": "^16.10.2",
"react-hot-loader": "4",
"ts-loader": "3.5.0",
"typescript": "^3.7.2",
"webpack-dev-server": "2.11.2",
"webpack-merge": "^4.1.2",
"react": "^16.10.2",
"slate": "^0.57.1",
"slate-react": "^0.57.1",
My .babelrc:
{
"presets": [
[
"env",
{
"modules": false,
"targets": {
"browsers": "> 1%",
"uglify": true
},
"useBuiltIns": true
}
],
"react",
"stage-2"
],
"plugins": [
"syntax-dynamic-import",
"transform-object-rest-spread",
[
"transform-class-properties",
{
"spec": true
}
],
"transform-runtime"
]
}
Issue Analytics
- State:
- Created 4 years ago
- Reactions:5
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Module parse failed: Unexpected Token. You may need an ...
React - Module parse failed: Unexpected Token. You may need an appropriate loader to handle this file type · Subscribe to RSS.
Read more >Module parse failed: Unexpected token. You may ... - GitHub
Module parse failed: Unexpected token. You may need an appropriate loader to handle this file type, currently no loaders are configured to process...
Read more >Odyssey Lift-off I: "Module parse failed: Unexpected token" Error
You may need an appropriate loader to handle this file type. Looks like webpack is unhappy for some reason. Could be a few...
Read more >You may need an appropriate loader to handle ... - Laracasts
resources/js/Pages/Animes/AnimeForm.vue 1:0 Module parse failed: Unexpected token (1:0) You may need an appropriate loader to handle this file type, ...
Read more >[Help] Module parse failed: Unexpected token . Babel not ...
Delete node_modules folder and try again, make sure you use latest LTS versions for node and npm. Freddie February 17, 2022, 7:46am ...
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
Most likely babel is not processing your node_modules. And it should not. Libraries have the responsibility of providing a valid JS code in the package.
It is valid JS according to latest ECMAScript specs. The problem is that not all browsers support latest ECMAScript specs. IE does not support destructuring assigments at all.
Edge does not support “Rest in objects” (
...attributes
part). See browser compatibility table at https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignmentI think I found what the problem is. https://github.com/ianstormtaylor/slate/blob/217bdd611b08305b2598f7d0bd25d34ed40f2912/config/rollup/rollup.config.js#L92
It should specify
tsx
extension as well.Nope. Im not planning on releasing in part because there are some void inline selection bugs.