-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Uncaught TypeError: __webpack_require__.O is not a function
after upgrading to a version >=4.24.0
#8143
Comments
Uncaught TypeError: __webpack_require__.O is not a function
after upgrading to a version w/ Stimulus (>=4.24.0)Uncaught TypeError: __webpack_require__.O is not a function
after upgrading to a version >=4.24.0
Maybe @jordisala1991 could help since he introduced stimulus... You could try to build less file, until it works to see which are the one with an issue. (Or at least having a smaller reproducer) |
@VincentLanglet I can also provide the contents of main.js or at least the main skeleton of the file (I'll append it to the ticket): main.js// css imports
import '../../public/bundles/mybundle/css/custom.css'; // just a plain css file, no sass/less or other transformers.
// javascript imports
import Masonry from 'masonry-layout';
window.onload = function() {
const container = document.querySelector('.masonry-grid');
if (container) {
new Masonry(container, {
itemSelector: '.grid-item',
columnWidth: '.grid-item'
});
}
}
// other irrelevant code EDIT: also, to be 100% clear, the code builds fine, the error happens ONLY during runtime in the browser's console. |
Removing main.js does remove the presence of the second error. This is looking more like a transpilation problem related to babel/webpack/foobar. |
Still looking for help here, I've tried the latest SonataAdminBundle minor version and played around with the settings in webpack config to no avail. I found similar error reports which seem to suggest that perhaps core-js and webpack/babel are interfering with each other. Perhaps my package.json dependencies need to match the same ones as used in Sonata, so that they can be compatible? Going back to SonataAdmin 4.23 always makes the issue go away. |
Looks like it's related with the single runtime chunk functionality, disabling it solves the problem. |
Would it be worth opening an issue on webpack or webpack-encore side then ? |
Not sure if this can be labeled as an issue upstream or an issue with our particular setup to be honest. I ended up having to update the admin webpack encore config to: - .enableSingleRuntimeChunk()
+ .disableSingleRuntimeChunk() and add an additional import for +import moment from 'expose-loader?exposes=moment!moment'; The symfony recommendation is to use single runtime chunk though, hence why we had this to begin with. |
I can confirm this bug. It seems to come from sonata/form-extensions >= 2.0 Starting with release 4.24.0, SonataAdmin allowed I suppose this has something to do with switch to stimulus controllers and/or the switch to the new eonasdan/bootstrap-datetimepicker in sonata-project/form-extensions 2.0 |
Environment
Sonata packages
show
Symfony packages
show
npm packages
show
Subject
After upgrading to a version >= 4.24.0 my previously working javascript now throws a cryptic webpack error which I assume derives from a transpilation issue. I also suspect it has something to do with the introduction of Stimulus, but couldn't confirm.
I've tried several things to fix the issue to no avail (eg: replacing
require
withimport
for theroutes.json
file leads to a different error).Worth noting this is very legacy javascript code that managed to be adapted to symfony/encore thanks to the use of expose-loader, imports-loader & other monkey business.
webpack encore configuration
fos_routing.js
main.js
Minimal repository with the bug
Don't have one, hard to isolate since it's a legacy application with a lot of legacy javascript code.
Happy to provide more details as requested.
Steps to reproduce
Upgrade to a version >= 4.24
Expected results
Working javascript as before.
Actual results
Javascript code builds just fine like before but the following error can be seen on the browser's console:
The first error concerns the inclusion of the FOSRouting js library, the second one concerns a plain css file loaded via
import
.The text was updated successfully, but these errors were encountered: