Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resolveId() - absolute paths of external modules are not to be converted to relative paths #3940

Closed
fanick1 opened this issue Jan 28, 2021 · 3 comments · Fixed by #4021
Closed

Comments

@fanick1
Copy link

fanick1 commented Jan 28, 2021

Expected Behavior / Situation

for some arbitrary module id a plugin with the resolveId() hook resolves this id to:

{
  id: '/some/absolute/path.haschode123.min.js',
  external: true
}

then this path is tranformed into the output file as-is

import foo from '/some/absolute/path.hashcode123.min.js'

Actual Behavior / Situation

this path is mangled in the output file into something like

import foo from '../../../../some/absolute/path.hashcode123.min.js'

which works in my case now only by accident (there are enough ../ to get to the root path in the browser)

Modification Proposal

do not path.relative() the id returned from resolveId when the id is marked as external.

using output.paths is not an option for me - I don't know the paths up front and I need to do some tricky resolutions

@fanick1 fanick1 changed the title resolvedId() - absolute paths of external modules are not to be converted to relative paths resolveId() - absolute paths of external modules are not to be converted to relative paths Jan 28, 2021
@fanick1
Copy link
Author

fanick1 commented Feb 3, 2021

I was lucky enough to run into a case where the rollup does not put enough '../' into the path and now the module (let's say the module in the example path.hashocde123.min.js) cannot be found because I am serving one module too deep in the URL structure.
A quick workaround I had to do is to prepend the module id returned from the resolveId() with few '../' :

{
  id: '../../../../../../../../../some/absolute/path.haschode123.min.js',
  external: true
}

This of course still leaves room for error. I really think that external modules with a leading '/' in the name should be treated as absolute paths.

@fanick1
Copy link
Author

fanick1 commented Feb 18, 2021

I believe this is the same issue as in #3831.

@lukastaegert
Copy link
Member

Fix at fix at #4021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants