-
Notifications
You must be signed in to change notification settings - Fork 769
Migrate to webpack@4 API #110
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
Conversation
|
Hey @7rulnik, thank you for the update! I've got this error when I tried to compile with Webpack: |
|
in webpack 4 all import() is wrapped in default, need change code in render of object assign to return obj.default |
function render(loaded, props) {
const resolved = resolve(loaded);
const component = Object.prototype.hasOwnProperty.call(resolved, 'default') ? resolved.default : resolved;
return React.createElement(resolve(loaded), props);
}this resolve the problem when use import for loading the components for example this load the datas for universal js await trigger('fetch', components, triggerLocals); now this not work |
|
@NandoSangenetto seems that you forget to transpile files. @joacub good catch! Can you give more info about |
|
Instead of const component = resolved && resolved.__esModule ? resolved.default : resolved; |
|
Waiting for the further merge operation |
|
@7rulnik trigger fetch running before correct and running ok if in the import use a import(Component).then(object => object.default)the solution not is in the module, aparently webpack change the method for return the imports and react-loadable never can return object without default |
|
@7rulnik , Is there an estimated timeline for this PR to land ? We're waiting it in order to move to webpack 4. Sorry to ask the question here, I understand this may not be the right place but since issues are not enabled /accessible 😅 By the way thanks to all |
|
@Oza94 Im not a maintainer of this project. So, we are waiting for @jamiebuilds reaction. |
|
Thanks for the feedback @7rulnik :) The scoped package is a good option for us, at least we can validate that everything works fine. However we can also wait a few days for the main package and @jamiebuilds 's response so do not feel committed to publish it |
f394144 to
a8b9c92
Compare
|
@Oza94 just published https://yarnpkg.com/en/package/@7rulnik/react-loadable |
|
@7rulnik tried using your release but am getting If I downgrade to Webpack 3 everything works as expected. Any ideas? Been debugging for awhile. |
|
@onetrickwolf did you saw #110 (comment)? Are you using es6 modules or commonJS? |
|
@7rulnik hey sorry should have read better, thanks that fixed it. For others having the same problem this fixed it for me: Will this be the permanent fix by the way? Should the docs be updated once this PR is merged? |
|
@onetrickwolf yes, aparently this is the way, webpack in the import return always object { default }, this not is catcheable for react-loadable. |
|
can I confirm is the current master version of react-loadable compatible with webpack 4 out of the box? Sorry still newbie here 🙇 |
|
@alamchrstn I don't think current master version supports webpack 4, that's why this pull is still open |
|
@EvgeniyKumachev ah I see, can someone give a working example of react loadable with webpack 4? thanks in advance 🙇 I'm still learning here... |
|
@alamchrstn you can use #110 (comment) |
|
How do you guys setup the splitchunks configuration? |
|
I’m working dame only change de load method for this |
|
How do you handle |
|
@dekryptic |
|
I dont’t have the problem the bundles load automatic with webpack |
|
@joacub Can you show how they are loaded? |
|
@7rulnik Do you have a working version up? If not, how do you suggest it be handled? |
|
@7rulnik You forgot to change this var source = path.node.source.value;
if (source !== 'react-loadable') return;at lib/babel.js line 13. This caused the babel plugin of your scoped package didn't work. The source is |
|
I'm getting this warning in |
|
Shall I create a PR supporting new lifecycle for |
|
@abramstyle just published |
|
Manifest now contains all vendors chunks. And it's smaller. You can test it in |
This comment has been minimized.
This comment has been minimized.
|
This seems to be breaking SSR, manifest doesn't look good at all. Will try to investigate more and report here {
"null": [
{
"file": "2.css",
"publicPath": "/2.css",
"chunkName": null,
"id": null
},
{
"file": "2.chunk.js",
"publicPath": "/2.chunk.js",
"chunkName": null,
"id": null
}
]
} |
|
@VincentCharpentier
Not sure if it's related to Webpack 4 but I had to fiddle allot with the .babelrc config; |
|
Thank you for the feedback, I'll try to find out what I'm missing |
|
I was using |
|
webpack 4 can handle dynamic import. just use |
|
Still have issues (no name property and null id property in manifest), but it seems like it's because @7rulnik/react-loadable/babel is not run by babel. Everything is fine if I manually add 'module' and 'webpack' properties to each loadables components. |
|
@VincentCharpentier Sounds like you didn't add @7rulnik everywhere and are still using react-loadable. Do a search for react-loadable in your project. Make sure every definition is prefixxed like so: |
|
I don't have react-loadable installed, only module: {
rules: [
{
test: /\.(js|jsx)?$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
babelrc: false,
plugins: [
'@7rulnik/react-loadable/babel',
'syntax-dynamic-import',
],
presets: [
[
'env',
{
'loose': false,
'shippedProposals': true,
},
],
'react',
],
},
},
},
// ...and my .babelrc (for server): // server only
{
"plugins": [
"@7rulnik/react-loadable/babel",
"dynamic-import-node"
],
"presets": [
[
"env",
{
"loose": false,
"shippedProposals": true
}
],
"react"
]
}Only difference between them is |
|
@VincentCharpentier |
|
thanks for your feedback. Could you also share you package.json ? especially dependencies and devdependencies, I think I have something incompatible |
|
|
Thanks for your feedback. Then I can only provide loader property when I want to use Loadable. In this scenario, react-loadable is now broken 😕. It won't generate ids in the manifest, thus breaking the SSR (no module reported) |
|
@7rulnik Hello, thank you for you fork. I found the issue with webpack plugin. In some cases block.module is null https://github.com/7rulnik/react-loadable/blob/scoped-version/src/webpack.js#L26 and plugin obviously throws the error. Could you please add small check that module object exists? |
? 😕 |
|
@vasivas This is because |
No description provided.