Browse Source

Fix edge case for non-exported variable declaration aliases for exported globals.

Closes #560.
gh-669
Brian Donovan 9 years ago
parent
commit
fa521cbddd
  1. 2
      src/Module.js
  2. 6
      test/form/import-named-exported-global-with-alias/_config.js
  3. 5
      test/form/import-named-exported-global-with-alias/_expected/amd.js
  4. 2
      test/form/import-named-exported-global-with-alias/_expected/cjs.js
  5. 0
      test/form/import-named-exported-global-with-alias/_expected/es6.js
  6. 6
      test/form/import-named-exported-global-with-alias/_expected/iife.js
  7. 9
      test/form/import-named-exported-global-with-alias/_expected/umd.js
  8. 1
      test/form/import-named-exported-global-with-alias/browser.js
  9. 2
      test/form/import-named-exported-global-with-alias/main.js

2
src/Module.js

@ -189,7 +189,7 @@ export default class Module {
const declaration = this.declarations[ name ];
const statement = declaration.statement;
if ( statement.node.type !== 'VariableDeclaration' ) return;
if ( !statement || statement.node.type !== 'VariableDeclaration' ) return;
const init = statement.node.declarations[0].init;
if ( !init || init.type === 'FunctionExpression' ) return;

6
test/form/import-named-exported-global-with-alias/_config.js

@ -0,0 +1,6 @@
module.exports = {
description: 'allow globals to be exported and imported',
options: {
moduleName: 'doc'
}
};

5
test/form/import-named-exported-global-with-alias/_expected/amd.js

@ -0,0 +1,5 @@
define(function () { 'use strict';
});

2
test/form/import-named-exported-global-with-alias/_expected/cjs.js

@ -0,0 +1,2 @@
'use strict';

0
test/form/import-named-exported-global-with-alias/_expected/es6.js

6
test/form/import-named-exported-global-with-alias/_expected/iife.js

@ -0,0 +1,6 @@
(function () {
'use strict';
}());

9
test/form/import-named-exported-global-with-alias/_expected/umd.js

@ -0,0 +1,9 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory() :
typeof define === 'function' && define.amd ? define(factory) :
(factory());
}(this, function () { 'use strict';
}));

1
test/form/import-named-exported-global-with-alias/browser.js

@ -0,0 +1 @@
export { document };

2
test/form/import-named-exported-global-with-alias/main.js

@ -0,0 +1,2 @@
import { document } from './browser.js';
var d = document;
Loading…
Cancel
Save