-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Codesplit chunks are out of order causes "webpackJsonp is not defined" error #1411
Comments
Sounds like chunks are loaded out of order. Can you share your webpack config for storybook? |
storybook config var webpackConfig = require('../webpack/webpack.config');
var devConfig = webpackConfig[0];
module.exports = function(storybookConfig) {
const fullConfig = Object.assign({}, storybookConfig, devConfig, {
entry: storybookConfig.entry,
output: storybookConfig.output,
plugins: storybookConfig.plugins.concat(devConfig.plugins),
module: Object.assign({}, storybookConfig.module, {
rules: storybookConfig.module.rules.concat(devConfig.module.rules)
}),
resolve: Object.assign({}, devConfig.resolve, storybookConfig.resolve, {
alias: Object.assign(
{},
devConfig.resolve.alias,
storybookConfig.resolve.alias
)
}),
resolveLoader: Object.assign(
{},
devConfig.resolveLoader,
storybookConfig.resolveLoader,
{
alias: Object.assign(
{},
devConfig.resolveLoader.alias,
storybookConfig.resolveLoader && storybookConfig.resolveLoader.alias
)
}
)
});
return fullConfig;
}; my dev webpack config var config = {
entry: {
shim: ['babel-polyfill', paths.shimContext],
postWindowMessage: paths.postWindowMessageContext,
cms: paths.cmsContext
},
plugins: [
new webpack.NoEmitOnErrorsPlugin()
],
rules: [
{
test: /\.jsx?$/,
use: ['babel-loader'],
include: paths.cmsSrc,
exclude: [
paths.generatedSrc
]
},
{
test: /\.scss$/,
exclude: /style\.scss$|passwordField\.scss$|progress-circle\.scss$/,
use: [
'style-loader',
{
loader: 'css-loader',
options: {
sourceMap: true,
modules: true,
importLoaders: 2,
localIdentName: '[name]__[local]___[hash:base64:5]'
}
},
{
loader: 'postcss-loader',
options: Object.assign(loaderConfigs.postcss, {
sourceMap: true
})
},
{
loader: 'sass-loader',
options: Object.assign(loaderConfigs.sass, {
sourceMap: true
})
}
]
}
],
output: {
publicPath: '/static/' + brand + '/cache-0/js/cms/voyage/'
},
devtool: 'inline-source-map'
}; which is merged in the baseConfig const baseConfig = options => {
// Needed plugins for both production and development
var plugins = [
new webpack.DefinePlugin({
'process.env': Object.assign(
{},
{
BRAND: JSON.stringify(brand)
},
options.env
),
}),
new SvgStore.Options({
svgoOptions: {
plugins: [
{ removeDesc: true },
{ removeAttrs: { attrs: 'fill|class|style' } },
{ removeStyleElement: true },
{ removeRasterImages: true },
{ sortAttr: true }
]
}
})
];
// Loaders needed both for production and development
var loaders = [
{
test: /generated\.js/,
use: ['raw-loader', {
loader: 'js-obfuscation-loader',
options
}]
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader']
},
{
test: /style\.scss$|passwordField\.scss$|progress-circle\.scss$/,
use: [
'style-loader',
'css-loader',
{
loader: 'postcss-loader',
options: loaderConfigs.postcss
},
{
loader: 'sass-loader',
options: loaderConfigs.sass
}
]
},
{
test: /\.svg$/,
use: ['babel-loader', 'svg-react-loader']
},
{
test: /\.html$/,
loader: 'raw-loader'
}
];
return {
entry: options.entry,
devtool: options.devtool,
output: Object.assign(
{},
{
path: paths.jsDist,
filename: '[name].js',
chunkFilename: '[name].js',
jsonpFunction: 'webpackJsonpCustom'
},
options.output
),
plugins: plugins.concat(options.plugins || []),
module: {
rules: loaders.concat(options.rules || [])
},
resolve: {
extensions: ['.js', '.jsx'],
modules: [
paths.jsSrc,
'node_modules'
],
alias: {
jquery: paths.jquery
},
plugins: [
new ComponentResolverPlugin()
]
},
resolveLoader: {
alias: {
'js-obfuscation-loader': paths.obfuscationLoaderSrc
}
},
externals: {
cms: 'cms'
},
node: {
fs: 'empty',
net: 'empty',
tls: 'empty',
}
};
}; |
Is there automatic code-splitting happening anywhere within your code? What files does webpack output for storybook? You entry points for storybook seem in order. |
Yes I have a lot of chunks. All of them start with webpackJsonp. |
I think I will close this. It seems like I have another error which causes this file to crash. That is why the function is not defined. |
My error is that a file declaring a global variable gets a Reference Error because the code is executed in strict mode. |
I still get the errors in the console after I fixed my issue. The storybook works in some stories, but in some others I get the following error:
No idea what is going on... |
Try the devtools profiler to find out what's going on, the flame chart will likely give you insight into where the recursion is happening. |
So one of the errors was a deprecate warning about action being imported from storybook/react. |
Now I got it. |
I have this error too. It loads 0.bundle.js before preview.bundle.js. 0 is a code split point created by require.ensure() |
That's a bug! |
Hi guys, I made a PR to fix this : #1775 @CurtisHumphrey @florian-bd could you review it & test it with your project to see if it fixes the issue ? Thanks ! |
Hi @thomasbertet |
I had the same problem and updating to 3.3.0-alpha.0 also fixed it, thanks! |
Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 60 days. Thanks! |
Looks like this was fixed in #1775, so this issue should be closed. |
I recently upgraded to webpack3 and storybook3.
I use full control configuration.
When I build everything is fine, but when I run the storybook, I get the error "webpackJsonp is not defined" in all the bundle.
I thought this variable was added by CommonsChunkPlugin but I am not using it. I just use DefinePlugin.
Any idea if this is coming from the storybook?
The text was updated successfully, but these errors were encountered: