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
d7a81f0
commit c1cb94a
Showing
19 changed files
with
113 additions
and
17 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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
const assert = require('assert'); | ||
const path = require('path'); | ||
|
||
const ID_MAIN = path.join(__dirname, 'main.js'); | ||
|
||
module.exports = { | ||
description: 'sends correct isEntry information to resolveId hooks', | ||
options: { | ||
plugins: [ | ||
{ | ||
async buildStart() { | ||
return Promise.all([ | ||
this.emitFile({ type: 'chunk', id: 'chunkWithoutImporter.js' }), | ||
this.emitFile({ type: 'chunk', id: './chunkWithImporter.js', importer: ID_MAIN }), | ||
this.resolve('./resolutionWithoutImporter'), | ||
this.resolve('./resolutionWithoutImporterEntry', undefined, { isEntry: true }), | ||
this.resolve('./resolutionWithoutImporterNonEntry', undefined, { isEntry: false }), | ||
this.resolve('./resolutionWithImporter', ID_MAIN), | ||
this.resolve('./resolutionWithImporterEntry', ID_MAIN, { isEntry: true }), | ||
this.resolve('./resolutionWithImporterNonEntry', ID_MAIN, { isEntry: false }) | ||
]); | ||
}, | ||
resolveId(source, importer, { isEntry }) { | ||
switch (source) { | ||
case ID_MAIN: | ||
assert.strictEqual(importer, undefined, source); | ||
assert.strictEqual(isEntry, true, source); | ||
break; | ||
case './dep.js': | ||
assert.strictEqual(importer, ID_MAIN, source); | ||
assert.strictEqual(isEntry, false, source); | ||
break; | ||
case 'chunkWithoutImporter.js': | ||
assert.strictEqual(importer, undefined, source); | ||
assert.strictEqual(isEntry, true, source); | ||
break; | ||
case './chunkWithImporter.js': | ||
assert.strictEqual(importer, ID_MAIN, source); | ||
assert.strictEqual(isEntry, true, source); | ||
break; | ||
case './resolutionWithoutImporter': | ||
assert.strictEqual(importer, undefined, source); | ||
assert.strictEqual(isEntry, true, source); | ||
break; | ||
case './resolutionWithoutImporterEntry': | ||
assert.strictEqual(importer, undefined, source); | ||
assert.strictEqual(isEntry, true, source); | ||
break; | ||
case './resolutionWithoutImporterNonEntry': | ||
assert.strictEqual(importer, undefined, source); | ||
assert.strictEqual(isEntry, false, source); | ||
break; | ||
case './resolutionWithImporter': | ||
assert.strictEqual(importer, ID_MAIN, source); | ||
assert.strictEqual(isEntry, false, source); | ||
break; | ||
case './resolutionWithImporterEntry': | ||
assert.strictEqual(importer, ID_MAIN, source); | ||
assert.strictEqual(isEntry, true, source); | ||
break; | ||
case './resolutionWithImporterNonEntry': | ||
assert.strictEqual(importer, ID_MAIN, source); | ||
assert.strictEqual(isEntry, false, source); | ||
break; | ||
default: | ||
throw new Error(`Unexpected resolution of ${source}`); | ||
} | ||
} | ||
} | ||
] | ||
} | ||
}; |
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 @@ | ||
console.log('with'); |
1 change: 1 addition & 0 deletions
1
test/function/samples/resolveid-is-entry/chunkWithoutImporter.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 @@ | ||
console.log('without'); |
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 @@ | ||
export default 42; |
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 value from './dep.js'; | ||
|
||
assert.strictEqual(value, 42); |
1 change: 1 addition & 0 deletions
1
test/function/samples/resolveid-is-entry/resolutionWithImporter.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 @@ | ||
console.log('with'); |
1 change: 1 addition & 0 deletions
1
test/function/samples/resolveid-is-entry/resolutionWithImporterEntry.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 @@ | ||
console.log('with entry'); |
1 change: 1 addition & 0 deletions
1
test/function/samples/resolveid-is-entry/resolutionWithImporterNonEntry.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 @@ | ||
console.log('with non entry'); |
1 change: 1 addition & 0 deletions
1
test/function/samples/resolveid-is-entry/resolutionWithoutImporter.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 @@ | ||
console.log('without'); |
1 change: 1 addition & 0 deletions
1
test/function/samples/resolveid-is-entry/resolutionWithoutImporterEntry.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 @@ | ||
console.log('without entry'); |
1 change: 1 addition & 0 deletions
1
test/function/samples/resolveid-is-entry/resolutionWithoutImporterNonEntry.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 @@ | ||
console.log('without non entry'); |