I've upgraded @symfony/webpack-encore to 0.15 and now I got this error:
Running webpack ...
Error: Encore.__esModule is not a recognized property or method.
index.js:799 Object.get
[crm]/[@symfony]/webpack-encore/index.js:799:27webpack.config.babel.js:11 _interopRequireDefault
/var/kamil/projects/deheus/crm/webpack.config.babel.js:11:57webpack.config.babel.js:9 Object.
/var/kamil/projects/deheus/crm/webpack.config.babel.js:9:23module.js:624 Module._compile
module.js:624:30node.js:144 loader
[crm]/[babel-register]/lib/node.js:144:5node.js:154 Object.require.extensions.(anonymous function) [as .js]
[crm]/[babel-register]/lib/node.js:154:7module.js:545 Module.load
module.js:545:32module.js:508 tryModuleLoad
module.js:508:12module.js:500 Function.Module._load
module.js:500:3module.js:568 Module.require
module.js:568:17
Problematic commit: https://github.com/symfony/webpack-encore/commit/d5924814a9f6fb11fe058d89999b51bb06d623e8
Hi @lewactwo,
Some questions to pinpoint the origin of this issue:
webpack.config.babel.js file?Thanks
webpack.config.babel.js:
import Encore from '@symfony/webpack-encore';
Encore
.setOutputPath('./public/assets/')
.setPublicPath('/assets')
.cleanupOutputBeforeBuild()
.addEntry('app', './frontend/scripts/main.js')
.addStyleEntry('global', './frontend/styles/main.scss')
.createSharedEntry('vendor', [
'jquery',
'jquery-datetimepicker/jquery.datetimepicker.css'
])
.enableSassLoader()
.autoProvidejQuery()
.enableSourceMaps(!Encore.isProduction())
.enableVersioning()
;
const config = Encore.getWebpackConfig();
Object.assign(config, {
resolve: {
alias: {
'jquery-ui/ui/widget': './vendor/jquery.ui.widget.js',
}
}
});
export default config;
command:
make frontend which is node_modules/.bin/encore production
node -v
v8.5.0
yarn -v
1.0.2
I'm a bit confused by the first line of your webpack.config.babel.js since Node doesn't support ES6 imports/exports yet... do you preprocess that file ?
Do you still have an error if you replace it by const Encore = require('@symfony/webpack-encore'); ?
hmm, I think this is related to the new error-catching proxy added in #150.
Such proxy is incompatible with the JS pattern of checking property existence by getting it and comparing with undefined (as this proxy is precisely throwing in this case.
@Lyrkan when the file is named webpack.config.babel.js rather than webpack.config.js, Webpack preprocesses the config file with Babel before loading it.
@weaverryan @Lyrkan I suggest whitelisting the properties accessed by the babel require wrapper (_interopRequireDefault).
I am using ES6 in webpack.config from year :) If I revert webpack-encore to 0.14 it works as expected.
@lewactwo yeah, as I said, this is related to a change we made to provide better error reporting. We should be able to fix it in the next version of Encore
Didn't know that @stof, I'll check it out more in details later but yeah it looks like the following change is enough for a basic use case (no idea if there is something else we should worry about though):
const publicApiProxy = new Proxy(publicApi, {
get: (target, prop) => {
if (prop === '__esModule') {
return target[prop];
}
// (...)
}
});
That's the only property they access: http://babeljs.io/repl/#?babili=false&browsers=&build=&builtIns=false&code_lz=JYWwDg9gTgLgBAMQhOAzKERwOQCMCGU2QA&debug=false&circleciRepo=&evaluate=true&lineWrap=false&presets=es2015%2Creact%2Cstage-2&prettier=false&targets=&version=6.26.0
Fix merged and 0.15.1 tagged. I hope this helps! Thanks for the fix @Lyrkan and @lewactwo for the report!