diff --git a/src/Module.js b/src/Module.js index 4b2e7d4..9be65dc 100644 --- a/src/Module.js +++ b/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; diff --git a/test/form/import-named-exported-global-with-alias/_config.js b/test/form/import-named-exported-global-with-alias/_config.js new file mode 100644 index 0000000..85b39fe --- /dev/null +++ b/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' + } +}; diff --git a/test/form/import-named-exported-global-with-alias/_expected/amd.js b/test/form/import-named-exported-global-with-alias/_expected/amd.js new file mode 100644 index 0000000..ec759b1 --- /dev/null +++ b/test/form/import-named-exported-global-with-alias/_expected/amd.js @@ -0,0 +1,5 @@ +define(function () { 'use strict'; + + + +}); \ No newline at end of file diff --git a/test/form/import-named-exported-global-with-alias/_expected/cjs.js b/test/form/import-named-exported-global-with-alias/_expected/cjs.js new file mode 100644 index 0000000..eb109ab --- /dev/null +++ b/test/form/import-named-exported-global-with-alias/_expected/cjs.js @@ -0,0 +1,2 @@ +'use strict'; + diff --git a/test/form/import-named-exported-global-with-alias/_expected/es6.js b/test/form/import-named-exported-global-with-alias/_expected/es6.js new file mode 100644 index 0000000..e69de29 diff --git a/test/form/import-named-exported-global-with-alias/_expected/iife.js b/test/form/import-named-exported-global-with-alias/_expected/iife.js new file mode 100644 index 0000000..f3d1016 --- /dev/null +++ b/test/form/import-named-exported-global-with-alias/_expected/iife.js @@ -0,0 +1,6 @@ +(function () { + 'use strict'; + + + +}()); \ No newline at end of file diff --git a/test/form/import-named-exported-global-with-alias/_expected/umd.js b/test/form/import-named-exported-global-with-alias/_expected/umd.js new file mode 100644 index 0000000..f3395b7 --- /dev/null +++ b/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'; + + + +})); \ No newline at end of file diff --git a/test/form/import-named-exported-global-with-alias/browser.js b/test/form/import-named-exported-global-with-alias/browser.js new file mode 100644 index 0000000..a7aab36 --- /dev/null +++ b/test/form/import-named-exported-global-with-alias/browser.js @@ -0,0 +1 @@ +export { document }; diff --git a/test/form/import-named-exported-global-with-alias/main.js b/test/form/import-named-exported-global-with-alias/main.js new file mode 100644 index 0000000..5d3739c --- /dev/null +++ b/test/form/import-named-exported-global-with-alias/main.js @@ -0,0 +1,2 @@ +import { document } from './browser.js'; +var d = document;