babel-plugin-universal-import: error when setting 'node: false' in webpack config
when i set node: false
(to reduce bytes to transfer) in my webpack frontend config i get the error:
Module not found: Error: Can't resolve 'path' in '__REPLACED__/src/app/universalComponent'
this is because the code transformed by the plugin makes use of __dirname
in the path
key wich is disabled by node: false
transformed code:
Home: __WEBPACK_IMPORTED_MODULE_4_react_universal_component___default()(__WEBPACK_IMPORTED_MODULE_2_babel_plugin_universal_import_universalImport_js___default()({
...
path: () => __WEBPACK_IMPORTED_MODULE_0_path___default.a.join(__dirname, '../containers/Home'), <------ __dirname
...
})
its fixed when i set node
to:
node = {
Buffer: false,
__dirname: true, // <------ note its enabled
__filename: false,
console: false,
global: false,
process: false,
};
instead of false
i am not sure if this can be “fixed” from your site but i think it would be good to add a note in one of the readmes of the coresponding repos like react-universal-component
i could add a note - just let me kow to wich repos it should be added
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 17 (7 by maintainers)
i pulled the updated demo from scratch and it works now to set node: false without error dont worry i just wanted to report it back to you as i found it thank you a lot! closing then