makeAbsoluteExternalsRelative
- Type:
optionalmakeAbsoluteExternalsRelative:false|true|"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 Rolldown core.
For true, an external import like import "/Users/Rolldown/project/relative.js" would be converted to a relative path. When converting an absolute path to a relative path, Rolldown does not take the file or dir options into account, because those may not be present e.g. for builds using the JavaScript API. Instead, it assumes that the root of the generated bundle is located at the common shared parent directory of all modules that were included in the bundle. Assuming that the common parent directory of all modules is "/Users/Rolldown/project", the import from above would likely be converted to import "./relative.js" in the output. If the output chunk is itself nested in a subdirectory by choosing e.g. chunkFileNames: "chunks/[name].js", the import would be "../relative.js". As stated before, this would also apply to originally relative imports like import "./relative.js" that are resolved to an absolute path before they are marked as external by the external option.
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, "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 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.