@loadable/babel-plugin not support webpack magic comments
See original GitHub issue🐛 Bug Report
@loadable/babel-plugin
、Module not found
As long as I remove @loadable/babel-plugin
from babel.config.json
it compiles correctly.
ERROR in ./src/components/router/index.tsx
Module not found: Error: Can't resolve '@/pages/' in 'D:\htdocs\react\react-app\src\components\router'
@ ./src/components/router/index.tsx 54:13-44 26:11-30:15
@ ./src/components/application/index.tsx
@ ./src/server.tsx
The code reporting the error is:
const Page = loadable((props: any) => import(/* webpackChunkName: "pages/[request]" */`@/pages/${props.path}`), {
cacheKey: props => props.path
});
I configured resolve.alias
in webpack
, The error persists even though I use relative path.
To Reproduce
git clone -b 3.x https://github.com/kaysonwu/react-app.git
yarn install && yarn build:server
Expected behavior
Compile correctly
Link to repl or repo (highly encouraged)
## System:
- OS: Windows 10 10.0.18363
- CPU: (8) x64 Intel(R) Core(TM) i5-8250U CPU @ 1.60GHz
- Memory: 1.74 GB / 7.89 GB
## Binaries:
- Node: 12.13.1
- Yarn: 1.21.1
- npm: 6.13.4
## npmPackages:
- @loadable/babel-plugin: ^5.12.0 => 5.12.0
- @loadable/component: ^5.12.0 => 5.12.0
- @loadable/server: ^5.12.0 => 5.12.0
- @loadable/webpack-plugin: ^5.12.0 => 5.12.0
Issue Analytics
- State:
- Created 4 years ago
- Comments:14 (10 by maintainers)
Top Results From Across the Web
Babel plugin - Loadable Components
Magic comments. To gives you flexibility and portability, the babel plugin supports magic comment. This way you can create portable "load" functions. To...
Read more >angular8.0 dynamic import not support webpack magic ...
It's working when you build for development mode only. Make sure to set the flag namedChunks in Angular.json to true before building. build:...
Read more >Fixing WebpackChunkName for Dynamic Imports - Time to Hack
Are the Webpack Magic Comments webpackChunkName not effective and working with Babel? See how to Fix it and Tips to avoid related problems....
Read more >Module Methods - webpack
Version 2 of webpack supports ES6 module syntax natively, meaning you can use ... For a full list of these magic comments see...
Read more >babel-plugin-smart-webpack-import: Documentation - Openbase
Keeps other magic comments from Webpack in-tact while adding our ones. ... "plugins": [ "babel-plugin-smart-webpack-import", "@loadable/babel-plugin" ].
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
/* webpackChunkName: "pages/[request]" */
is the issue. Remove it and it would be ok. Probably this is what babel plugin is breaking by a some reason.@gregberge @theKashey Who can evaluate it? Thank you!