Browse Source

Merge pull request #499 from krzksz/module-name

Don't overwrite moduleName object for IIFE and UMD
gh-669
Rich Harris 9 years ago
parent
commit
c28557ff8b
  1. 2
      src/finalisers/iife.js
  2. 2
      src/finalisers/umd.js
  3. 2
      test/form/computed-properties/_expected/iife.js
  4. 2
      test/form/computed-properties/_expected/umd.js
  5. 2
      test/form/dedupes-external-imports/_expected/iife.js
  6. 2
      test/form/dedupes-external-imports/_expected/umd.js
  7. 2
      test/form/export-all-from-internal/_expected/iife.js
  8. 2
      test/form/export-all-from-internal/_expected/umd.js
  9. 2
      test/form/exports-at-end-if-possible/_expected/iife.js
  10. 2
      test/form/exports-at-end-if-possible/_expected/umd.js
  11. 2
      test/form/multiple-exports/_expected/iife.js
  12. 2
      test/form/multiple-exports/_expected/umd.js
  13. 2
      test/form/namespaced-named-exports/_expected/iife.js
  14. 2
      test/form/namespaced-named-exports/_expected/umd.js
  15. 2
      test/form/preserves-comments-after-imports/_expected/iife.js
  16. 2
      test/form/preserves-comments-after-imports/_expected/umd.js

2
src/finalisers/iife.js

@ -31,7 +31,7 @@ export default function iife ( bundle, magicString, { exportMode, indentString }
}
if ( exportMode === 'named' ) {
dependencies.unshift( `(this.${name} = {})` );
dependencies.unshift( `(this.${name} = this.${name} || {})` );
args.unshift( 'exports' );
}

2
src/finalisers/umd.js

@ -31,7 +31,7 @@ export default function umd ( bundle, magicString, { exportMode, indentString },
if ( exportMode === 'named' ) {
amdDeps.unshift( `'exports'` );
cjsDeps.unshift( `exports` );
globalDeps.unshift( `(${setupNamespace(options.moduleName)} = {})` );
globalDeps.unshift( `(${setupNamespace(options.moduleName)} = global.${options.moduleName} || {})` );
args.unshift( 'exports' );
}

2
test/form/computed-properties/_expected/iife.js

@ -17,4 +17,4 @@
exports.x = x;
exports.X = X;
}((this.computedProperties = {})));
}((this.computedProperties = this.computedProperties || {})));

2
test/form/computed-properties/_expected/umd.js

@ -1,7 +1,7 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(factory((global.computedProperties = {})));
(factory((global.computedProperties = global.computedProperties || {})));
}(this, function (exports) { 'use strict';
var foo = 'foo';

2
test/form/dedupes-external-imports/_expected/iife.js

@ -30,4 +30,4 @@
exports.bar = bar;
exports.baz = baz;
}((this.myBundle = {}),external));
}((this.myBundle = this.myBundle || {}),external));

2
test/form/dedupes-external-imports/_expected/umd.js

@ -1,7 +1,7 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('external')) :
typeof define === 'function' && define.amd ? define(['exports', 'external'], factory) :
(factory((global.myBundle = {}),global.external));
(factory((global.myBundle = global.myBundle || {}),global.external));
}(this, function (exports,external) { 'use strict';
class Foo extends external.Component {

2
test/form/export-all-from-internal/_expected/iife.js

@ -7,4 +7,4 @@
exports.a = a;
exports.b = b;
}((this.exposedInternals = {})));
}((this.exposedInternals = this.exposedInternals || {})));

2
test/form/export-all-from-internal/_expected/umd.js

@ -1,7 +1,7 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(factory((global.exposedInternals = {})));
(factory((global.exposedInternals = global.exposedInternals || {})));
}(this, function (exports) { 'use strict';
const a = 1;

2
test/form/exports-at-end-if-possible/_expected/iife.js

@ -9,4 +9,4 @@
exports.FOO = FOO;
}((this.myBundle = {})));
}((this.myBundle = this.myBundle || {})));

2
test/form/exports-at-end-if-possible/_expected/umd.js

@ -1,7 +1,7 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(factory((global.myBundle = {})));
(factory((global.myBundle = global.myBundle || {})));
}(this, function (exports) { 'use strict';
var FOO = 'foo';

2
test/form/multiple-exports/_expected/iife.js

@ -7,4 +7,4 @@
exports.foo = foo;
exports.bar = bar;
}((this.myBundle = {})));
}((this.myBundle = this.myBundle || {})));

2
test/form/multiple-exports/_expected/umd.js

@ -1,7 +1,7 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(factory((global.myBundle = {})));
(factory((global.myBundle = global.myBundle || {})));
}(this, function (exports) { 'use strict';
var foo = 1;

2
test/form/namespaced-named-exports/_expected/iife.js

@ -7,4 +7,4 @@ this.foo.bar = this.foo.bar || {};
exports.answer = answer;
}((this.foo.bar.baz = {})));
}((this.foo.bar.baz = this.foo.bar.baz || {})));

2
test/form/namespaced-named-exports/_expected/umd.js

@ -1,7 +1,7 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(factory((global.foo = global.foo || {}, global.foo.bar = global.foo.bar || {}, global.foo.bar.baz = {})));
(factory((global.foo = global.foo || {}, global.foo.bar = global.foo.bar || {}, global.foo.bar.baz = global.foo.bar.baz || {})));
}(this, function (exports) { 'use strict';
var answer = 42;

2
test/form/preserves-comments-after-imports/_expected/iife.js

@ -9,4 +9,4 @@
exports.obj = obj;
}((this.myBundle = {})));
}((this.myBundle = this.myBundle || {})));

2
test/form/preserves-comments-after-imports/_expected/umd.js

@ -1,7 +1,7 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(factory((global.myBundle = {})));
(factory((global.myBundle = global.myBundle || {})));
}(this, function (exports) { 'use strict';
/** A comment for a number */

Loading…
Cancel
Save