-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Fix new ESM loader runtime by moving to abs URLs #9172
Changes from 11 commits
ec26354
b87c517
d3b8b80
97fb583
2374991
6360db5
c268a75
05c0a90
166c312
b19fc2a
1dbda59
8e8233c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,6 @@ | ||
function load(id, base) { | ||
let bundleId = require('../bundle-manifest').resolve(id); | ||
let request = base ? './' + base + bundleId : './' + bundleId; | ||
|
||
function load(id) { | ||
// eslint-disable-next-line no-undef | ||
return __parcel__import__(request); | ||
return __parcel__import__(require('../bundle-manifest').resolve(id)); | ||
} | ||
|
||
module.exports = load; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,17 @@ | ||
var mapping = {}; | ||
var mapping = new Map(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are we ok to drop browsers that don't support There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe Map is supported in IE11. This support coverage looks good enough to me. But I can remove if you want. |
||
|
||
function register(pairs) { | ||
var keys = Object.keys(pairs); | ||
for (var i = 0; i < keys.length; i++) { | ||
mapping[keys[i]] = pairs[keys[i]]; | ||
function register(baseUrl, pairs) { | ||
for (var i = 0; i < pairs.length; i++) { | ||
mapping.set(pairs[i][0], {baseUrl, path: pairs[i][1]}); | ||
mattcompiles marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} | ||
|
||
function resolve(id) { | ||
var resolved = mapping[id]; | ||
var resolved = mapping.get(id); | ||
if (resolved == null) { | ||
throw new Error('Could not resolve bundle with id ' + id); | ||
} | ||
return resolved; | ||
return new URL(resolved.path, resolved.baseUrl).toString(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This one definitely won't work in IE. Probably ok at this point? I guess we can't simply concatenate the strings? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah not ideal. We could just recommend a polyfill for URL if anyone has issues I guess. |
||
} | ||
|
||
module.exports.register = register; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@devongovett Thoughts on this? Seems reasonable that I should be able to use
import.meta.url
without it being replaced?I could modify the transform to add a new special parcel symbol (e.g.
__parcel_importMetaUrl__
)? Or potentially add some asset meta data that prevents the stripping?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm yeah, I guess we could add a new
__parcel
thing, but does this work as is for now? if so I'm ok with leaving it as you have it as well.