Skip to content

Commit

Permalink
all non-entry cjs files get wrapped
Browse files Browse the repository at this point in the history
  • Loading branch information
evanw committed Mar 25, 2021
1 parent f8fc44a commit bce7d77
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions internal/bundler/linker.go
Original file line number Diff line number Diff line change
Expand Up @@ -1375,10 +1375,9 @@ func (c *linkerContext) scanImportsAndExports() {

// If the output format doesn't have an implicit CommonJS wrapper, any file
// that uses CommonJS features will need to be wrapped, even though the
// resulting wrapper won't be invoked by other files.
if repr.meta.cjsStyleExports &&
(c.options.OutputFormat == config.FormatIIFE ||
c.options.OutputFormat == config.FormatESModule) {
// resulting wrapper won't be invoked by other files. An exception is made
// for entry point files in CommonJS format (or when in pass-through mode).
if repr.meta.cjsStyleExports && (!file.isEntryPoint || c.options.OutputFormat == config.FormatIIFE || c.options.OutputFormat == config.FormatESModule) {
repr.meta.cjsWrap = true
}

Expand Down

0 comments on commit bce7d77

Please sign in to comment.