Skip to content

Commit

Permalink
Merge pull request #1046 from huochunpeng/nodejs-global
Browse files Browse the repository at this point in the history
fix(bundler): enable tracing @babel/polyfill
  • Loading branch information
EisenbergEffect authored Feb 11, 2019
2 parents 0826e29 + 1bef893 commit a1ccc1a
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 4 deletions.
3 changes: 2 additions & 1 deletion lib/build/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();'});
});
}

Expand Down
5 changes: 4 additions & 1 deletion lib/build/bundled-source.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,10 @@ exports.BundledSource = class {
let contents;
// forceCjsWrap bypasses a r.js parse bug.
// See lib/amodro-trace/read/cjs.js for more info.
let forceCjsWrap = !!modulePath.match(/(\/|\\)(cjs|commonjs)(\/|\\)/i);
let forceCjsWrap = !!modulePath.match(/(\/|\\)(cjs|commonjs)(\/|\\)/i) ||
// core-js uses "var define = ..." everywhere, we need to force cjs
// before we can switch to dumberjs bundler
(desc && desc.name === 'core-js');

try {
contents = cjsTransform(modulePath, this.contents, forceCjsWrap);
Expand Down
3 changes: 1 addition & 2 deletions lib/commands/new/buildsystems/cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions lib/resources/src/main-cli.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import '@babel/polyfill';
import environment from './environment';

export function configure(aurelia) {
Expand Down
1 change: 1 addition & 0 deletions lib/resources/src/main-cli.template.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import '@babel/polyfill';
import environment from './environment';
// @if features.bootstrap='bootstrap'
import 'bootstrap';
Expand Down

0 comments on commit a1ccc1a

Please sign in to comment.