-
-
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 ce73ae8
Showing
16 changed files
with
218 additions
and
1 deletion.
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
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
36 changes: 36 additions & 0 deletions
36
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,36 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
module.exports = { | ||
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 | ||
}; | ||
} | ||
} | ||
} | ||
} | ||
}; |
8 changes: 8 additions & 0 deletions
8
.../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,8 @@ | ||
define(['exports'], function (exports) { 'use strict'; | ||
|
||
console.log('not inlined'); | ||
const value = 'not inlined'; | ||
|
||
exports.value = value; | ||
|
||
}); |
34 changes: 34 additions & 0 deletions
34
...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,34 @@ | ||
define(['require'], function (require) { 'use strict'; | ||
|
||
Promise.resolve().then(function () { return depInlinedViaResolveId; }).then(console.log); | ||
Promise.resolve().then(function () { return depInlinedViaLoad; }).then(console.log); | ||
Promise.resolve().then(function () { return depInlinedViaTransform; }).then(console.log); | ||
new Promise(function (resolve, reject) { require(['./generated-dep-not-inlined'], resolve, reject) }).then(console.log); | ||
|
||
console.log('main'); | ||
|
||
console.log('resolveId'); | ||
const value = 'resolveId'; | ||
|
||
var depInlinedViaResolveId = /*#__PURE__*/Object.freeze({ | ||
__proto__: null, | ||
value: value | ||
}); | ||
|
||
console.log('load'); | ||
const value$1 = 'load'; | ||
|
||
var depInlinedViaLoad = /*#__PURE__*/Object.freeze({ | ||
__proto__: null, | ||
value: value$1 | ||
}); | ||
|
||
console.log('transform'); | ||
const value$2 = 'transform'; | ||
|
||
var depInlinedViaTransform = /*#__PURE__*/Object.freeze({ | ||
__proto__: null, | ||
value: value$2 | ||
}); | ||
|
||
}); |
6 changes: 6 additions & 0 deletions
6
.../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,6 @@ | ||
'use strict'; | ||
|
||
console.log('not inlined'); | ||
const value = 'not inlined'; | ||
|
||
exports.value = value; |
32 changes: 32 additions & 0 deletions
32
...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,32 @@ | ||
'use strict'; | ||
|
||
Promise.resolve().then(function () { return depInlinedViaResolveId; }).then(console.log); | ||
Promise.resolve().then(function () { return depInlinedViaLoad; }).then(console.log); | ||
Promise.resolve().then(function () { return depInlinedViaTransform; }).then(console.log); | ||
new Promise(function (resolve) { resolve(require('./generated-dep-not-inlined.js')); }).then(console.log); | ||
|
||
console.log('main'); | ||
|
||
console.log('resolveId'); | ||
const value = 'resolveId'; | ||
|
||
var depInlinedViaResolveId = /*#__PURE__*/Object.freeze({ | ||
__proto__: null, | ||
value: value | ||
}); | ||
|
||
console.log('load'); | ||
const value$1 = 'load'; | ||
|
||
var depInlinedViaLoad = /*#__PURE__*/Object.freeze({ | ||
__proto__: null, | ||
value: value$1 | ||
}); | ||
|
||
console.log('transform'); | ||
const value$2 = 'transform'; | ||
|
||
var depInlinedViaTransform = /*#__PURE__*/Object.freeze({ | ||
__proto__: null, | ||
value: value$2 | ||
}); |
4 changes: 4 additions & 0 deletions
4
...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,4 @@ | ||
console.log('not inlined'); | ||
const value = 'not inlined'; | ||
|
||
export { value }; |
30 changes: 30 additions & 0 deletions
30
.../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,30 @@ | ||
Promise.resolve().then(function () { return depInlinedViaResolveId; }).then(console.log); | ||
Promise.resolve().then(function () { return depInlinedViaLoad; }).then(console.log); | ||
Promise.resolve().then(function () { return depInlinedViaTransform; }).then(console.log); | ||
import('./generated-dep-not-inlined.js').then(console.log); | ||
|
||
console.log('main'); | ||
|
||
console.log('resolveId'); | ||
const value = 'resolveId'; | ||
|
||
var depInlinedViaResolveId = /*#__PURE__*/Object.freeze({ | ||
__proto__: null, | ||
value: value | ||
}); | ||
|
||
console.log('load'); | ||
const value$1 = 'load'; | ||
|
||
var depInlinedViaLoad = /*#__PURE__*/Object.freeze({ | ||
__proto__: null, | ||
value: value$1 | ||
}); | ||
|
||
console.log('transform'); | ||
const value$2 = 'transform'; | ||
|
||
var depInlinedViaTransform = /*#__PURE__*/Object.freeze({ | ||
__proto__: null, | ||
value: value$2 | ||
}); |
11 changes: 11 additions & 0 deletions
11
...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,11 @@ | ||
System.register([], function (exports) { | ||
'use strict'; | ||
return { | ||
execute: function () { | ||
|
||
console.log('not inlined'); | ||
const value = exports('value', 'not inlined'); | ||
|
||
} | ||
}; | ||
}); |
39 changes: 39 additions & 0 deletions
39
...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,39 @@ | ||
System.register([], function (exports, module) { | ||
'use strict'; | ||
return { | ||
execute: function () { | ||
|
||
Promise.resolve().then(function () { return depInlinedViaResolveId; }).then(console.log); | ||
Promise.resolve().then(function () { return depInlinedViaLoad; }).then(console.log); | ||
Promise.resolve().then(function () { return depInlinedViaTransform; }).then(console.log); | ||
module.import('./generated-dep-not-inlined.js').then(console.log); | ||
|
||
console.log('main'); | ||
|
||
console.log('resolveId'); | ||
const value = 'resolveId'; | ||
|
||
var depInlinedViaResolveId = /*#__PURE__*/Object.freeze({ | ||
__proto__: null, | ||
value: value | ||
}); | ||
|
||
console.log('load'); | ||
const value$1 = 'load'; | ||
|
||
var depInlinedViaLoad = /*#__PURE__*/Object.freeze({ | ||
__proto__: null, | ||
value: value$1 | ||
}); | ||
|
||
console.log('transform'); | ||
const value$2 = 'transform'; | ||
|
||
var depInlinedViaTransform = /*#__PURE__*/Object.freeze({ | ||
__proto__: null, | ||
value: value$2 | ||
}); | ||
|
||
} | ||
}; | ||
}); |
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'); |