Skip to content

Commit

Permalink
Use var for IIFE (#4588)
Browse files Browse the repository at this point in the history
Otherwise, the created variable is not on the global object
  • Loading branch information
lukastaegert committed Jul 26, 2022
1 parent 27c0557 commit 3502ac4
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/finalisers/iife.ts
Expand Up @@ -37,7 +37,7 @@ export default function iife(
strict
}: NormalizedOutputOptions
): Bundle {
const { _, cnst, getNonArrowFunctionIntro, getPropertyAccess, n } = snippets;
const { _, getNonArrowFunctionIntro, getPropertyAccess, n } = snippets;
const isNamespaced = name && name.includes('.');
const useVariableAssignment = !extend && !isNamespaced;

Expand Down Expand Up @@ -96,7 +96,7 @@ export default function iife(
if (hasExports) {
if (name && !(extend && namedExportsMode)) {
wrapperIntro =
(useVariableAssignment ? `${cnst} ${name}` : `this${keypath(name, getPropertyAccess)}`) +
(useVariableAssignment ? `var ${name}` : `this${keypath(name, getPropertyAccess)}`) +
`${_}=${_}${wrapperIntro}`;
}
if (isNamespaced) {
Expand Down
@@ -1,4 +1,4 @@
const myBundle = (function (other) {
var myBundle = (function (other) {
'use strict';

const a = 1;
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

@@ -1,4 +1,4 @@
const bundle = (function (exports, foo$1) {
var bundle = (function (exports, foo$1) {
'use strict';

const _interopDefaultLegacy = e => e && typeof e === 'object' && 'default' in e ? e : { 'default': e };
Expand Down

0 comments on commit 3502ac4

Please sign in to comment.