Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Emit inline comments inside dynamic import (#2797)
* Emit inline comments inside dynamic import fixes #2778 * space after import still generates valid JS * Using findFirstOccurrenceOutsideComment()
- Loading branch information
1 parent
fadf7bc
commit 6709c17
Showing
7 changed files
with
50 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
test/chunking-form/samples/dynamic-import-comments/_config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module.exports = { | ||
description: 'should not remove inline comments inside dynamic import', | ||
options: { | ||
input: 'main.js', | ||
onwarn() {}, | ||
plugins: { | ||
resolveDynamicImport() { | ||
return false; | ||
} | ||
}, | ||
output: { | ||
dynamicImportFunction: 'foobar' | ||
} | ||
} | ||
}; |
7 changes: 7 additions & 0 deletions
7
test/chunking-form/samples/dynamic-import-comments/_expected/amd/main.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
define(['require'], function (require) { 'use strict'; | ||
|
||
new Promise(function (resolve, reject) { require([ | ||
/* webpackChunkName: "chunk-name" */ | ||
'./foo.js'/*suffix*/], resolve, reject) }); | ||
|
||
}); |
5 changes: 5 additions & 0 deletions
5
test/chunking-form/samples/dynamic-import-comments/_expected/cjs/main.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
'use strict'; | ||
|
||
Promise.resolve(require( | ||
/* webpackChunkName: "chunk-name" */ | ||
'./foo.js'/*suffix*/)); |
3 changes: 3 additions & 0 deletions
3
test/chunking-form/samples/dynamic-import-comments/_expected/es/main.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
foobar( | ||
/* webpackChunkName: "chunk-name" */ | ||
'./foo.js'/*suffix*/); |
12 changes: 12 additions & 0 deletions
12
test/chunking-form/samples/dynamic-import-comments/_expected/system/main.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
System.register([], function (exports, module) { | ||
'use strict'; | ||
return { | ||
execute: function () { | ||
|
||
module.import( | ||
/* webpackChunkName: "chunk-name" */ | ||
'./foo.js'/*suffix*/); | ||
|
||
} | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import /* () should not break */ ( | ||
/* webpackChunkName: "chunk-name" */ | ||
'./foo.js'/*suffix*/); |