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
Caught (in promise) TypeError: c[t] is not a function, Index.js code doesn't run when served publicly, Updated Webpack #17223
Comments
I'm also encountering the same issue. To better understand the root cause, I plan on replicating it within a simplified project context. |
Please use:
CSS is under experiments right now, also you can see warnings, because
|
Other solution when you enable
I will improve warnings in |
Thank you. The first solution solved the issue. |
Fixed in Feel free to feedback |
Bug report
What is the current behavior?
When bundled files are served publicly, any code inside the index.js (entry point for bundle) does not execute or run. However, all imports into index.js which include functions run with no problem. When bundle is served using webpack-dev-server, there is no problem there. To test, I deleted all the code in index.js and wrote a console.log() inside a function. The function did not execute at all.
The following error is thrown:
Looking into the bundled file where the error is:
The imports include files that use top-level await. Other than that, there are no promises in the index.js.
Css, html, and images in bundle all display correctly.
If the current behavior is a bug, please provide the steps to reproduce.
https://github.com/gdkoo/SleepWakeRegulate/blob/main/webpack.config.cjs
What is the expected behavior?
Using miniCSSExtractPlugin and HTML Webpack Plugin, index.html, style.css, and index.js should all be bundled into main.js and main.css, and an index.html should be generated in a public folder. This is all happening correctly. When running npm run build and npm run serve, the code all executes correctly. However, when served to Firebase hosting or another emulator, the bundled code executes everything except code from index.js. This ranges from simple console.log()s to images that are added to the DOM.
After some debugging, I found that removing the './style.css' import specifically (which thereby prevents the main.css bundle), rebundling, and serving publicly led to the rest of index.js file executing as expected. However, doing so removes the css stylesheet. I suspect the issue in my case might have to do with the miniCSSExtractPlugin.
Other relevant information:
webpack version: 5.83.1
Node.js version: v16.18.0
Operating System: macOS 11.0.1
Additional tools:
@webpack-cli/generators: ^3.0.1 => 3.0.1
babel-loader: ^9.1.0 => 9.1.0
css-loader: ^6.7.2 => 6.7.2
html-webpack-plugin: ^5.5.1 => 5.5.1
style-loader: ^3.3.1 => 3.3.1
url-loader: ^4.1.1 => 4.1.1
webpack: ^5.83.1 => 5.83.1
webpack-cli: ^5.0.1 => 5.0.1
webpack-dev-server: ^4.11.1 => 4.11.1
The text was updated successfully, but these errors were encountered: