diff --git a/LICENSE.md b/LICENSE.md
index 726831dfdc9..4aafb4a8f28 100644
--- a/LICENSE.md
+++ b/LICENSE.md
@@ -727,7 +727,7 @@ Repository: micromatch/to-regex-range
## yargs-parser
License: ISC
By: Ben Coe
-Repository: git@github.com:yargs/yargs-parser.git
+Repository: https://github.com/yargs/yargs-parser.git
> Copyright (c) 2016, Contributors
>
diff --git a/docs/05-plugin-development.md b/docs/05-plugin-development.md
index 51544787d48..ead6c2d045d 100644
--- a/docs/05-plugin-development.md
+++ b/docs/05-plugin-development.md
@@ -150,7 +150,7 @@ In case a dynamic import is not passed a string as argument, this hook gets acce
Note that the return value of this hook will not be passed to `resolveId` afterwards; if you need access to the static resolution algorithm, you can use [`this.resolve(source, importer)`](guide/en/#thisresolvesource-string-importer-string-options-skipself-boolean--promiseid-string-external-boolean--null) on the plugin context.
#### `resolveId`
-Type: `(source: string, importer: string) => string | false | null | {id: string, external?: boolean, moduleSideEffects?: boolean | null, syntheticNamedExports?: boolean | null}`
+Type: `(source: string, importer: string | undefined) => string | false | null | {id: string, external?: boolean, moduleSideEffects?: boolean | null, syntheticNamedExports?: boolean | null}`
Kind: `async, first`
Previous Hook: [`buildStart`](guide/en/#buildstart) if we are resolving an entry point, [`transform`](guide/en/#transform) if we are resolving an import, or as fallback for [`resolveDynamicImport`](guide/en/#resolvedynamicimport). Additionally this hook can be triggered during the build phase from plugin hooks by calling [`this.emitFile`](guide/en/#thisemitfileemittedfile-emittedchunk--emittedasset--string) to emit an entry point or at any time by calling [`this.resolve`](guide/en/#thisresolvesource-string-importer-string-options-skipself-boolean--promiseid-string-external-boolean--null) to manually resolve an id.
Next Hook: [`load`](guide/en/#load) if the resolved id that has not yet been loaded, otherwise [`buildEnd`](guide/en/#buildend).
@@ -449,6 +449,7 @@ Emits a new file that is included in the build output and returns a `referenceId
{
type: 'chunk',
id: string,
+ importer?: string,
name?: string,
fileName?: string
}
@@ -468,7 +469,9 @@ You can reference the URL of an emitted file in any code returned by a [`load`](
The generated code that replaces `import.meta.ROLLUP_FILE_URL_referenceId` can be customized via the [`resolveFileUrl`](guide/en/#resolvefileurl) plugin hook. You can also use [`this.getFileName(referenceId)`](guide/en/#thisgetfilenamereferenceid-string--string) to determine the file name as soon as it is available
-If the `type` is *`chunk`*, then this emits a new chunk with the given module id as entry point. This will not result in duplicate modules in the graph, instead if necessary, existing chunks will be split or a facade chunk with reexports will be created. Chunks with a specified `fileName` will always generate separate chunks while other emitted chunks may be deduplicated with existing chunks even if the `name` does not match. If such a chunk is not deduplicated, the [`output.chunkFileNames`](guide/en/#outputchunkfilenames) name pattern will be used.
+If the `type` is *`chunk`*, then this emits a new chunk with the given module `id` as entry point. To resolve it, the `id` will be passed through build hooks just like regular entry points, starting with [`resolveId`](guide/en/#resolveid). If an `importer` is provided, this acts as the second parameter of `resolveId` and is important to properly resolve relative paths. If it is not provided, paths will be resolved relative to the current working directory.
+
+This will not result in duplicate modules in the graph, instead if necessary, existing chunks will be split or a facade chunk with reexports will be created. Chunks with a specified `fileName` will always generate separate chunks while other emitted chunks may be deduplicated with existing chunks even if the `name` does not match. If such a chunk is not deduplicated, the [`output.chunkFileNames`](guide/en/#outputchunkfilenames) name pattern will be used.
If the `type` is *`asset`*, then this emits an arbitrary new file with the given `source` as content. It is possible to defer setting the `source` via [`this.setAssetSource(assetReferenceId, source)`](guide/en/#thissetassetsourceassetreferenceid-string-source-string--uint8array--void) to a later time to be able to reference a file during the build phase while setting the source separately for each output during the generate phase. Assets with a specified `fileName` will always generate separate files while other emitted assets may be deduplicated with existing assets if they have the same source even if the `name` does not match. If such an asset is not deduplicated, the [`output.assetFileNames`](guide/en/#outputassetfilenames) name pattern will be used.
@@ -518,7 +521,7 @@ or converted into an Array via `Array.from(this.moduleIds)`.
Use Rollup's internal acorn instance to parse code to an AST.
-#### `this.resolve(source: string, importer: string, options?: {skipSelf: boolean}) => Promise<{id: string, external: boolean} | null>`
+#### `this.resolve(source: string, importer?: string, options?: {skipSelf: boolean}) => Promise<{id: string, external: boolean} | null>`
Resolve imports to module ids (i.e. file names) using the same plugins that Rollup uses, and determine if an import should be external. If `null` is returned, the import could not be resolved by Rollup or any plugin but was not explicitly marked as external by the user.
If you pass `skipSelf: true`, then the `resolveId` hook of the plugin from which `this.resolve` is called will be skipped when resolving.
@@ -563,9 +566,9 @@ The `position` argument is a character index where the warning was raised. If pr
- `this.getChunkFileName(chunkReferenceId: string) => string` - _**Use [`this.getFileName`](guide/en/#thisgetfilenamereferenceid-string--string)**_ - Get the file name of an emitted chunk. The file name will be relative to `outputOptions.dir`.
-- `this.isExternal(id: string, importer: string, isResolved: boolean) => boolean` - _**Use [`this.resolve`](guide/en/#thisresolvesource-string-importer-string-options-skipself-boolean--promiseid-string-external-boolean--null)**_ - Determine if a given module ID is external when imported by `importer`. When `isResolved` is false, Rollup will try to resolve the id before testing if it is external.
+- `this.isExternal(id: string, importer: string | undefined, isResolved: boolean) => boolean` - _**Use [`this.resolve`](guide/en/#thisresolvesource-string-importer-string-options-skipself-boolean--promiseid-string-external-boolean--null)**_ - Determine if a given module ID is external when imported by `importer`. When `isResolved` is false, Rollup will try to resolve the id before testing if it is external.
-- `this.resolveId(source: string, importer: string) => Promise` - _**Use [`this.resolve`](guide/en/#thisresolvesource-string-importer-string-options-skipself-boolean--promiseid-string-external-boolean--null)**_ - Resolve imports to module ids (i.e. file names) using the same plugins that Rollup uses. Returns `null` if an id cannot be resolved.
+- `this.resolveId(source: string, importer?: string) => Promise` - _**Use [`this.resolve`](guide/en/#thisresolvesource-string-importer-string-options-skipself-boolean--promiseid-string-external-boolean--null)**_ - Resolve imports to module ids (i.e. file names) using the same plugins that Rollup uses. Returns `null` if an id cannot be resolved.
### File URLs
diff --git a/package-lock.json b/package-lock.json
index 405683a6844..53d6797dd99 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -51,9 +51,9 @@
}
},
"@babel/generator": {
- "version": "7.8.7",
- "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.8.7.tgz",
- "integrity": "sha512-DQwjiKJqH4C3qGiyQCAExJHoZssn49JTMJgZ8SANGgVFdkupcUhLOdkAeoC6kmHZCPfoDG5M0b6cFlSN5wW7Ew==",
+ "version": "7.8.8",
+ "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.8.8.tgz",
+ "integrity": "sha512-HKyUVu69cZoclptr8t8U5b6sx6zoWjh8jiUhnuj3MpZuKT2dJ8zPTuiy31luq32swhI0SpwItCIlU8XW7BZeJg==",
"dev": true,
"requires": {
"@babel/types": "^7.8.7",
@@ -128,9 +128,9 @@
}
},
"@babel/parser": {
- "version": "7.8.7",
- "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.8.7.tgz",
- "integrity": "sha512-9JWls8WilDXFGxs0phaXAZgpxTZhSk/yOYH2hTHC0X1yC7Z78IJfvR1vJ+rmJKq3I35td2XzXzN6ZLYlna+r/A==",
+ "version": "7.8.8",
+ "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.8.8.tgz",
+ "integrity": "sha512-mO5GWzBPsPf6865iIbzNE0AvkKF3NE+2S3eRUpE+FE07BOAkXh6G+GW/Pj01hhXjve1WScbaIO4UlY1JKeqCcA==",
"dev": true
},
"@babel/runtime": {
@@ -422,9 +422,9 @@
"dev": true
},
"@types/node": {
- "version": "13.9.0",
- "resolved": "https://registry.npmjs.org/@types/node/-/node-13.9.0.tgz",
- "integrity": "sha512-0ARSQootUG1RljH2HncpsY2TJBfGQIKOOi7kxzUY6z54ePu/ZD+wJA8zI2Q6v8rol2qpG/rvqsReco8zNMPvhQ==",
+ "version": "13.9.1",
+ "resolved": "https://registry.npmjs.org/@types/node/-/node-13.9.1.tgz",
+ "integrity": "sha512-E6M6N0blf/jiZx8Q3nb0vNaswQeEyn0XlupO+xN6DtJ6r6IT4nXrTry7zhIfYvFCl3/8Cu6WIysmUBKiqV0bqQ==",
"dev": true
},
"@types/parse-json": {
@@ -698,9 +698,17 @@
"acorn-jsx": "^5.0.1",
"chalk": "^2.4.2",
"magic-string": "^0.25.3",
- "minimist": "^1.2.0",
+ "minimist": "^1.2.3",
"os-homedir": "^2.0.0",
"regexpu-core": "^4.5.4"
+ },
+ "dependencies": {
+ "acorn": {
+ "version": "6.4.1",
+ "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.4.1.tgz",
+ "integrity": "sha512-ZVA9k326Nwrj3Cj9jlh3wGFutC2ZornPNARZwsNYqQYgN0EsV2d53w5RN/co65Ohn4sUAUtb1rSUAOD6XN9idA==",
+ "dev": true
+ }
}
},
"buffer-from": {
@@ -1419,12 +1427,12 @@
"dev": true
},
"espree": {
- "version": "6.2.0",
- "resolved": "https://registry.npmjs.org/espree/-/espree-6.2.0.tgz",
- "integrity": "sha512-Xs8airJ7RQolnDIbLtRutmfvSsAe0xqMMAantCN/GMoqf81TFbeI1T7Jpd56qYu1uuh32dOG5W/X9uO+ghPXzA==",
+ "version": "6.2.1",
+ "resolved": "https://registry.npmjs.org/espree/-/espree-6.2.1.tgz",
+ "integrity": "sha512-ysCxRQY3WaXJz9tdbWOwuWr5Y/XrPTGX9Kiz3yoUXwW0VZ4w30HTkQLaGx/+ttFjF8i+ACbArnB4ce68a9m5hw==",
"dev": true,
"requires": {
- "acorn": "^7.1.0",
+ "acorn": "^7.1.1",
"acorn-jsx": "^5.2.0",
"eslint-visitor-keys": "^1.1.0"
}
@@ -1588,9 +1596,9 @@
}
},
"find-cache-dir": {
- "version": "3.3.0",
- "resolved": "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-3.3.0.tgz",
- "integrity": "sha512-PtXtQb7IrD8O+h6Cq1dbpJH5NzD8+9keN1zZ0YlpDzl1PwXEJEBj6u1Xa92t1Hwluoozd9TNKul5Hi2iqpsWwg==",
+ "version": "3.3.1",
+ "resolved": "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-3.3.1.tgz",
+ "integrity": "sha512-t2GDMt3oGC/v+BMwzmllWDuJF/xcDtE5j/fCGbqDD7OLuJkj0cfh1YSA5VKPvwMeLFLNDBkwOKZ2X85jGLVftQ==",
"dev": true,
"requires": {
"commondir": "^1.0.1",
@@ -1867,9 +1875,9 @@
}
},
"globals": {
- "version": "12.3.0",
- "resolved": "https://registry.npmjs.org/globals/-/globals-12.3.0.tgz",
- "integrity": "sha512-wAfjdLgFsPZsklLJvOBUBmzYE8/CwhEqSBEMRXA3qxIiNtyqvjYurAtIfDh6chlEPUfmTY3MnZh5Hfh4q0UlIw==",
+ "version": "12.4.0",
+ "resolved": "https://registry.npmjs.org/globals/-/globals-12.4.0.tgz",
+ "integrity": "sha512-BWICuzzDvDoH54NHKCseDanAhE3CeDorgDL5MT6LMXXj2WCnd9UC2szdk4AWLfjdgNBCXLUanXYcpBBKOSWGwg==",
"dev": true,
"requires": {
"type-fest": "^0.8.1"
@@ -2201,9 +2209,9 @@
"dev": true
},
"inquirer": {
- "version": "7.0.6",
- "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-7.0.6.tgz",
- "integrity": "sha512-7SVO4h+QIdMq6XcqIqrNte3gS5MzCCKZdsq9DO4PJziBFNYzP3PGFbDjgadDb//MCahzgjCxvQ/O2wa7kx9o4w==",
+ "version": "7.1.0",
+ "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-7.1.0.tgz",
+ "integrity": "sha512-5fJMWEmikSYu0nv/flMc475MhGbB7TSPd/2IpFV4I4rMklboCH2rQjYY5kKiYGHqUF9gvaambupcJFFG9dvReg==",
"dev": true,
"requires": {
"ansi-escapes": "^4.2.1",
@@ -2669,12 +2677,12 @@
"dev": true
},
"json5": {
- "version": "2.1.1",
- "resolved": "https://registry.npmjs.org/json5/-/json5-2.1.1.tgz",
- "integrity": "sha512-l+3HXD0GEI3huGq1njuqtzYK8OYJyXMkOLtQ53pjWh89tvWS2h6l+1zMkYWqlb57+SiQodKZyvMEFb2X+KrFhQ==",
+ "version": "2.1.2",
+ "resolved": "https://registry.npmjs.org/json5/-/json5-2.1.2.tgz",
+ "integrity": "sha512-MoUOQ4WdiN3yxhm7NEVJSJrieAo5hNSLQ5sj05OTRHPL9HOBy8u4Bu88jsC1jvqAdN+E1bJmsUcZH+1HQxliqQ==",
"dev": true,
"requires": {
- "minimist": "^1.2.0"
+ "minimist": "^1.2.5"
}
},
"jsonc-parser": {
@@ -3266,26 +3274,18 @@
}
},
"minimist": {
- "version": "1.2.0",
- "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
- "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=",
+ "version": "1.2.5",
+ "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz",
+ "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==",
"dev": true
},
"mkdirp": {
- "version": "0.5.1",
- "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
- "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
+ "version": "0.5.3",
+ "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.3.tgz",
+ "integrity": "sha512-P+2gwrFqx8lhew375MQHHeTlY8AuOJSrGf0R5ddkEndUkmwpgUob/vQuBD1V22/Cw1/lJr4x+EjllSezBThzBg==",
"dev": true,
"requires": {
- "minimist": "0.0.8"
- },
- "dependencies": {
- "minimist": {
- "version": "0.0.8",
- "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
- "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=",
- "dev": true
- }
+ "minimist": "^1.2.5"
}
},
"mocha": {
@@ -3378,6 +3378,15 @@
"path-exists": "^3.0.0"
}
},
+ "mkdirp": {
+ "version": "0.5.1",
+ "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
+ "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
+ "dev": true,
+ "requires": {
+ "minimist": "^1.2.3"
+ }
+ },
"ms": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz",
@@ -3722,9 +3731,9 @@
}
},
"yargs": {
- "version": "15.1.0",
- "resolved": "https://registry.npmjs.org/yargs/-/yargs-15.1.0.tgz",
- "integrity": "sha512-T39FNN1b6hCW4SOIk1XyTOWxtXdcen0t+XYrysQmChzSipvhBO8Bj0nK1ozAasdk24dNWuMZvr4k24nz+8HHLg==",
+ "version": "15.3.1",
+ "resolved": "https://registry.npmjs.org/yargs/-/yargs-15.3.1.tgz",
+ "integrity": "sha512-92O1HWEjw27sBfgmXiixJWT5hRBp2eobqXicLtPBIDBhYB+1HpwZlXmbW2luivBJHBzki+7VyCLRtAkScbTBQA==",
"dev": true,
"requires": {
"cliui": "^6.0.0",
@@ -3737,17 +3746,7 @@
"string-width": "^4.2.0",
"which-module": "^2.0.0",
"y18n": "^4.0.0",
- "yargs-parser": "^16.1.0"
- }
- },
- "yargs-parser": {
- "version": "16.1.0",
- "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-16.1.0.tgz",
- "integrity": "sha512-H/V41UNZQPkUMIT5h5hiwg4QKIY1RPvoBV4XcjUbRM8Bk2oKqqyZ0DIEbTFZB0XjbtSPG8SAa/0DxCQmiRgzKg==",
- "dev": true,
- "requires": {
- "camelcase": "^5.0.0",
- "decamelize": "^1.2.0"
+ "yargs-parser": "^18.1.1"
}
}
}
@@ -4125,18 +4124,18 @@
"dev": true
},
"regenerate-unicode-properties": {
- "version": "8.1.0",
- "resolved": "https://registry.npmjs.org/regenerate-unicode-properties/-/regenerate-unicode-properties-8.1.0.tgz",
- "integrity": "sha512-LGZzkgtLY79GeXLm8Dp0BVLdQlWICzBnJz/ipWUgo59qBaZ+BHtq51P2q1uVZlppMuUAT37SDk39qUbjTWB7bA==",
+ "version": "8.2.0",
+ "resolved": "https://registry.npmjs.org/regenerate-unicode-properties/-/regenerate-unicode-properties-8.2.0.tgz",
+ "integrity": "sha512-F9DjY1vKLo/tPePDycuH3dn9H1OTPIkVD9Kz4LODu+F2C75mgjAJ7x/gwy6ZcSNRAAkhNlJSOHRe8k3p+K9WhA==",
"dev": true,
"requires": {
"regenerate": "^1.4.0"
}
},
"regenerator-runtime": {
- "version": "0.13.4",
- "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.4.tgz",
- "integrity": "sha512-plpwicqEzfEyTQohIKktWigcLzmNStMGwbOUbykx51/29Z3JOGYldaaNGK7ngNXV+UcoqvIMmloZ48Sr74sd+g==",
+ "version": "0.13.5",
+ "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.5.tgz",
+ "integrity": "sha512-ZS5w8CpKFinUzOwW3c83oPeVXoNsrLsaCoLtJvAClH135j/R77RuymhiSErhm2lKcwSCIpmvIWSbDkIfAqKQlA==",
"dev": true
},
"regexpp": {
@@ -4146,17 +4145,17 @@
"dev": true
},
"regexpu-core": {
- "version": "4.6.0",
- "resolved": "https://registry.npmjs.org/regexpu-core/-/regexpu-core-4.6.0.tgz",
- "integrity": "sha512-YlVaefl8P5BnFYOITTNzDvan1ulLOiXJzCNZxduTIosN17b87h3bvG9yHMoHaRuo88H4mQ06Aodj5VtYGGGiTg==",
+ "version": "4.7.0",
+ "resolved": "https://registry.npmjs.org/regexpu-core/-/regexpu-core-4.7.0.tgz",
+ "integrity": "sha512-TQ4KXRnIn6tz6tjnrXEkD/sshygKH/j5KzK86X8MkeHyZ8qst/LZ89j3X4/8HEIfHANTFIP/AbXakeRhWIl5YQ==",
"dev": true,
"requires": {
"regenerate": "^1.4.0",
- "regenerate-unicode-properties": "^8.1.0",
- "regjsgen": "^0.5.0",
- "regjsparser": "^0.6.0",
+ "regenerate-unicode-properties": "^8.2.0",
+ "regjsgen": "^0.5.1",
+ "regjsparser": "^0.6.4",
"unicode-match-property-ecmascript": "^1.0.4",
- "unicode-match-property-value-ecmascript": "^1.1.0"
+ "unicode-match-property-value-ecmascript": "^1.2.0"
}
},
"regjsgen": {
@@ -4166,9 +4165,9 @@
"dev": true
},
"regjsparser": {
- "version": "0.6.3",
- "resolved": "https://registry.npmjs.org/regjsparser/-/regjsparser-0.6.3.tgz",
- "integrity": "sha512-8uZvYbnfAtEm9Ab8NTb3hdLwL4g/LQzEYP7Xs27T96abJCCE2d6r3cPZPQEsLKy0vRSGVNG+/zVGtLr86HQduA==",
+ "version": "0.6.4",
+ "resolved": "https://registry.npmjs.org/regjsparser/-/regjsparser-0.6.4.tgz",
+ "integrity": "sha512-64O87/dPDgfk8/RQqC4gkZoGyyWFIEUTTh80CU6CWuK5vkCGyekIx+oKcEIYtP/RAxSQltCZHCNu/mdd7fqlJw==",
"dev": true,
"requires": {
"jsesc": "~0.5.0"
@@ -4248,9 +4247,9 @@
}
},
"rollup": {
- "version": "2.0.0",
- "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.0.0.tgz",
- "integrity": "sha512-tbvWownITR+0ebaX6iRr7IcLkziTCJacRpmWz03NIj3CZDmGlergYSwdG8wPx68LT0ms1YzqmbjUQHb6ut8pdw==",
+ "version": "2.0.6",
+ "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.0.6.tgz",
+ "integrity": "sha512-P42IlI6a/bxh52ed8hEXXe44LcHfep2f26OZybMJPN1TTQftibvQEl3CWeOmJrzqGbFxOA000QXDWO9WJaOQpA==",
"dev": true,
"requires": {
"fsevents": "~2.1.2"
@@ -4280,6 +4279,15 @@
"requires": {
"sourcemap-codec": "^1.4.4"
}
+ },
+ "mkdirp": {
+ "version": "0.5.1",
+ "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
+ "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
+ "dev": true,
+ "requires": {
+ "minimist": "^1.2.3"
+ }
}
}
},
@@ -4293,9 +4301,9 @@
}
},
"rollup-plugin-terser": {
- "version": "5.2.0",
- "resolved": "https://registry.npmjs.org/rollup-plugin-terser/-/rollup-plugin-terser-5.2.0.tgz",
- "integrity": "sha512-jQI+nYhtDBc9HFRBz8iGttQg7li9klmzR62RG2W2nN6hJ/FI2K2ItYQ7kJ7/zn+vs+BP1AEccmVRjRN989I+Nw==",
+ "version": "5.3.0",
+ "resolved": "https://registry.npmjs.org/rollup-plugin-terser/-/rollup-plugin-terser-5.3.0.tgz",
+ "integrity": "sha512-XGMJihTIO3eIBsVGq7jiNYOdDMb3pVxuzY0uhOE/FM4x/u9nQgr3+McsjzqBn3QfHIpNSZmFnpoKAwHBEcsT7g==",
"dev": true,
"requires": {
"@babel/code-frame": "^7.5.5",
@@ -4436,7 +4444,7 @@
"dev": true,
"requires": {
"es6-object-assign": "^1.0.3",
- "minimist": "^1.2.0",
+ "minimist": "^1.2.3",
"shelljs": "^0.8.1"
}
},
@@ -4735,9 +4743,9 @@
"dev": true
},
"systemjs": {
- "version": "6.2.5",
- "resolved": "https://registry.npmjs.org/systemjs/-/systemjs-6.2.5.tgz",
- "integrity": "sha512-Jw1FOgzxG+wIi+ewEPyYKsqxR3IQOQWMwFh1o7C0VfLYoBcVDYSg8EFrKCisUD+5+/KecrDC+NSy4exkl7QRdw==",
+ "version": "6.2.6",
+ "resolved": "https://registry.npmjs.org/systemjs/-/systemjs-6.2.6.tgz",
+ "integrity": "sha512-cIGKuf8PwDPsiuC+op7tiyvQTWLDzzXYSx9aYmSrHiz6mVal6VT7uAS0gTEBs5WIWc03RqhvnNbNgodaauBsbg==",
"dev": true
},
"table": {
@@ -4791,9 +4799,9 @@
}
},
"terser": {
- "version": "4.6.6",
- "resolved": "https://registry.npmjs.org/terser/-/terser-4.6.6.tgz",
- "integrity": "sha512-4lYPyeNmstjIIESr/ysHg2vUPRGf2tzF9z2yYwnowXVuVzLEamPN1Gfrz7f8I9uEPuHcbFlW4PLIAsJoxXyJ1g==",
+ "version": "4.6.7",
+ "resolved": "https://registry.npmjs.org/terser/-/terser-4.6.7.tgz",
+ "integrity": "sha512-fmr7M1f7DBly5cX2+rFDvmGBAaaZyPrHYK4mMdHEDAdNTqXSZgSOfqsfGq2HqPGT/1V0foZZuCZFx8CHKgAk3g==",
"dev": true,
"requires": {
"commander": "^2.20.0",
@@ -4875,9 +4883,9 @@
"dev": true
},
"tslint": {
- "version": "6.0.0",
- "resolved": "https://registry.npmjs.org/tslint/-/tslint-6.0.0.tgz",
- "integrity": "sha512-9nLya8GBtlFmmFMW7oXXwoXS1NkrccqTqAtwXzdPV9e2mqSEvCki6iHL/Fbzi5oqbugshzgGPk7KBb2qNP1DSA==",
+ "version": "6.1.0",
+ "resolved": "https://registry.npmjs.org/tslint/-/tslint-6.1.0.tgz",
+ "integrity": "sha512-fXjYd/61vU6da04E505OZQGb2VCN2Mq3doeWcOIryuG+eqdmFUXTYVwdhnbEu2k46LNLgUYt9bI5icQze/j0bQ==",
"dev": true,
"requires": {
"@babel/code-frame": "^7.0.0",
@@ -4983,15 +4991,15 @@
}
},
"unicode-match-property-value-ecmascript": {
- "version": "1.1.0",
- "resolved": "https://registry.npmjs.org/unicode-match-property-value-ecmascript/-/unicode-match-property-value-ecmascript-1.1.0.tgz",
- "integrity": "sha512-hDTHvaBk3RmFzvSl0UVrUmC3PuW9wKVnpoUDYH0JDkSIovzw+J5viQmeYHxVSBptubnr7PbH2e0fnpDRQnQl5g==",
+ "version": "1.2.0",
+ "resolved": "https://registry.npmjs.org/unicode-match-property-value-ecmascript/-/unicode-match-property-value-ecmascript-1.2.0.tgz",
+ "integrity": "sha512-wjuQHGQVofmSJv1uVISKLE5zO2rNGzM/KCYZch/QQvez7C1hUhBIuZ701fYXExuufJFMPhv2SyL8CyoIfMLbIQ==",
"dev": true
},
"unicode-property-aliases-ecmascript": {
- "version": "1.0.5",
- "resolved": "https://registry.npmjs.org/unicode-property-aliases-ecmascript/-/unicode-property-aliases-ecmascript-1.0.5.tgz",
- "integrity": "sha512-L5RAqCfXqAwR3RriF8pM0lU0w4Ryf/GgzONwi6KnL1taJQa7x1TCxdJnILX59WIGOwR57IVxn7Nej0fz1Ny6fw==",
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/unicode-property-aliases-ecmascript/-/unicode-property-aliases-ecmascript-1.1.0.tgz",
+ "integrity": "sha512-PqSoPh/pWetQ2phoj5RLiaqIk4kCNwoV3CI+LfGmWLKI3rE3kl1h59XpX2BjgDrmbxD9ARtQobPGU1SguCYuQg==",
"dev": true
},
"universalify": {
@@ -5204,12 +5212,12 @@
"dev": true
},
"yaml": {
- "version": "1.7.2",
- "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.7.2.tgz",
- "integrity": "sha512-qXROVp90sb83XtAoqE8bP9RwAkTTZbugRUTm5YeFCBfNRPEp2YzTeqWiz7m5OORHzEvrA/qcGS8hp/E+MMROYw==",
+ "version": "1.8.2",
+ "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.8.2.tgz",
+ "integrity": "sha512-omakb0d7FjMo3R1D2EbTKVIk6dAVLRxFXdLZMEUToeAvuqgG/YuHMuQOZ5fgk+vQ8cx+cnGKwyg+8g8PNT0xQg==",
"dev": true,
"requires": {
- "@babel/runtime": "^7.6.3"
+ "@babel/runtime": "^7.8.7"
}
},
"yargs": {
@@ -5297,9 +5305,9 @@
}
},
"yargs-parser": {
- "version": "13.1.1",
- "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-13.1.1.tgz",
- "integrity": "sha512-oVAVsHz6uFrg3XQheFII8ESO2ssAf9luWuAd6Wexsu4F3OtIW0o8IribPXYrD4WC24LWtPrJlGy87y5udK+dxQ==",
+ "version": "13.1.2",
+ "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-13.1.2.tgz",
+ "integrity": "sha512-3lbsNRf/j+A4QuSZfDRA7HRSfWrzO0YjqTJd5kjAq37Zep1CEgaYmrH9Q3GwPiB9cHyd1Y1UwggGhJGoxipbzg==",
"dev": true,
"requires": {
"camelcase": "^5.0.0",
@@ -5309,9 +5317,9 @@
}
},
"yargs-parser": {
- "version": "16.1.0",
- "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-16.1.0.tgz",
- "integrity": "sha512-H/V41UNZQPkUMIT5h5hiwg4QKIY1RPvoBV4XcjUbRM8Bk2oKqqyZ0DIEbTFZB0XjbtSPG8SAa/0DxCQmiRgzKg==",
+ "version": "18.1.1",
+ "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-18.1.1.tgz",
+ "integrity": "sha512-KRHEsOM16IX7XuLnMOqImcPNbLVXMNHYAoFc3BKR8Ortl5gzDbtXvvEoGx9imk5E+X1VeNKNlcHr8B8vi+7ipA==",
"dev": true,
"requires": {
"camelcase": "^5.0.0",
diff --git a/package.json b/package.json
index 44e415d1394..b997ce591d5 100644
--- a/package.json
+++ b/package.json
@@ -70,7 +70,7 @@
"@rollup/plugin-node-resolve": "^7.1.1",
"@rollup/plugin-replace": "^2.3.1",
"@types/micromatch": "^4.0.1",
- "@types/node": "^13.9.0",
+ "@types/node": "^13.9.1",
"@types/yargs-parser": "^15.0.0",
"acorn": "^7.1.1",
"acorn-export-ns-from": "^0.1.0",
@@ -107,10 +107,10 @@
"pretty-ms": "^6.0.1",
"require-relative": "^0.8.7",
"requirejs": "^2.3.6",
- "rollup": "^2.0.0",
+ "rollup": "^2.0.6",
"rollup-plugin-license": "^0.13.0",
"rollup-plugin-string": "^3.0.0",
- "rollup-plugin-terser": "^5.2.0",
+ "rollup-plugin-terser": "^5.3.0",
"rollup-plugin-typescript": "^1.0.1",
"rollup-pluginutils": "^2.8.2",
"sander": "^0.6.0",
@@ -119,13 +119,13 @@
"source-map": "^0.7.3",
"source-map-support": "^0.5.16",
"sourcemap-codec": "^1.4.8",
- "systemjs": "^6.2.5",
- "terser": "^4.6.6",
+ "systemjs": "^6.2.6",
+ "terser": "^4.6.7",
"tslib": "^1.11.1",
- "tslint": "^6.0.0",
+ "tslint": "^6.1.0",
"typescript": "^3.8.3",
"url-parse": "^1.4.7",
- "yargs-parser": "^16.1.0"
+ "yargs-parser": "^18.1.1"
},
"files": [
"dist/**/*.js",
diff --git a/src/Graph.ts b/src/Graph.ts
index 1ebc7228b07..1458189e0d9 100644
--- a/src/Graph.ts
+++ b/src/Graph.ts
@@ -32,14 +32,15 @@ function normalizeEntryModules(
entryModules: string | string[] | Record
): UnresolvedModule[] {
if (typeof entryModules === 'string') {
- return [{ fileName: null, name: null, id: entryModules }];
+ return [{ fileName: null, name: null, id: entryModules, importer: undefined }];
}
if (Array.isArray(entryModules)) {
- return entryModules.map(id => ({ fileName: null, name: null, id }));
+ return entryModules.map(id => ({ fileName: null, name: null, id, importer: undefined }));
}
return Object.keys(entryModules).map(name => ({
fileName: null,
id: entryModules[name],
+ importer: undefined,
name
}));
}
diff --git a/src/ModuleLoader.ts b/src/ModuleLoader.ts
index 5af0388bea9..7740914fbc0 100644
--- a/src/ModuleLoader.ts
+++ b/src/ModuleLoader.ts
@@ -35,11 +35,16 @@ import transform from './utils/transform';
export interface UnresolvedModule {
fileName: string | null;
id: string;
+ importer: string | undefined;
name: string | null;
}
-function normalizeRelativeExternalId(importer: string, source: string) {
- return isRelative(source) ? resolve(importer, '..', source) : source;
+function normalizeRelativeExternalId(source: string, importer: string | undefined) {
+ return isRelative(source)
+ ? importer
+ ? resolve(importer, '..', source)
+ : resolve(source)
+ : source;
}
function getIdMatcher>(
@@ -133,8 +138,8 @@ export class ModuleLoader {
const firstEntryModuleIndex = this.nextEntryModuleIndex;
this.nextEntryModuleIndex += unresolvedEntryModules.length;
const loadNewEntryModulesPromise = Promise.all(
- unresolvedEntryModules.map(({ fileName, id, name }) =>
- this.loadEntryModule(id, true).then(module => {
+ unresolvedEntryModules.map(({ fileName, id, name, importer }) =>
+ this.loadEntryModule(id, true, importer).then(module => {
if (fileName !== null) {
module.chunkFileNames.add(fileName);
} else if (name !== null) {
@@ -183,7 +188,7 @@ export class ModuleLoader {
}
}
const loadNewManualChunkModulesPromise = Promise.all(
- unresolvedManualChunks.map(({ id }) => this.loadEntryModule(id, false))
+ unresolvedManualChunks.map(({ id }) => this.loadEntryModule(id, false, undefined))
).then(manualChunkModules => {
for (let index = 0; index < manualChunkModules.length; index++) {
this.addModuleToManualChunk(unresolvedManualChunks[index].alias, manualChunkModules[index]);
@@ -195,7 +200,7 @@ export class ModuleLoader {
async resolveId(
source: string,
- importer: string,
+ importer: string | undefined,
skip?: number | null
): Promise {
return this.normalizeResolveIdResult(
@@ -413,8 +418,12 @@ export class ModuleLoader {
return resolvedId;
}
- private loadEntryModule = (unresolvedId: string, isEntry: boolean): Promise =>
- this.pluginDriver.hookFirst('resolveId', [unresolvedId, undefined]).then(resolveIdResult => {
+ private loadEntryModule = (
+ unresolvedId: string,
+ isEntry: boolean,
+ importer: string | undefined
+ ): Promise =>
+ this.pluginDriver.hookFirst('resolveId', [unresolvedId, importer]).then(resolveIdResult => {
if (
resolveIdResult === false ||
(resolveIdResult && typeof resolveIdResult === 'object' && resolveIdResult.external)
@@ -434,7 +443,7 @@ export class ModuleLoader {
private normalizeResolveIdResult(
resolveIdResult: ResolveIdResult,
- importer: string,
+ importer: string | undefined,
source: string
): ResolvedId | null {
let id = '';
@@ -457,10 +466,10 @@ export class ModuleLoader {
if (this.isExternal(resolveIdResult, importer, true)) {
external = true;
}
- id = external ? normalizeRelativeExternalId(importer, resolveIdResult) : resolveIdResult;
+ id = external ? normalizeRelativeExternalId(resolveIdResult, importer) : resolveIdResult;
}
} else {
- id = normalizeRelativeExternalId(importer, source);
+ id = normalizeRelativeExternalId(source, importer);
if (resolveIdResult !== false && !this.isExternal(id, importer, true)) {
return null;
}
diff --git a/src/rollup/rollup.ts b/src/rollup/rollup.ts
index 17354ab465c..f60ddae3ed2 100644
--- a/src/rollup/rollup.ts
+++ b/src/rollup/rollup.ts
@@ -149,7 +149,6 @@ export async function rollupInternal(
timeStart('BUILD', 1);
let chunks: Chunk[];
-
try {
await graph.pluginDriver.hookParallel('buildStart', [inputOptions]);
chunks = await graph.build(
diff --git a/src/rollup/types.d.ts b/src/rollup/types.d.ts
index e88f5381d1e..30f5f38477f 100644
--- a/src/rollup/types.d.ts
+++ b/src/rollup/types.d.ts
@@ -134,6 +134,7 @@ export interface EmittedAsset {
export interface EmittedChunk {
fileName?: string;
id: string;
+ importer?: string;
name?: string;
type: 'chunk';
}
@@ -175,11 +176,11 @@ export interface PluginContext extends MinimalPluginContext {
parse: (input: string, options: any) => AcornNode;
resolve: (
source: string,
- importer: string,
+ importer?: string,
options?: { skipSelf: boolean }
) => Promise;
/** @deprecated Use `this.resolve` instead */
- resolveId: (source: string, importer: string) => Promise;
+ resolveId: (source: string, importer?: string) => Promise;
setAssetSource: (assetReferenceId: string, source: string | Uint8Array) => void;
warn: (warning: RollupWarning | string, pos?: number | { column: number; line: number }) => void;
}
@@ -216,7 +217,7 @@ export type ResolveIdHook = (
export type IsExternal = (
source: string,
- importer: string,
+ importer: string | undefined,
isResolved: boolean
) => boolean | null | undefined;
diff --git a/src/utils/FileEmitter.ts b/src/utils/FileEmitter.ts
index 39d0b972256..dab16502ddf 100644
--- a/src/utils/FileEmitter.ts
+++ b/src/utils/FileEmitter.ts
@@ -294,6 +294,7 @@ export class FileEmitter {
{
fileName: emittedChunk.fileName || null,
id: emittedChunk.id,
+ importer: emittedChunk.importer as string | undefined,
name: emittedChunk.name || null
}
],
diff --git a/src/utils/PluginContext.ts b/src/utils/PluginContext.ts
index a84795a3c76..3d832cb5652 100644
--- a/src/utils/PluginContext.ts
+++ b/src/utils/PluginContext.ts
@@ -140,7 +140,7 @@ export function getPluginContexts(
};
},
isExternal: getDeprecatedContextHandler(
- (id: string, parentId: string, isResolved = false) =>
+ (id: string, parentId: string | undefined, isResolved = false) =>
graph.moduleLoader.isExternal(id, parentId, isResolved),
'isExternal',
'resolve',
@@ -163,7 +163,7 @@ export function getPluginContexts(
);
},
resolveId: getDeprecatedContextHandler(
- (source: string, importer: string) =>
+ (source: string, importer: string | undefined) =>
graph.moduleLoader
.resolveId(source, importer)
.then(resolveId => resolveId && resolveId.id),
diff --git a/test/chunking-form/samples/emit-file/emit-chunk-with-importer/_config.js b/test/chunking-form/samples/emit-file/emit-chunk-with-importer/_config.js
new file mode 100644
index 00000000000..f8192ec4ea2
--- /dev/null
+++ b/test/chunking-form/samples/emit-file/emit-chunk-with-importer/_config.js
@@ -0,0 +1,35 @@
+const path = require('path');
+let noImporterReferenceId;
+let mainReferenceId;
+let nestedReferenceId;
+
+module.exports = {
+ description: 'allows specifying an importer when resolving ids',
+ options: {
+ input: 'main',
+ plugins: {
+ buildStart() {
+ noImporterReferenceId = this.emitFile({ type: 'chunk', id: './lib.js' });
+ mainReferenceId = this.emitFile({
+ type: 'chunk',
+ id: './lib.js',
+ importer: path.resolve(__dirname, 'main.js')
+ });
+ nestedReferenceId = this.emitFile({
+ type: 'chunk',
+ id: './lib.js',
+ importer: path.resolve(__dirname, 'nested/virtual.js')
+ });
+ },
+ transform(code, id) {
+ if (id.endsWith('main.js')) {
+ return (
+ `console.log('no importer', import.meta.ROLLUP_FILE_URL_${noImporterReferenceId});\n` +
+ `console.log('from maim', import.meta.ROLLUP_FILE_URL_${mainReferenceId});\n` +
+ `console.log('from nested', import.meta.ROLLUP_FILE_URL_${nestedReferenceId});\n`
+ );
+ }
+ }
+ }
+ }
+};
diff --git a/test/chunking-form/samples/emit-file/emit-chunk-with-importer/_expected/amd/generated-lib.js b/test/chunking-form/samples/emit-file/emit-chunk-with-importer/_expected/amd/generated-lib.js
new file mode 100644
index 00000000000..cee6de6e289
--- /dev/null
+++ b/test/chunking-form/samples/emit-file/emit-chunk-with-importer/_expected/amd/generated-lib.js
@@ -0,0 +1,5 @@
+define(function () { 'use strict';
+
+ console.log('main lib');
+
+});
diff --git a/test/chunking-form/samples/emit-file/emit-chunk-with-importer/_expected/amd/generated-lib2.js b/test/chunking-form/samples/emit-file/emit-chunk-with-importer/_expected/amd/generated-lib2.js
new file mode 100644
index 00000000000..f76826176c4
--- /dev/null
+++ b/test/chunking-form/samples/emit-file/emit-chunk-with-importer/_expected/amd/generated-lib2.js
@@ -0,0 +1,5 @@
+define(function () { 'use strict';
+
+ console.log('nested lib');
+
+});
diff --git a/test/chunking-form/samples/emit-file/emit-chunk-with-importer/_expected/amd/main.js b/test/chunking-form/samples/emit-file/emit-chunk-with-importer/_expected/amd/main.js
new file mode 100644
index 00000000000..805bcc46e71
--- /dev/null
+++ b/test/chunking-form/samples/emit-file/emit-chunk-with-importer/_expected/amd/main.js
@@ -0,0 +1,7 @@
+define(['require'], function (require) { 'use strict';
+
+ console.log('no importer', new URL(require.toUrl('./generated-lib.js'), document.baseURI).href);
+ console.log('from maim', new URL(require.toUrl('./generated-lib.js'), document.baseURI).href);
+ console.log('from nested', new URL(require.toUrl('./generated-lib2.js'), document.baseURI).href);
+
+});
diff --git a/test/chunking-form/samples/emit-file/emit-chunk-with-importer/_expected/cjs/generated-lib.js b/test/chunking-form/samples/emit-file/emit-chunk-with-importer/_expected/cjs/generated-lib.js
new file mode 100644
index 00000000000..5aab9a32157
--- /dev/null
+++ b/test/chunking-form/samples/emit-file/emit-chunk-with-importer/_expected/cjs/generated-lib.js
@@ -0,0 +1,3 @@
+'use strict';
+
+console.log('main lib');
diff --git a/test/chunking-form/samples/emit-file/emit-chunk-with-importer/_expected/cjs/generated-lib2.js b/test/chunking-form/samples/emit-file/emit-chunk-with-importer/_expected/cjs/generated-lib2.js
new file mode 100644
index 00000000000..3bad4466642
--- /dev/null
+++ b/test/chunking-form/samples/emit-file/emit-chunk-with-importer/_expected/cjs/generated-lib2.js
@@ -0,0 +1,3 @@
+'use strict';
+
+console.log('nested lib');
diff --git a/test/chunking-form/samples/emit-file/emit-chunk-with-importer/_expected/cjs/main.js b/test/chunking-form/samples/emit-file/emit-chunk-with-importer/_expected/cjs/main.js
new file mode 100644
index 00000000000..6ea003e0663
--- /dev/null
+++ b/test/chunking-form/samples/emit-file/emit-chunk-with-importer/_expected/cjs/main.js
@@ -0,0 +1,5 @@
+'use strict';
+
+console.log('no importer', (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __dirname + '/generated-lib.js').href : new URL('generated-lib.js', document.currentScript && document.currentScript.src || document.baseURI).href));
+console.log('from maim', (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __dirname + '/generated-lib.js').href : new URL('generated-lib.js', document.currentScript && document.currentScript.src || document.baseURI).href));
+console.log('from nested', (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __dirname + '/generated-lib2.js').href : new URL('generated-lib2.js', document.currentScript && document.currentScript.src || document.baseURI).href));
diff --git a/test/chunking-form/samples/emit-file/emit-chunk-with-importer/_expected/es/generated-lib.js b/test/chunking-form/samples/emit-file/emit-chunk-with-importer/_expected/es/generated-lib.js
new file mode 100644
index 00000000000..29000e65aa3
--- /dev/null
+++ b/test/chunking-form/samples/emit-file/emit-chunk-with-importer/_expected/es/generated-lib.js
@@ -0,0 +1 @@
+console.log('main lib');
diff --git a/test/chunking-form/samples/emit-file/emit-chunk-with-importer/_expected/es/generated-lib2.js b/test/chunking-form/samples/emit-file/emit-chunk-with-importer/_expected/es/generated-lib2.js
new file mode 100644
index 00000000000..fb916c16842
--- /dev/null
+++ b/test/chunking-form/samples/emit-file/emit-chunk-with-importer/_expected/es/generated-lib2.js
@@ -0,0 +1 @@
+console.log('nested lib');
diff --git a/test/chunking-form/samples/emit-file/emit-chunk-with-importer/_expected/es/main.js b/test/chunking-form/samples/emit-file/emit-chunk-with-importer/_expected/es/main.js
new file mode 100644
index 00000000000..a2c6d8019cc
--- /dev/null
+++ b/test/chunking-form/samples/emit-file/emit-chunk-with-importer/_expected/es/main.js
@@ -0,0 +1,3 @@
+console.log('no importer', new URL('generated-lib.js', import.meta.url).href);
+console.log('from maim', new URL('generated-lib.js', import.meta.url).href);
+console.log('from nested', new URL('generated-lib2.js', import.meta.url).href);
diff --git a/test/chunking-form/samples/emit-file/emit-chunk-with-importer/_expected/system/generated-lib.js b/test/chunking-form/samples/emit-file/emit-chunk-with-importer/_expected/system/generated-lib.js
new file mode 100644
index 00000000000..507bca5d3ac
--- /dev/null
+++ b/test/chunking-form/samples/emit-file/emit-chunk-with-importer/_expected/system/generated-lib.js
@@ -0,0 +1,10 @@
+System.register([], function () {
+ 'use strict';
+ return {
+ execute: function () {
+
+ console.log('main lib');
+
+ }
+ };
+});
diff --git a/test/chunking-form/samples/emit-file/emit-chunk-with-importer/_expected/system/generated-lib2.js b/test/chunking-form/samples/emit-file/emit-chunk-with-importer/_expected/system/generated-lib2.js
new file mode 100644
index 00000000000..7926ecf0ea3
--- /dev/null
+++ b/test/chunking-form/samples/emit-file/emit-chunk-with-importer/_expected/system/generated-lib2.js
@@ -0,0 +1,10 @@
+System.register([], function () {
+ 'use strict';
+ return {
+ execute: function () {
+
+ console.log('nested lib');
+
+ }
+ };
+});
diff --git a/test/chunking-form/samples/emit-file/emit-chunk-with-importer/_expected/system/main.js b/test/chunking-form/samples/emit-file/emit-chunk-with-importer/_expected/system/main.js
new file mode 100644
index 00000000000..370c482dbbb
--- /dev/null
+++ b/test/chunking-form/samples/emit-file/emit-chunk-with-importer/_expected/system/main.js
@@ -0,0 +1,12 @@
+System.register([], function (exports, module) {
+ 'use strict';
+ return {
+ execute: function () {
+
+ console.log('no importer', new URL('generated-lib.js', module.meta.url).href);
+ console.log('from maim', new URL('generated-lib.js', module.meta.url).href);
+ console.log('from nested', new URL('generated-lib2.js', module.meta.url).href);
+
+ }
+ };
+});
diff --git a/test/chunking-form/samples/emit-file/emit-chunk-with-importer/lib.js b/test/chunking-form/samples/emit-file/emit-chunk-with-importer/lib.js
new file mode 100644
index 00000000000..29000e65aa3
--- /dev/null
+++ b/test/chunking-form/samples/emit-file/emit-chunk-with-importer/lib.js
@@ -0,0 +1 @@
+console.log('main lib');
diff --git a/test/chunking-form/samples/emit-file/emit-chunk-with-importer/main.js b/test/chunking-form/samples/emit-file/emit-chunk-with-importer/main.js
new file mode 100644
index 00000000000..61502ce3163
--- /dev/null
+++ b/test/chunking-form/samples/emit-file/emit-chunk-with-importer/main.js
@@ -0,0 +1 @@
+console.log('ignored');
diff --git a/test/chunking-form/samples/emit-file/emit-chunk-with-importer/nested/lib.js b/test/chunking-form/samples/emit-file/emit-chunk-with-importer/nested/lib.js
new file mode 100644
index 00000000000..fb916c16842
--- /dev/null
+++ b/test/chunking-form/samples/emit-file/emit-chunk-with-importer/nested/lib.js
@@ -0,0 +1 @@
+console.log('nested lib');
diff --git a/test/function/samples/resolve-relative-external-id/_config.js b/test/function/samples/resolve-relative-external-id/_config.js
new file mode 100644
index 00000000000..6b0022a9f08
--- /dev/null
+++ b/test/function/samples/resolve-relative-external-id/_config.js
@@ -0,0 +1,31 @@
+const assert = require('assert');
+const path = require('path');
+
+module.exports = {
+ description: 'resolves relative external ids',
+ options: {
+ external: [
+ path.resolve(__dirname, 'external.js'),
+ path.resolve(__dirname, 'nested', 'external.js')
+ ],
+ plugins: {
+ async buildStart() {
+ assert.deepStrictEqual(await this.resolve('./external.js'), {
+ external: true,
+ id: path.resolve(__dirname, 'external.js'),
+ moduleSideEffects: true,
+ syntheticNamedExports: false
+ });
+ assert.deepStrictEqual(
+ await this.resolve('./external.js', path.resolve(__dirname, 'nested', 'some-file.js')),
+ {
+ external: true,
+ id: path.resolve(__dirname, 'nested', 'external.js'),
+ moduleSideEffects: true,
+ syntheticNamedExports: false
+ }
+ );
+ }
+ }
+ }
+};
diff --git a/test/function/samples/resolve-relative-external-id/main.js b/test/function/samples/resolve-relative-external-id/main.js
new file mode 100644
index 00000000000..7a4e8a723a4
--- /dev/null
+++ b/test/function/samples/resolve-relative-external-id/main.js
@@ -0,0 +1 @@
+export default 42;