-
Notifications
You must be signed in to change notification settings - Fork 12.8k
ES6 modules not found when loaded over network #29854
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
Comments
Not pulling arbitrary http endpoints is intentional. You can // .d.ts file
declare module "https://dev.jspm.io/[email protected]/lit-element.js" {
export const LitElement: any, html: any;
}
// Elsewhere
import { LitElement, html } from 'https://dev.jspm.io/[email protected]/lit-element.js'; |
Thx for the tip about declaring a module by its URL. It helps, but in order for it to be really useful, you typically have to add quite a bit more type information than declare module "https://dev.jspm.io/[email protected]/lit-element.js" {
export declare class LitElement extends HTMLElement {
requestUpdate(name?: PropertyKey, oldValue?: unknown): Promise<unkown>;
...
}
export const html: any;
...
} I still think it would be great if there was an option to turn on pulling http endpoints just like the ES2015 runtime system in a browser does, since it would make the kind of development/prototyping that I described above much easier and even more productive. |
This issue has been marked 'Working as Intended' and has seen no recent activity. It has been automatically closed for house-keeping purposes. |
@RyanCavanaugh Is there a way to pull in the type definitions while simultaneously relying on a network import? I'm trying to do the exact same thing as @hindsholm. There's no reason to pull in all the code when it can be served via CDN. Edit: Found this. Unfortunately, for libraries like lit-element, this means you still have to have the entire library locally, as a |
Something that I would like to call out is that the package in question is authored in TypeScript and publishes its type declarations alongside the other build output. Why should we re-declare all of those types? I also arrived at the solution of loading from a CDN after reading the following advice given in a separate thread:
Excerpt taken from this older thread. To lay out the scope of my problem:
So my options to write TypeScript and deploy to the browser are:
It seems like something important is missing here. |
(the missing thing may be Import Maps, but those don't technically exist yet) |
Issue Type: Bug
ES6 modules can be loaded over HTTP(S) like this:
This works fine in any modern browser since it is standard ES6 and I find it very convenient for small projects because it allows you to completely avoid the complexity involved with npm and packagers.
However, VS Code complains with a red underline and the mouseover error message:
It would be great if VS Code did not complain about this (since it is possible to find the module) and even better of course, if the module could be resolved correctly like locally-loaded modules.
VS Code version: Code 1.31.0 (7c66f58312b48ed8ca4e387ebd9ffe9605332caa, 2019-02-06T08:51:24.856Z)
OS version: Linux x64 4.20.6-arch1-1-ARCH
System Info
checker_imaging: disabled_off
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: disabled_software
rasterization: disabled_software
surface_synchronization: enabled_on
video_decode: unavailable_off
webgl: enabled
webgl2: enabled
Extensions (20)
(1 theme extensions excluded)
The text was updated successfully, but these errors were encountered: