At the moment, determining pal module is not enough for v5, where target of the webpack configuration could take the type string | false | string[] | undefined. Currently, this is casted to string, as it's rarely needed more than that. However, for IE11, with the recommendation from webpack being target: ['web', 'es5'], the following code becomes insufficient:
function getPAL(target: string) {
switch (target) {
case "web": return "aurelia-pal-browser";
case "webworker": return "aurelia-pal-worker";
case "electron-renderer": return "aurelia-pal-browser";
default: return "aurelia-pal-nodejs";
}
}
Change it to:
function getPAL(target?: string | string[] | false) {
if (target instanceof Array) {
if (target.includes('web') || target.includes('es5')) {
return 'aurelia-pal-browser';
}
// not really sure what to pick from an array
target = target[0];
}
if (target === false) {
throw new Error('Invalid target to build for AureliaPlugin.');
}
switch (target) {
case undefined:
case "es5":
case "web":
return "aurelia-pal-browser";
case "webworker": return "aurelia-pal-worker";
case "electron-renderer": return "aurelia-pal-browser";
default: return "aurelia-pal-nodejs";
}
}
This should also help prevent issues with aurelia-pal-nodejs not found when target is not specified. Nodejs app shouldn't be the default.
Tested on IE for the test app at tests/app-simple
Closes #187
Thanks @ItWorksOnMyMachine and @elitastic
@elitastic for #175 , can you check again a few things, against latest master after this is merged:
tsconfig target is es5
target in webpack configuration is ['web', 'es5']
dist options in the AureliaPlugin is native-modules (or don't specify, as this is the default value)
Additionally, added a basic tests with aurelia-testing to verify that the build actually works.
At the moment, determining pal module is not enough for v5, where
target
of the webpack configuration could take the typestring | false | string[] | undefined
. Currently, this is casted tostring
, as it's rarely needed more than that. However, for IE11, with the recommendation from webpack beingtarget: ['web', 'es5']
, the following code becomes insufficient:Change it to:
This should also help prevent issues with
aurelia-pal-nodejs
not found whentarget
is not specified. Nodejs app shouldn't be the default.Tested on IE for the test app at![image](https://user-images.githubusercontent.com/9994529/126065078-ab61265d-3f00-49a5-af58-7c53e24c415c.png)
tests/app-simple
Closes #187
Thanks @ItWorksOnMyMachine and @elitastic
@elitastic for #175 , can you check again a few things, against latest master after this is merged:
['web', 'es5']
dist
options in theAureliaPlugin
isnative-modules
(or don't specify, as this is the default value)Additionally, added a basic tests with
aurelia-testing
to verify that the build actually works.