proposal-asset-references icon indicating copy to clipboard operation
proposal-asset-references copied to clipboard

also in Script, or just Module?

Open ljharb opened this issue 7 years ago • 7 comments

import() works in both Scripts and Modules. Should asset work in Scripts, for the same reasons?

ljharb avatar Nov 14 '18 21:11 ljharb

Good question. I think there is an interesting overlap with import maps. Particularly “import:” URLs or something like it. The larger story around how URLs will work in the larger web platform can be informative of how it could work in scripts.

sebmarkbage avatar Nov 14 '18 21:11 sebmarkbage

if this syntax works in a way that requires IO/async ops to perform resolution before starting code evaluation I don't think this would work for Scripts since they are expected for run synchronously.

bmeck avatar Nov 16 '18 20:11 bmeck

I would assume the synchronous form is not available in Scripts, but the asynchronous one should work, just like import() does.

ljharb avatar Nov 16 '18 20:11 ljharb

@ljharb is this mostly about consistency? If the location operations are not timed specifically we can still produce the reference synchronously.

bmeck avatar Nov 16 '18 23:11 bmeck

Yes, I think a lack of consistency will be confusing, including in terms of thinking about the phases in ESM.

ljharb avatar Nov 16 '18 23:11 ljharb

including in terms of thinking about the phases in ESM.

Can you explain how these values are directly tied in part to the phases of ESM?

bmeck avatar Nov 19 '18 16:11 bmeck

With static forms, i expect that all imports are fully resolved and valid before any actual code evaluates. import ‘nonexistent’ throws before anything is evaluated; I’d expect asset from ‘nonexistent’ to do the same.

ljharb avatar Nov 19 '18 19:11 ljharb