Skip to content
Permalink
Browse files

fix(bundler): improve compatibility with nodejs global var "global"

A simple global var "global" is created before load all AMD modules. This is a practical way to support nodejs global var "global". In future we will build on top of dumberjs to properly support nodejs global vars "global", "process", and "Buffer" (the last two are still not supported transparently in aurelia-cli bundler). With this fix, @babel/polyfill now works as an AMD module.
  • Loading branch information...
huochunpeng committed Feb 10, 2019
1 parent 0826e29 commit 02d1cd03c0e251eb8d76526b62995bbd9bccad7b
@@ -189,7 +189,8 @@ exports.Bundle = class {

if (loaderOptions.configTarget === this.config.name) {
work = work.then(() => {
files.push({ contents: '_aureliaConfigureModuleLoader();'});
// create global var "global" for compatibility with nodejs
files.push({ contents: 'var global = this; _aureliaConfigureModuleLoader();'});
});
}

@@ -63,8 +63,7 @@ module.exports = function(project, options) {
{
'path': 'node_modules/aurelia-cli/lib/resources/scripts/configure-bluebird.js',
'env': 'dev'
},
'node_modules/@babel/polyfill/browser.js'
}
],
dependencies: [
// only needs packages not explicitly depend
@@ -1,3 +1,4 @@
import '@babel/polyfill';
import environment from './environment';

export function configure(aurelia) {
@@ -1,3 +1,4 @@
import '@babel/polyfill';
import environment from './environment';
// @if features.bootstrap='bootstrap'
import 'bootstrap';

0 comments on commit 02d1cd0

Please sign in to comment.
You can’t perform that action at this time.