-
Notifications
You must be signed in to change notification settings - Fork 27
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
Avoid adding a new keyword for static imports (with
)
#62
Comments
I haven't seen another discussion of this particular alternative. Could you say something about why you see this option as preferable? (Personally, I thought a keyword would be in keeping with the rest of the syntax of import statements.) |
import module from ('./file.wasm', { type: 'wasm' });
const module = await import('./file.wasm', { type: 'wasm' });
import module from './file.wasm' with type: 'wasm', integrity: '7425tre...'
// Aside: Would this be valid? (newline)
import module from 'file.wasm' with
type: 'wasm', // Comma separated?
integrity: '7425tre...'
// Proposed alternative
import module from (
'./file.wasm',
{ type: 'wasm', integrity: '7425tre..' }
);
const module = await import(
'./file.wasm',
{ type: 'wasm', integrity: '7425tre..' }
); Some of the examples simply looked kind of verbose when I first read them, so I was wondering if that's on purpose (It's needed/required by some contraints) and this popped up as an alternative in my mind :)
Sure :), but allowing a 'parenthesized referrer' instead of adding a new keyword shouldn't 'voilate' the current syntax for import statements with the benefit of having more alignment between import statements and import json from "./foo.json" with type: "json";
import("foo.json", { with: { type: "json" } /* <= Meh ;( */ })
import json from ("./foo.json", { type: "json" });
import("foo.json", { type: "json" } /* <= no with { .. } for alignment needed */) |
How do Import Maps work together with Module Attributes? Is this needed/or a goal at all? e.g ( only in theory to make a showcase :) )
{
"imports": {
// Module (Current)
"[referrer]": "[url]"
// Module with Attributes (Proposed)
"[referrer]": {
url: "/node_modules/wasm-pkg/module.wasm",
type: 'wasm',
deps: [ ./dep1.wasm', './dep2.wasm' ], // e.g DepCache Proposal @guybedford
integrity: '...'
}
} // Import Maps
// Module (with Attributes)
import module from '[referrer]';
const module = await import('[referrer]')
// Without Import Maps
// Module
import module from "/node_modules/wasm-pkg/module.wasm";
// Module with Attributes
import module from (
"/node_modules/wasm-pkg/module.wasm",
{ type: 'wasm', deps: [ './dep1.wasm', './dep2.wasm' ], integrity: '...' }
);
const module = await import(
"/node_modules/wasm-pkg/module.wasm",
{ type: 'wasm', deps: [ './dep1.wasm', './dep2.wasm' ], integrity: '...' }
); |
As for whether For depcache and integrity, I think these are better expressed out-of-band exclusively. When we have a piece of metadata that makes sense both in-band and out-of-band, we can think more concretely about how we could let users do either. I'd imagine, out-of-band could set a baseline, and in-band could add more things to that. |
Besides what you said (which seems to mean that yes we would need to consider how import maps work with this), seems like they would need to be handled in some way if there will be something like #73 |
About import maps, I've proposed things about interactions with import maps in the past, but they weren't considered in scope for the people working on import maps. I'm not currently proposing more things about import maps. |
The proposal has settled on the Thanks for contributing to the discussion! |
Wouldn't it be possible to avoid the e.g
with
keyword for static imports by e.ge.g
with the benefit of being kind of similiar to the syntax of a dynamic import?
My apologies if this was already being discussed/proposed before
The text was updated successfully, but these errors were encountered: