diff --git a/src/Chunk.ts b/src/Chunk.ts index c4e8d6b512c..70464bb5ba8 100644 --- a/src/Chunk.ts +++ b/src/Chunk.ts @@ -1246,7 +1246,11 @@ export default class Chunk { } } - private setIdentifierRenderResolutions({ format, interop, namespaceToStringTag }: NormalizedOutputOptions) { + private setIdentifierRenderResolutions({ + format, + interop, + namespaceToStringTag + }: NormalizedOutputOptions) { const syntheticExports = new Set(); for (const exportName of this.getExportNames()) { const exportVariable = this.exportsByName[exportName]; diff --git a/src/ExternalModule.ts b/src/ExternalModule.ts index f5ffba4bbb2..0b81685625a 100644 --- a/src/ExternalModule.ts +++ b/src/ExternalModule.ts @@ -7,7 +7,7 @@ import { } from './rollup/types'; import { EMPTY_ARRAY } from './utils/blank'; import { makeLegal } from './utils/identifierHelpers'; -import { isAbsolute, normalize, relative } from './utils/path'; +import { normalize, relative } from './utils/path'; export default class ExternalModule { chunk: void; @@ -23,7 +23,6 @@ export default class ExternalModule { nameSuggestions: { [name: string]: number }; reexported = false; renderPath: string = undefined as any; - renormalizeRenderPath = false; suggestedVariableName: string; used = false; variableName = ''; @@ -32,7 +31,8 @@ export default class ExternalModule { private readonly options: NormalizedInputOptions, public readonly id: string, hasModuleSideEffects: boolean | 'no-treeshake', - meta: CustomPluginOptions + meta: CustomPluginOptions, + public renormalizeRenderPath: boolean ) { this.execIndex = Infinity; this.suggestedVariableName = makeLegal(id.split(/[\\/]/).pop()!); @@ -76,12 +76,9 @@ export default class ExternalModule { this.renderPath = typeof options.paths === 'function' ? options.paths(this.id) : options.paths[this.id]; if (!this.renderPath) { - if (!isAbsolute(this.id)) { - this.renderPath = this.id; - } else { - this.renderPath = normalize(relative(inputBase, this.id)); - this.renormalizeRenderPath = true; - } + this.renderPath = this.renormalizeRenderPath + ? normalize(relative(inputBase, this.id)) + : this.id; } return this.renderPath; } diff --git a/src/ModuleLoader.ts b/src/ModuleLoader.ts index b8be285588d..ed6148899a9 100644 --- a/src/ModuleLoader.ts +++ b/src/ModuleLoader.ts @@ -6,8 +6,9 @@ import { CustomPluginOptions, EmittedChunk, HasModuleSideEffects, + ModuleOptions, NormalizedInputOptions, - PartialResolvedId, + PartialNull, Plugin, ResolvedId, ResolveIdResult, @@ -27,7 +28,7 @@ import { errUnresolvedImportTreatedAsExternal } from './utils/error'; import { readFile } from './utils/fs'; -import { isRelative, resolve } from './utils/path'; +import { isAbsolute, isRelative, resolve } from './utils/path'; import { PluginDriver } from './utils/PluginDriver'; import relativeId from './utils/relativeId'; import { resolveId } from './utils/resolveId'; @@ -41,6 +42,11 @@ export interface UnresolvedModule { name: string | null; } +type NormalizedResolveIdWithoutDefaults = Partial> & { + external?: boolean | 'absolute'; + id: string; +}; + export class ModuleLoader { private readonly hasModuleSideEffects: HasModuleSideEffects; private readonly implicitEntryModules = new Set(); @@ -160,9 +166,11 @@ export class ModuleLoader { source ) ); - } + }; - private addDefaultsToResolvedId(resolvedId: PartialResolvedId | null): ResolvedId | null { + private addDefaultsToResolvedId( + resolvedId: NormalizedResolveIdWithoutDefaults | null + ): ResolvedId | null { if (!resolvedId) { return null; } @@ -172,7 +180,7 @@ export class ModuleLoader { id: resolvedId.id, meta: resolvedId.meta || EMPTY_OBJECT, moduleSideEffects: - resolvedId.moduleSideEffects ?? this.hasModuleSideEffects(resolvedId.id, external), + resolvedId.moduleSideEffects ?? this.hasModuleSideEffects(resolvedId.id, !!external), syntheticNamedExports: resolvedId.syntheticNamedExports ?? false }; } @@ -338,19 +346,21 @@ export class ModuleLoader { resolvedId: ResolvedId ): Promise { if (resolvedId.external) { - if (!this.modulesById.has(resolvedId.id)) { + const { external, id, moduleSideEffects, meta } = resolvedId; + if (!this.modulesById.has(id)) { this.modulesById.set( - resolvedId.id, + id, new ExternalModule( this.options, - resolvedId.id, - resolvedId.moduleSideEffects, - resolvedId.meta + id, + moduleSideEffects, + meta, + external !== 'absolute' && isAbsolute(id) ) ); } - const externalModule = this.modulesById.get(resolvedId.id); + const externalModule = this.modulesById.get(id); if (!(externalModule instanceof ExternalModule)) { return error(errInternalIdCannotBeExternal(source, importer)); } @@ -381,31 +391,58 @@ export class ModuleLoader { } } + /* For plugins when resolveIdResult.id is absolute (otherwise external is true) + external | normalizeExternalPaths | result + true | true | true + true | 'relative' | 'absolute' + true | false | 'absolute' + 'normalize' | true | true + 'normalize' | 'relative' | true + 'normalize' | false | true + 'absolute' | true | 'absolute' + 'absolute' | 'relative' | 'absolute' + 'absolute' | false | 'absolute' + */ private getNormalizedResolvedIdWithoutDefaults( resolveIdResult: ResolveIdResult, importer: string | undefined, source: string - ): (PartialResolvedId & { external: boolean }) | null { + ): NormalizedResolveIdWithoutDefaults | null { + const { normalizeExternalPaths } = this.options; if (resolveIdResult) { if (typeof resolveIdResult === 'object') { + const external = + resolveIdResult.external || this.options.external(resolveIdResult.id, importer, true); return { ...resolveIdResult, external: - resolveIdResult.external || this.options.external(resolveIdResult.id, importer, true) + external && + (external === 'normalize' || + !isAbsolute(resolveIdResult.id) || + (external === true && + isNotAbsoluteExternal(resolveIdResult.id, source, normalizeExternalPaths)) || + 'absolute') }; } + const external = this.options.external(resolveIdResult, importer, true); return { - external, - id: external ? normalizeRelativeExternalId(resolveIdResult, importer) : resolveIdResult + external: + external && + (isNotAbsoluteExternal(resolveIdResult, source, normalizeExternalPaths) || 'absolute'), + id: + external && normalizeExternalPaths + ? normalizeRelativeExternalId(resolveIdResult, importer) + : resolveIdResult }; } - const id = normalizeRelativeExternalId(source, importer); + + const id = normalizeExternalPaths ? normalizeRelativeExternalId(source, importer) : source; if (resolveIdResult !== false && !this.options.external(id, importer, true)) { return null; } return { - external: true, + external: isNotAbsoluteExternal(id, source, normalizeExternalPaths) || 'absolute', id }; } @@ -469,7 +506,9 @@ export class ModuleLoader { } return this.fetchModule( this.addDefaultsToResolvedId( - typeof resolveIdResult === 'object' ? resolveIdResult : { id: resolveIdResult } + typeof resolveIdResult === 'object' + ? (resolveIdResult as NormalizedResolveIdWithoutDefaults) + : { id: resolveIdResult } )!, undefined, isEntry @@ -541,3 +580,15 @@ function addChunkNamesToModule( } } } + +function isNotAbsoluteExternal( + id: string, + source: string, + normalizeExternalPaths: boolean | 'relative' +) { + return ( + normalizeExternalPaths === true || + (normalizeExternalPaths === 'relative' && isRelative(source)) || + !isAbsolute(id) + ); +} diff --git a/src/rollup/types.d.ts b/src/rollup/types.d.ts index 3f671969bbd..03a514b9954 100644 --- a/src/rollup/types.d.ts +++ b/src/rollup/types.d.ts @@ -219,7 +219,7 @@ export interface PluginContextMeta { } export interface ResolvedId extends ModuleOptions { - external: boolean; + external: boolean | 'absolute'; id: string; } @@ -228,7 +228,7 @@ export interface ResolvedIdMap { } interface PartialResolvedId extends Partial> { - external?: boolean; + external?: boolean | 'absolute' | 'normalize'; id: string; } @@ -531,6 +531,7 @@ export interface InputOptions { /** @deprecated Use the "manualChunks" output option instead. */ manualChunks?: ManualChunksOption; moduleContext?: ((id: string) => string | null | undefined) | { [id: string]: string }; + normalizeExternalPaths?: boolean | 'relative'; onwarn?: WarningHandlerWithDefault; perf?: boolean; plugins?: Plugin[]; @@ -557,6 +558,7 @@ export interface NormalizedInputOptions { /** @deprecated Use the "manualChunks" output option instead. */ manualChunks: ManualChunksOption | undefined; moduleContext: (id: string) => string; + normalizeExternalPaths: boolean | 'relative'; onwarn: WarningHandler; perf: boolean; plugins: Plugin[]; diff --git a/src/utils/options/mergeOptions.ts b/src/utils/options/mergeOptions.ts index 843109df900..4a782442727 100644 --- a/src/utils/options/mergeOptions.ts +++ b/src/utils/options/mergeOptions.ts @@ -108,6 +108,7 @@ function mergeInputOptions( input: getOption('input') || [], manualChunks: getOption('manualChunks'), moduleContext: getOption('moduleContext'), + normalizeExternalPaths: getOption('normalizeExternalPaths'), onwarn: getOnWarn(config, defaultOnWarnHandler), perf: getOption('perf'), plugins: ensureArray(config.plugins) as Plugin[], diff --git a/src/utils/options/normalizeInputOptions.ts b/src/utils/options/normalizeInputOptions.ts index 595575b9ca6..e6a62786836 100644 --- a/src/utils/options/normalizeInputOptions.ts +++ b/src/utils/options/normalizeInputOptions.ts @@ -51,6 +51,8 @@ export function normalizeInputOptions( input: getInput(config), manualChunks: getManualChunks(config, onwarn, strictDeprecations), moduleContext: getModuleContext(config, context), + normalizeExternalPaths: + (config.normalizeExternalPaths as boolean | 'relative' | undefined) ?? true, onwarn, perf: (config.perf as boolean | undefined) || false, plugins: ensureArray(config.plugins) as Plugin[], @@ -262,7 +264,7 @@ const getTreeshake = ( warn ), propertyReadSideEffects: - configTreeshake.propertyReadSideEffects === 'always' && 'always' || + (configTreeshake.propertyReadSideEffects === 'always' && 'always') || configTreeshake.propertyReadSideEffects !== false, tryCatchDeoptimization: configTreeshake.tryCatchDeoptimization !== false, unknownGlobalSideEffects: configTreeshake.unknownGlobalSideEffects !== false diff --git a/test/form/samples/normalize-external-paths/normalize-false/_config.js b/test/form/samples/normalize-external-paths/normalize-false/_config.js new file mode 100644 index 00000000000..cc09710af0a --- /dev/null +++ b/test/form/samples/normalize-external-paths/normalize-false/_config.js @@ -0,0 +1,22 @@ +const path = require('path'); + +module.exports = { + description: 'does not normalize external paths when set to false', + options: { + normalizeExternalPaths: false, + external(id) { + if (['./relativeUnresolved.js', '../relativeUnresolved.js', '/absolute.js'].includes(id)) + return true; + }, + plugins: { + resolveId(source) { + if (source.endsWith('/pluginDirect.js')) return false; + if (source.endsWith('/pluginTrue.js')) return { id: '/pluginTrue.js', external: true }; + if (source.endsWith('/pluginAbsolute.js')) + return { id: '/pluginAbsolute.js', external: 'absolute' }; + if (source.endsWith('/pluginNormalize.js')) + return { id: path.join(__dirname, 'pluginNormalize.js'), external: 'normalize' }; + } + } + } +}; diff --git a/test/form/samples/normalize-external-paths/normalize-false/_expected.js b/test/form/samples/normalize-external-paths/normalize-false/_expected.js new file mode 100644 index 00000000000..b6167dd2f17 --- /dev/null +++ b/test/form/samples/normalize-external-paths/normalize-false/_expected.js @@ -0,0 +1,32 @@ +import { relativeUnresolved as relativeUnresolved$1 } from './relativeUnresolved.js'; +import { absolute } from '/absolute.js'; +import { pluginDirect as pluginDirect$1 } from './pluginDirect.js'; +import { pluginTrue } from '/pluginTrue.js'; +import { pluginAbsolute } from '/pluginAbsolute.js'; +import { pluginNormalize } from './pluginNormalize.js'; +import { relativeUnresolved } from '../relativeUnresolved.js'; +import { pluginDirect } from '../pluginDirect.js'; + +console.log( + 'nested', + relativeUnresolved, + relativeMissing, + relativeExisting, + absolute, + pluginDirect, + pluginTrue, + pluginAbsolute, + pluginNormalize +); + +console.log( + 'main', + relativeUnresolved$1, + relativeMissing, + relativeExisting, + absolute, + pluginDirect$1, + pluginTrue, + pluginAbsolute, + pluginNormalize +); diff --git a/test/form/samples/normalize-external-paths/normalize-false/main.js b/test/form/samples/normalize-external-paths/normalize-false/main.js new file mode 100644 index 00000000000..7f766ec8a6b --- /dev/null +++ b/test/form/samples/normalize-external-paths/normalize-false/main.js @@ -0,0 +1,19 @@ +import { relativeUnresolved } from './relativeUnresolved.js'; +import { absolute } from '/absolute.js'; +import { pluginDirect } from './pluginDirect.js'; +import { pluginTrue } from './pluginTrue.js'; +import { pluginAbsolute } from './pluginAbsolute.js'; +import { pluginNormalize } from './pluginNormalize.js'; +import './nested/nested.js'; + +console.log( + 'main', + relativeUnresolved, + relativeMissing, + relativeExisting, + absolute, + pluginDirect, + pluginTrue, + pluginAbsolute, + pluginNormalize +); diff --git a/test/form/samples/normalize-external-paths/normalize-false/nested/nested.js b/test/form/samples/normalize-external-paths/normalize-false/nested/nested.js new file mode 100644 index 00000000000..d1585e7ed38 --- /dev/null +++ b/test/form/samples/normalize-external-paths/normalize-false/nested/nested.js @@ -0,0 +1,18 @@ +import { relativeUnresolved } from '../relativeUnresolved.js'; +import { absolute } from '/absolute.js'; +import { pluginDirect } from '../pluginDirect.js'; +import { pluginTrue } from '../pluginTrue.js'; +import { pluginAbsolute } from '../pluginAbsolute.js'; +import { pluginNormalize } from '../pluginNormalize.js'; + +console.log( + 'nested', + relativeUnresolved, + relativeMissing, + relativeExisting, + absolute, + pluginDirect, + pluginTrue, + pluginAbsolute, + pluginNormalize +); diff --git a/test/form/samples/normalize-external-paths/normalize-relative/_config.js b/test/form/samples/normalize-external-paths/normalize-relative/_config.js new file mode 100644 index 00000000000..da7c8fc356c --- /dev/null +++ b/test/form/samples/normalize-external-paths/normalize-relative/_config.js @@ -0,0 +1,32 @@ +const path = require('path'); + +module.exports = { + description: + 'only normalizes external paths that were originally relative when set to "relative"', + options: { + normalizeExternalPaths: 'relative', + external(id) { + if ( + [ + './relativeUnresolved.js', + '../relativeUnresolved.js', + path.join(__dirname, 'relativeMissing.js'), + path.join(__dirname, 'relativeExisting.js'), + '/absolute.js' + ].includes(id) + ) + return true; + }, + plugins: { + resolveId(source) { + if (source.endsWith('/pluginDirect.js')) return false; + if (source.endsWith('/pluginTrue.js')) + return { id: path.join(__dirname, 'pluginTrue.js'), external: true }; + if (source.endsWith('/pluginAbsolute.js')) + return { id: '/pluginAbsolute.js', external: 'absolute' }; + if (source.endsWith('/pluginNormalize.js')) + return { id: path.join(__dirname, 'pluginNormalize.js'), external: 'normalize' }; + } + } + } +}; diff --git a/test/form/samples/normalize-external-paths/normalize-relative/_expected.js b/test/form/samples/normalize-external-paths/normalize-relative/_expected.js new file mode 100644 index 00000000000..37f25871818 --- /dev/null +++ b/test/form/samples/normalize-external-paths/normalize-relative/_expected.js @@ -0,0 +1,32 @@ +import { relativeUnresolved } from './relativeUnresolved.js'; +import { relativeMissing } from './relativeMissing.js'; +import { relativeExisting } from './relativeExisting.js'; +import { absolute } from '/absolute.js'; +import { pluginDirect } from './pluginDirect.js'; +import { pluginTrue } from './pluginTrue.js'; +import { pluginAbsolute } from '/pluginAbsolute.js'; +import { pluginNormalize } from './pluginNormalize.js'; + +console.log( + 'nested', + relativeUnresolved, + relativeMissing, + relativeExisting, + absolute, + pluginDirect, + pluginTrue, + pluginAbsolute, + pluginNormalize +); + +console.log( + 'main', + relativeUnresolved, + relativeMissing, + relativeExisting, + absolute, + pluginDirect, + pluginTrue, + pluginAbsolute, + pluginNormalize +); diff --git a/test/form/samples/normalize-external-paths/normalize-relative/main.js b/test/form/samples/normalize-external-paths/normalize-relative/main.js new file mode 100644 index 00000000000..162d6f832a0 --- /dev/null +++ b/test/form/samples/normalize-external-paths/normalize-relative/main.js @@ -0,0 +1,21 @@ +import { relativeUnresolved } from './relativeUnresolved.js'; +import { relativeMissing } from './relativeMissing.js'; +import { relativeExisting } from './relativeExisting.js'; +import { absolute } from '/absolute.js'; +import { pluginDirect } from './pluginDirect.js'; +import { pluginTrue } from './pluginTrue.js'; +import { pluginAbsolute } from './pluginAbsolute.js'; +import { pluginNormalize } from './pluginNormalize.js'; +import './nested/nested.js'; + +console.log( + 'main', + relativeUnresolved, + relativeMissing, + relativeExisting, + absolute, + pluginDirect, + pluginTrue, + pluginAbsolute, + pluginNormalize +); diff --git a/test/form/samples/normalize-external-paths/normalize-relative/nested/nested.js b/test/form/samples/normalize-external-paths/normalize-relative/nested/nested.js new file mode 100644 index 00000000000..415147c49ec --- /dev/null +++ b/test/form/samples/normalize-external-paths/normalize-relative/nested/nested.js @@ -0,0 +1,20 @@ +import { relativeUnresolved } from '../relativeUnresolved.js'; +import { relativeMissing } from '../relativeMissing.js'; +import { relativeExisting } from '../relativeExisting.js'; +import { absolute } from '/absolute.js'; +import { pluginDirect } from '../pluginDirect.js'; +import { pluginTrue } from '../pluginTrue.js'; +import { pluginAbsolute } from '../pluginAbsolute.js'; +import { pluginNormalize } from '../pluginNormalize.js'; + +console.log( + 'nested', + relativeUnresolved, + relativeMissing, + relativeExisting, + absolute, + pluginDirect, + pluginTrue, + pluginAbsolute, + pluginNormalize +); diff --git a/test/form/samples/normalize-external-paths/normalize-relative/relativeExisting.js b/test/form/samples/normalize-external-paths/normalize-relative/relativeExisting.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/form/samples/normalize-external-paths/normalize-true/_config.js b/test/form/samples/normalize-external-paths/normalize-true/_config.js new file mode 100644 index 00000000000..386bde4c372 --- /dev/null +++ b/test/form/samples/normalize-external-paths/normalize-true/_config.js @@ -0,0 +1,32 @@ +const path = require('path'); + +module.exports = { + description: 'normalizes both relative and absolute external paths when set to true', + options: { + normalizeExternalPaths: true, + external(id) { + if ( + [ + './relativeUnresolved.js', + '../relativeUnresolved.js', + path.join(__dirname, 'relativeMissing.js'), + path.join(__dirname, 'relativeExisting.js'), + path.join(__dirname, 'absolute.js') + ].includes(id) + ) + return true; + }, + plugins: { + resolveId(source) { + if (source.endsWith('/pluginDirect.js')) return false; + if (source.endsWith('/pluginTrue.js')) + return { id: path.join(__dirname, 'pluginTrue.js'), external: true }; + if (source.endsWith('/pluginAbsolute.js')) + return { id: '/pluginAbsolute.js', external: 'absolute' }; + if (source.endsWith('/pluginNormalize.js')) + return { id: path.join(__dirname, 'pluginNormalize.js'), external: 'normalize' }; + if (source === '/absolute.js') return path.join(__dirname, 'absolute.js'); + } + } + } +}; diff --git a/test/form/samples/normalize-external-paths/normalize-true/_expected.js b/test/form/samples/normalize-external-paths/normalize-true/_expected.js new file mode 100644 index 00000000000..77b7cbc1625 --- /dev/null +++ b/test/form/samples/normalize-external-paths/normalize-true/_expected.js @@ -0,0 +1,32 @@ +import { relativeUnresolved } from './relativeUnresolved.js'; +import { relativeMissing } from './relativeMissing.js'; +import { relativeExisting } from './relativeExisting.js'; +import { absolute } from './absolute.js'; +import { pluginDirect } from './pluginDirect.js'; +import { pluginTrue } from './pluginTrue.js'; +import { pluginAbsolute } from '/pluginAbsolute.js'; +import { pluginNormalize } from './pluginNormalize.js'; + +console.log( + 'nested', + relativeUnresolved, + relativeMissing, + relativeExisting, + absolute, + pluginDirect, + pluginTrue, + pluginAbsolute, + pluginNormalize +); + +console.log( + 'main', + relativeUnresolved, + relativeMissing, + relativeExisting, + absolute, + pluginDirect, + pluginTrue, + pluginAbsolute, + pluginNormalize +); diff --git a/test/form/samples/normalize-external-paths/normalize-true/main.js b/test/form/samples/normalize-external-paths/normalize-true/main.js new file mode 100644 index 00000000000..162d6f832a0 --- /dev/null +++ b/test/form/samples/normalize-external-paths/normalize-true/main.js @@ -0,0 +1,21 @@ +import { relativeUnresolved } from './relativeUnresolved.js'; +import { relativeMissing } from './relativeMissing.js'; +import { relativeExisting } from './relativeExisting.js'; +import { absolute } from '/absolute.js'; +import { pluginDirect } from './pluginDirect.js'; +import { pluginTrue } from './pluginTrue.js'; +import { pluginAbsolute } from './pluginAbsolute.js'; +import { pluginNormalize } from './pluginNormalize.js'; +import './nested/nested.js'; + +console.log( + 'main', + relativeUnresolved, + relativeMissing, + relativeExisting, + absolute, + pluginDirect, + pluginTrue, + pluginAbsolute, + pluginNormalize +); diff --git a/test/form/samples/normalize-external-paths/normalize-true/nested/nested.js b/test/form/samples/normalize-external-paths/normalize-true/nested/nested.js new file mode 100644 index 00000000000..415147c49ec --- /dev/null +++ b/test/form/samples/normalize-external-paths/normalize-true/nested/nested.js @@ -0,0 +1,20 @@ +import { relativeUnresolved } from '../relativeUnresolved.js'; +import { relativeMissing } from '../relativeMissing.js'; +import { relativeExisting } from '../relativeExisting.js'; +import { absolute } from '/absolute.js'; +import { pluginDirect } from '../pluginDirect.js'; +import { pluginTrue } from '../pluginTrue.js'; +import { pluginAbsolute } from '../pluginAbsolute.js'; +import { pluginNormalize } from '../pluginNormalize.js'; + +console.log( + 'nested', + relativeUnresolved, + relativeMissing, + relativeExisting, + absolute, + pluginDirect, + pluginTrue, + pluginAbsolute, + pluginNormalize +); diff --git a/test/form/samples/normalize-external-paths/normalize-true/relativeExisting.js b/test/form/samples/normalize-external-paths/normalize-true/relativeExisting.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/form/samples/quote-id/_expected/amd.js b/test/form/samples/quote-id/_expected/amd.js index 2e1243729a0..aba63d8d282 100644 --- a/test/form/samples/quote-id/_expected/amd.js +++ b/test/form/samples/quote-id/_expected/amd.js @@ -1,6 +1,6 @@ define(['quoted\'\ \ -\
\
external1', 'quoted\'\ \ -\
\
external2', 'C:\\File\\Path.js'], function (quoted_____external1, quoted_____external2, Path_js) { 'use strict'; +\
\
external1', './quoted\'\ \ +\
\
external2', './C:/File/Path'], function (quoted_____external1, quoted_____external2, Path_js) { 'use strict'; console.log(quoted_____external1.foo, quoted_____external2.bar, Path_js.baz); diff --git a/test/form/samples/quote-id/_expected/cjs.js b/test/form/samples/quote-id/_expected/cjs.js index be514723275..9468de1d0d0 100644 --- a/test/form/samples/quote-id/_expected/cjs.js +++ b/test/form/samples/quote-id/_expected/cjs.js @@ -2,8 +2,8 @@ var quoted_____external1 = require('quoted\'\ \ \
\
external1'); -var quoted_____external2 = require('quoted\'\ \ +var quoted_____external2 = require('./quoted\'\ \ \
\
external2'); -var Path_js = require('C:\\File\\Path.js'); +var Path_js = require('./C:/File/Path.js'); console.log(quoted_____external1.foo, quoted_____external2.bar, Path_js.baz); diff --git a/test/form/samples/quote-id/_expected/es.js b/test/form/samples/quote-id/_expected/es.js index cb0fe35580d..182f5ee556a 100644 --- a/test/form/samples/quote-id/_expected/es.js +++ b/test/form/samples/quote-id/_expected/es.js @@ -1,7 +1,7 @@ import { foo } from 'quoted\'\ \ \
\
external1'; -import { bar } from 'quoted\'\ \ +import { bar } from './quoted\'\ \ \
\
external2'; -import { baz } from 'C:\\File\\Path.js'; +import { baz } from './C:/File/Path.js'; console.log(foo, bar, baz); diff --git a/test/form/samples/quote-id/_expected/system.js b/test/form/samples/quote-id/_expected/system.js index 7572577c40d..2043821f04c 100644 --- a/test/form/samples/quote-id/_expected/system.js +++ b/test/form/samples/quote-id/_expected/system.js @@ -1,6 +1,6 @@ System.register('Q', ['quoted\'\ \ -\
\
external1', 'quoted\'\ \ -\
\
external2', 'C:\\File\\Path.js'], function () { +\
\
external1', './quoted\'\ \ +\
\
external2', './C:/File/Path.js'], function () { 'use strict'; var foo, bar, baz; return { diff --git a/test/form/samples/quote-id/_expected/umd.js b/test/form/samples/quote-id/_expected/umd.js index 92870cbe872..f59f3c56cdd 100644 --- a/test/form/samples/quote-id/_expected/umd.js +++ b/test/form/samples/quote-id/_expected/umd.js @@ -1,10 +1,10 @@ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('quoted\'\ \ -\
\
external1'), require('quoted\'\ \ -\
\
external2'), require('C:\\File\\Path.js')) : +\
\
external1'), require('./quoted\'\ \ +\
\
external2'), require('./C:/File/Path.js')) : typeof define === 'function' && define.amd ? define(['quoted\'\ \ -\
\
external1', 'quoted\'\ \ -\
\
external2', 'C:\\File\\Path.js'], factory) : +\
\
external1', './quoted\'\ \ +\
\
external2', './C:/File/Path'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.quotedExternal1, global.quotedExternal2, global.quotedExternal3)); }(this, (function (quoted_____external1, quoted_____external2, Path_js) { 'use strict'; diff --git a/test/function/samples/options-hook/_config.js b/test/function/samples/options-hook/_config.js index b217bd91263..9a1dab37078 100644 --- a/test/function/samples/options-hook/_config.js +++ b/test/function/samples/options-hook/_config.js @@ -19,6 +19,7 @@ module.exports = { context: 'undefined', experimentalCacheExpiry: 10, input: ['used'], + normalizeExternalPaths: true, perf: false, plugins: [ { diff --git a/test/misc/optionList.js b/test/misc/optionList.js index 05392922320..7eeb54b2025 100644 --- a/test/misc/optionList.js +++ b/test/misc/optionList.js @@ -1,6 +1,6 @@ exports.input = - 'acorn, acornInjectPlugins, cache, context, experimentalCacheExpiry, external, inlineDynamicImports, input, manualChunks, moduleContext, onwarn, perf, plugins, preserveEntrySignatures, preserveModules, preserveSymlinks, shimMissingExports, strictDeprecations, treeshake, watch'; + 'acorn, acornInjectPlugins, cache, context, experimentalCacheExpiry, external, inlineDynamicImports, input, manualChunks, moduleContext, normalizeExternalPaths, onwarn, perf, plugins, preserveEntrySignatures, preserveModules, preserveSymlinks, shimMissingExports, strictDeprecations, treeshake, watch'; exports.flags = - 'acorn, acornInjectPlugins, amd, assetFileNames, banner, c, cache, chunkFileNames, compact, config, context, d, dir, dynamicImportFunction, e, entryFileNames, environment, esModule, experimentalCacheExpiry, exports, extend, external, externalLiveBindings, f, failAfterWarnings, file, footer, format, freeze, g, globals, h, hoistTransitiveImports, i, indent, inlineDynamicImports, input, interop, intro, m, manualChunks, minifyInternalExports, moduleContext, n, name, namespaceToStringTag, noConflict, o, onwarn, outro, p, paths, perf, plugin, plugins, preferConst, preserveEntrySignatures, preserveModules, preserveModulesRoot, preserveSymlinks, shimMissingExports, silent, sourcemap, sourcemapExcludeSources, sourcemapFile, stdin, strict, strictDeprecations, systemNullSetters, treeshake, v, validate, w, waitForBundleInput, watch'; + 'acorn, acornInjectPlugins, amd, assetFileNames, banner, c, cache, chunkFileNames, compact, config, context, d, dir, dynamicImportFunction, e, entryFileNames, environment, esModule, experimentalCacheExpiry, exports, extend, external, externalLiveBindings, f, failAfterWarnings, file, footer, format, freeze, g, globals, h, hoistTransitiveImports, i, indent, inlineDynamicImports, input, interop, intro, m, manualChunks, minifyInternalExports, moduleContext, n, name, namespaceToStringTag, noConflict, normalizeExternalPaths, o, onwarn, outro, p, paths, perf, plugin, plugins, preferConst, preserveEntrySignatures, preserveModules, preserveModulesRoot, preserveSymlinks, shimMissingExports, silent, sourcemap, sourcemapExcludeSources, sourcemapFile, stdin, strict, strictDeprecations, systemNullSetters, treeshake, v, validate, w, waitForBundleInput, watch'; exports.output = 'amd, assetFileNames, banner, chunkFileNames, compact, dir, dynamicImportFunction, entryFileNames, esModule, exports, extend, externalLiveBindings, file, footer, format, freeze, globals, hoistTransitiveImports, indent, inlineDynamicImports, interop, intro, manualChunks, minifyInternalExports, name, namespaceToStringTag, noConflict, outro, paths, plugins, preferConst, preserveModules, preserveModulesRoot, sourcemap, sourcemapExcludeSources, sourcemapFile, sourcemapPathTransform, strict, systemNullSetters, validate';