问题
I have the following code :
var path = "./relative/path/to/" + fileName + ".json";
import(path).then(cb);
The import
works as expected in my Electron demo (which uses Webpack 3.12).
It breaks in my Angular demo (which uses Webpack 4.28).
My Angular demo has the following Webpack config :
module.exports = {
node: { fs: 'empty' }
};
It produces the following error at runtime :
Unhandled Promise rejection: Cannot find module './resources/symbology/labelTemplates/labelTemplates.json' ; Zone: <root> ; Task: Promise.then ; Value: Error: Cannot find module './resources/symbology/labelTemplates/labelTemplates.json'
at symbology lazy namespace object:5
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (zone.js:391)
at Zone.push../node_modules/zone.js/dist/zone.js.Zone.run (zone.js:150)
at zone.js:889
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:423)
at Zone.push../node_modules/zone.js/dist/zone.js.Zone.runTask (zone.js:195)
at drainMicroTaskQueue (zone.js:601) Error: Cannot find module './resources/symbology/labelTemplates/labelTemplates.json'
...
I tried various changes to my config, but I keep getting the same error.
Am I doing something wrong?
来源:https://stackoverflow.com/questions/54651712/import-breaks-in-angular-7-2-3-webpack-4-28