Closed Mordred closed 7 years ago
I'm closing this as a duplicate of aurelia/pal-browser#17, please make yourself heard over there and follow that thread for feedback.
From that thread, it's clear that loading some Aurelia modules before the PAL is initialized breaks the DI, specifically leads to inability to inject DOM.Element
and friends.
It's not directly related to Webpack.
I'm pretty sure the trigger in your repro is the addition in main.js
of
import { BindingSignaler } from 'aurelia-templating-resources';
This loads Aurelia libs before the PAL is actually initialized (said initialization is performed by aurelia-bootstrapper
).
I would say it's unfortunate that importing without actually using anything triggers this bug and that's probably what we should fix. But that's the current situation.
BTW: since you don't seem to use BindingSignaler
, removing that line should work around the problem.
That was only minimal code, so that you can reproduce it
My real code is more complicated ... I'm importing aurelia-i18n
, which is importing aurelia-templating-resources
.
And I think this is related to how webpack-plugin imports globalResources.
I'm rewriting jspm
to webpack
and this wasn't issue on the jspm
. On jspm
they were loaded when needed, but on webpack
, they are bundled and loaded directly.
The plugin doesn't "load" globalResources
.
As I said the trigger in your repro is the import
. It will load aurelia-framework
and friends and as described in the PAL issue, it was identified that loading framework libraries before the PAL is initialized leads to this bug.
Webpack might make this issue more visible because all imports are satisfied synchronously, which might change the timing. That said, the original issue was posted by a JSPM user.
I'm going to ask for the skeleton to be changed.
If you set your entry
to aurelia-bootstrapper
and remove it from main
everything should be alright.
Look here for examples: https://github.com/jods4/aurelia-webpack-build
Bootstrapping from the main
file directly is bad because of this very issue.
Thanks man,
it's working now.
One note: I had to change aureliaApp
to reference my app/main
because I'm using different file than default.
I'm submitting a bug report
Please tell us about your environment:
Operating System: OSX 10.11
Node Version: 7.5.0
NPM Version: 4.1.2
JSPM OR Webpack AND Version webpack 2.3.3
Browser: all
Language: all
Current behavior: When you import
aurelia-templating-resources
duringconfigure
,PAL.moduleName
will load all resources beforeaurelia-pal-browser
is initialized. Then when you try to useerror is thrown:
Expected/desired behavior:
I have created minimal steps to reproduce this bug on aurelia-skeleton-navigation: https://github.com/Mordred/skeleton-navigation/commit/9d9b991f7bed8a90404c5e06974ef2cf1d0eba85
What is the expected behavior? No error thrown.
What is the motivation / use case for changing the behavior? World without errors.