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

Basing syntax on Import Assertions syntax #16

Open
AlicanC opened this issue Jan 2, 2021 · 1 comment
Open

Basing syntax on Import Assertions syntax #16

AlicanC opened this issue Jan 2, 2021 · 1 comment

Comments

@AlicanC
Copy link

AlicanC commented Jan 2, 2021

I think it would be great if the syntax was closer to what's being introduced in Import Assertions:

import logoModuleReference from "./logo.svg" as reference;
// OR
const logoModuleReference: ModuleReference = await import('./logo.svg', { as: 'reference' });

const logoUrl: string = URL.createObjectURL(logoModuleReference);

import workerModuleReference from "./worker.js" as reference;
const worker = new Worker(workerModuleReference);

Note: I've rewritten this post, because I've interpreted the goal of Import Assertions wrong.

@AlicanC AlicanC changed the title Basing this proposal on Import Assertions Basing syntax on Import Assertions syntax Jan 2, 2021
@shaedrich
Copy link

From the current state of the import attributes proposal, it would look like this:

import logoModuleReference from "./logo.svg" with { asReference: true };
// or
import logoModuleReference from "./logo.svg" with { as: "reference" };

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

No branches or pull requests

2 participants