From 4fc431a3b928713065326e236299970b5ddd25d4 Mon Sep 17 00:00:00 2001 From: Lukas Taegert-Atkinson Date: Fri, 15 Jul 2022 16:38:02 +0200 Subject: [PATCH] [v3.0] Change default for makeAbsoluteExternalsRelative (#4567) --- docs/999-big-list-of-options.md | 4 ++-- src/utils/options/normalizeInputOptions.ts | 2 +- test/form/samples/quote-id/_expected/amd.js | 4 ++-- test/form/samples/quote-id/_expected/cjs.js | 4 ++-- test/form/samples/quote-id/_expected/es.js | 4 ++-- test/form/samples/quote-id/_expected/system.js | 4 ++-- test/form/samples/quote-id/_expected/umd.js | 8 ++++---- test/function/samples/options-hook/_config.js | 2 +- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/docs/999-big-list-of-options.md b/docs/999-big-list-of-options.md index fc17e1e5f3f..2740bfb27e8 100755 --- a/docs/999-big-list-of-options.md +++ b/docs/999-big-list-of-options.md @@ -344,7 +344,7 @@ buildWithCache() #### makeAbsoluteExternalsRelative -Type: `boolean | "ifRelativeSource"`
CLI: `--makeAbsoluteExternalsRelative`/`--no-makeAbsoluteExternalsRelative`
Default: `true` +Type: `boolean | "ifRelativeSource"`
CLI: `--makeAbsoluteExternalsRelative`/`--no-makeAbsoluteExternalsRelative`
Default: `"ifRelativeSource"` Determines if absolute external paths should be converted to relative paths in the output. This does not only apply to paths that are absolute in the source but also to paths that are resolved to an absolute path by either a plugin or Rollup core. @@ -354,7 +354,7 @@ As stated before, this would also apply to originally relative imports like `imp One common problem is that this mechanism will also apply to imports like `import "/absolute.js'"`, resulting in unexpected relative paths in the output. -For this case, choosing `"ifRelativeSource"` will check if the original import was a relative import and only then convert it to a relative import in the output. Choosing `false` will keep all paths as absolute paths in the output. +For this case, `"ifRelativeSource"` checks if the original import was a relative import and only then convert it to a relative import in the output. Choosing `false` will keep all paths as absolute paths in the output. Note that when a relative path is directly marked as "external" using the [`external`](guide/en/#external) option, then it will be the same relative path in the output. When it is resolved first via a plugin or Rollup core and then marked as external, the above logic will apply. diff --git a/src/utils/options/normalizeInputOptions.ts b/src/utils/options/normalizeInputOptions.ts index abd4e48264f..4665ddcbff3 100644 --- a/src/utils/options/normalizeInputOptions.ts +++ b/src/utils/options/normalizeInputOptions.ts @@ -47,7 +47,7 @@ export function normalizeInputOptions(config: InputOptions): { external: getIdMatcher(config.external), inlineDynamicImports: getInlineDynamicImports(config, onwarn, strictDeprecations), input: getInput(config), - makeAbsoluteExternalsRelative: config.makeAbsoluteExternalsRelative ?? true, + makeAbsoluteExternalsRelative: config.makeAbsoluteExternalsRelative ?? 'ifRelativeSource', manualChunks: getManualChunks(config, onwarn, strictDeprecations), maxParallelFileOps, maxParallelFileReads: maxParallelFileOps, diff --git a/test/form/samples/quote-id/_expected/amd.js b/test/form/samples/quote-id/_expected/amd.js index 0f4d352f0d7..1e1788b3070 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'], (function (quoted_____external1, quoted_____external2, Path_js) { 'use strict'; +\
\
external1', 'quoted\'\ \ +\
\
external2', 'C:\\File\\Path.js'], (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 9468de1d0d0..be514723275 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 182f5ee556a..cb0fe35580d 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 f5a9740eb0a..f6906e3bc49 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 fb276a03cd4..5fcb5aa6501 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'], factory) : +\
\
external1', 'quoted\'\ \ +\
\
external2', 'C:\\File\\Path.js'], 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 f739ee6252c..04b6611f8fc 100644 --- a/test/function/samples/options-hook/_config.js +++ b/test/function/samples/options-hook/_config.js @@ -19,7 +19,7 @@ module.exports = { context: 'undefined', experimentalCacheExpiry: 10, input: ['used'], - makeAbsoluteExternalsRelative: true, + makeAbsoluteExternalsRelative: 'ifRelativeSource', maxParallelFileOps: 20, maxParallelFileReads: 20, perf: false,