with encore webpack, I do add a js file:
Encore
.addEntry('js/request', './assets/js/request.js')
.cleanupOutputBeforeBuild()
.disableSingleRuntimeChunk()
.splitEntryChunks()
...
Inside the request.js, I import a custom module:
import Request from './request';
console.log(Request);
window.Request = Request;
Which is exported in request/index.js:
export default () => ({
url: null,
options: { method: 'GET' },
response: null,
load() {
...
Pretty straight forward actually. BUT - when I compile this, I get a warning:
warning in ./assets/js/request.js
"export 'default' (imported as 'Request') was not found in './request'
And undefined is logged for that console.log(Request);
command.
Usually this happens, when you don't export as default but I do and somehow don't? This doesn't make sense at all for me. I'm pretty new to webpack and couln't find a helpful hint so far...
Anyone an idea what I'm doing wrong?
CodePudding user response:
Oh man, I've put a request.js
and a request/index.js
into the same folder.
So when I import ./request
inside request.js
, its gonna import itself due to the hierarchy of the import file detection.
Now I will just put all the files into a separate folder /entries
and will be able to import ../request
. Importing explicitly import ./request/index.js
will also work.
I guess this just has to happen once, when you start with modules, webpack and stuff...