-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ec04aa2
commit 9a334b0
Showing
19 changed files
with
119 additions
and
0 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
37 changes: 37 additions & 0 deletions
37
test/chunking-form/samples/inline-dynamic-import/inline-in-various-hooks/_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,37 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
module.exports = { | ||
solo: true, | ||
description: 'inlines dynamic imports marked for inlining', | ||
options: { | ||
input: 'main.js', | ||
plugins: { | ||
resolveId(id, importer) { | ||
if (id.endsWith('dep-inlined-via-resolveId.js')) { | ||
return this.resolve(id, importer, { skipSelf: true }).then(resolution => | ||
Object.assign({}, resolution, { inlineDynamicImport: true }) | ||
); | ||
} | ||
}, | ||
load(id) { | ||
if (id.endsWith('dep-inlined-via-load.js')) { | ||
return { | ||
code: fs.readFileSync(path.resolve(__dirname, 'dep-inlined-via-load.js'), { | ||
encoding: 'utf8' | ||
}), | ||
inlineDynamicImport: true | ||
}; | ||
} | ||
}, | ||
transform(code, id) { | ||
if (id.endsWith('dep-inlined-via-transform.js')) { | ||
return { | ||
code, | ||
inlineDynamicImport: true | ||
}; | ||
} | ||
} | ||
} | ||
} | ||
}; |
5 changes: 5 additions & 0 deletions
5
...ples/inline-dynamic-import/inline-in-various-hooks/_expected/amd/generated-dep-inlined.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 @@ | ||
define(function () { 'use strict'; | ||
|
||
console.log('inlined'); | ||
|
||
}); |
5 changes: 5 additions & 0 deletions
5
.../inline-dynamic-import/inline-in-various-hooks/_expected/amd/generated-dep-not-inlined.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 @@ | ||
define(function () { 'use strict'; | ||
|
||
console.log('not inlined'); | ||
|
||
}); |
6 changes: 6 additions & 0 deletions
6
...chunking-form/samples/inline-dynamic-import/inline-in-various-hooks/_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,6 @@ | ||
define(['require'], function (require) { 'use strict'; | ||
|
||
new Promise(function (resolve, reject) { require(['./generated-dep-inlined'], resolve, reject) }); | ||
new Promise(function (resolve, reject) { require(['./generated-dep-not-inlined'], resolve, reject) }); | ||
|
||
}); |
3 changes: 3 additions & 0 deletions
3
...ples/inline-dynamic-import/inline-in-various-hooks/_expected/cjs/generated-dep-inlined.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 @@ | ||
'use strict'; | ||
|
||
console.log('inlined'); |
3 changes: 3 additions & 0 deletions
3
.../inline-dynamic-import/inline-in-various-hooks/_expected/cjs/generated-dep-not-inlined.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 @@ | ||
'use strict'; | ||
|
||
console.log('not inlined'); |
4 changes: 4 additions & 0 deletions
4
...chunking-form/samples/inline-dynamic-import/inline-in-various-hooks/_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,4 @@ | ||
'use strict'; | ||
|
||
new Promise(function (resolve) { resolve(require('./generated-dep-inlined.js')); }); | ||
new Promise(function (resolve) { resolve(require('./generated-dep-not-inlined.js')); }); |
2 changes: 2 additions & 0 deletions
2
...mples/inline-dynamic-import/inline-in-various-hooks/_expected/es/generated-dep-inlined.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,2 @@ | ||
console.log('inlined'); | ||
export const value = 'inlined'; |
2 changes: 2 additions & 0 deletions
2
...s/inline-dynamic-import/inline-in-various-hooks/_expected/es/generated-dep-not-inlined.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,2 @@ | ||
console.log('not inlined'); | ||
export const value = 'not inlined'; |
4 changes: 4 additions & 0 deletions
4
.../chunking-form/samples/inline-dynamic-import/inline-in-various-hooks/_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,4 @@ | ||
import('./generated-dep-inlined.js').then(ns => console.log(ns)); | ||
import('./generated-dep-not-inlined.js').then(ns => console.log(ns)); | ||
|
||
console.log('main'); |
10 changes: 10 additions & 0 deletions
10
...s/inline-dynamic-import/inline-in-various-hooks/_expected/system/generated-dep-inlined.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,10 @@ | ||
System.register([], function () { | ||
'use strict'; | ||
return { | ||
execute: function () { | ||
|
||
console.log('inlined'); | ||
|
||
} | ||
}; | ||
}); |
10 changes: 10 additions & 0 deletions
10
...line-dynamic-import/inline-in-various-hooks/_expected/system/generated-dep-not-inlined.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,10 @@ | ||
System.register([], function () { | ||
'use strict'; | ||
return { | ||
execute: function () { | ||
|
||
console.log('not inlined'); | ||
|
||
} | ||
}; | ||
}); |
11 changes: 11 additions & 0 deletions
11
...nking-form/samples/inline-dynamic-import/inline-in-various-hooks/_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,11 @@ | ||
System.register([], function (exports, module) { | ||
'use strict'; | ||
return { | ||
execute: function () { | ||
|
||
module.import('./generated-dep-inlined.js'); | ||
module.import('./generated-dep-not-inlined.js'); | ||
|
||
} | ||
}; | ||
}); |
2 changes: 2 additions & 0 deletions
2
...unking-form/samples/inline-dynamic-import/inline-in-various-hooks/dep-inlined-via-load.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,2 @@ | ||
console.log('load'); | ||
export const value = 'load'; |
2 changes: 2 additions & 0 deletions
2
...g-form/samples/inline-dynamic-import/inline-in-various-hooks/dep-inlined-via-resolveId.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,2 @@ | ||
console.log('resolveId'); | ||
export const value = 'resolveId'; |
2 changes: 2 additions & 0 deletions
2
...g-form/samples/inline-dynamic-import/inline-in-various-hooks/dep-inlined-via-transform.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,2 @@ | ||
console.log('transform'); | ||
export const value = 'transform'; |
2 changes: 2 additions & 0 deletions
2
test/chunking-form/samples/inline-dynamic-import/inline-in-various-hooks/dep-not-inlined.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,2 @@ | ||
console.log('not inlined'); | ||
export const value = 'not inlined'; |
6 changes: 6 additions & 0 deletions
6
test/chunking-form/samples/inline-dynamic-import/inline-in-various-hooks/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,6 @@ | ||
import('./dep-inlined-via-resolveId.js').then(console.log); | ||
import('./dep-inlined-via-load.js').then(console.log); | ||
import('./dep-inlined-via-transform.js').then(console.log); | ||
import('./dep-not-inlined.js').then(console.log); | ||
|
||
console.log('main'); |