Closed ekzobrain closed 3 years ago
Hello Dmitry,
I've never seen this error before myself. Chances are you'll have to find a solution for this as I'm not actively developing these modules anymore (I just maintain them) but I would be more than happy to accept a PR once you find the solution. Otherwise I'm pretty sure the recommended path works fine (a lot of installs and no complaints seem to verify this).
Hi, @RWOverdijk
I experimentally found that it happens because of these lines (9-11) is source code:
// added for bundling
import {AuthFilterValueConverter} from './authFilterValueConverter'; // eslint-disable-line no-unused-vars
import {AuthenticatedFilterValueConverter} from './authenticatedFilterValueConverter'; // eslint-disable-line no-unused-vars
import {AuthenticatedValueConverter} from './authenticatedValueConverter'; // eslint-disable-line no-unused-vars
They lead to recursive imports in es2015 build (aurelia-authentication.js imports authFilterValueConverter.js at the top, which imports AuthService from aurelia-authentication.js, which is not yet defined at that time). Do you have ideas how to quickly fix this?
I don't know actually. It's strange that you're the first to have this issue. Perhaps it's a configuration issue? Otherwise, one of the two needs to get the other injected which is not really a quick fix I'm afraid.
I see this as well, es2015 dist folder is unusable
The reason not many people are seeing this is that most use aurelia-plugin's default dist: "native-modules" which does not have such a problem. Once you start producing es6 bundles it becomes an issue
Removing those imports from spoonx.js
did not visibly do any damage to the build
As a temporary workaround with webpack you can use
resolve: {
alias: {
"aurelia-authentication": "aurelia-authentication/dist/native-modules"
}
}
@MaximBalaganskiy :+1: nice find.
What do you recommend doing here? I've been out of the loop for a bit and went into maintenance mode for these plugins. Just removing the imports doesn't sound very compelling to me. @doktordirk Any input?
The only reason for those imports to be there, as far as I can see, is to copy the files to the dist folder. Removing them does not change it - the files are still copied, so I still think this is the best solution.
It has been a while, but I remember that back then all of this was necessary to support different types of packagers. If everything still works it's fine by me. @doktordirk Do you remember?
Webpack would find those via PLATFORM.moduleName
. Not sure about the rest...
I'm not against getting a fix in. But since I don't actively use this anymore, and this is used in production by others, I need to be extra careful.
As long as there are tests to back it up we can definitely push changes though! :)
i've just tested why converters are not included... the offender is the method they are added to global resources - dynamically from the config, Neither webpack nor CLI can pick them up unless there are explicit strings similar to
frameworkConfig.globalResources(PLATFORM.moduleName('./authFilterValueConverter'));
I've just tested this in the latest CLI and WP projects
Hi!
I get this runtime error in Google Chrome when targeting es2015 build in Webpack (https://github.com/aurelia/webpack-plugin/wiki/Minimize-size#use-es6-if-you-can). Backtrace:
In Firefox this error is reported as: "ReferenceError: "can't access lexical declaration `AuthService' before initialization"
Thanks in advance, Dmitry.