Skip to content

Commit

Permalink
[v3.0] Change default for makeAbsoluteExternalsRelative (#4567)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukastaegert committed Jul 20, 2022
1 parent 31b0b43 commit 3f55e31
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions docs/999-big-list-of-options.md
Expand Up @@ -344,7 +344,7 @@ buildWithCache()
#### makeAbsoluteExternalsRelative
Type: `boolean | "ifRelativeSource"`<br> CLI: `--makeAbsoluteExternalsRelative`/`--no-makeAbsoluteExternalsRelative`<br> Default: `true`
Type: `boolean | "ifRelativeSource"`<br> CLI: `--makeAbsoluteExternalsRelative`/`--no-makeAbsoluteExternalsRelative`<br> 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.
Expand All @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/utils/options/normalizeInputOptions.ts
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions 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);

Expand Down
4 changes: 2 additions & 2 deletions test/form/samples/quote-id/_expected/cjs.js
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions 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);
Expand Down
4 changes: 2 additions & 2 deletions 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 {
Expand Down
8 changes: 4 additions & 4 deletions 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';

Expand Down
2 changes: 1 addition & 1 deletion test/function/samples/options-hook/_config.js
Expand Up @@ -19,7 +19,7 @@ module.exports = {
context: 'undefined',
experimentalCacheExpiry: 10,
input: ['used'],
makeAbsoluteExternalsRelative: true,
makeAbsoluteExternalsRelative: 'ifRelativeSource',
maxParallelFileOps: 20,
maxParallelFileReads: 20,
perf: false,
Expand Down

0 comments on commit 3f55e31

Please sign in to comment.