-
I am trying to import json namespaces from 2 modules (project dependencies), but they do not load. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I think this has to do with how Webpack works to resolve dynamic imports. It needs to know in advance the path to create the necessary chunks. If the path is dynamic, Webpack does not know which chunks to create, and I guess the problem comes from here. Something like this: function loadLocaleFrom(lang, ns) {
const path = someCondition ? './some-path' : '/another-path'
return import(`{path}/${lang}/${ns}.json`).then((m) => m.default),
} Webpack don't know the function loadLocaleFrom(lang, ns) {
if(someCondition) return import(`./some-path/${lang}/${ns}.json`).then((m) => m.default)
return import(`./another-path/${lang}/${ns}.json`).then((m) => m.default)
} This way, Webpack knows that should create chunks to all the content of Hope it helps! |
Beta Was this translation helpful? Give feedback.
I think this has to do with how Webpack works to resolve dynamic imports. It needs to know in advance the path to create the necessary chunks. If the path is dynamic, Webpack does not know which chunks to create, and I guess the problem comes from here.
Something like this:
Webpack don't know the
path
in advance. So maybe it helps to change it to something like: