Comments (5)
I've quickly patched the https://github.com/modernweb-dev/web/blob/master/packages/dev-server-import-maps/src/importMapsPlugin.ts#L121-L123 file, and it works!
if (getAttribute(importMapScript, 'src')) {
- throw new Error('Import maps with a "src" attribute are not yet supported.');
+ const importMapPath = getAttribute(importMapScript, 'src');
+ const content = fs.readFileSync(importMapPath, 'utf8');
+ setTextContent(importMapScript, content);
+ removeAttribute(importMapScript, 'src');
}
from web.
There might be a good reasons not to support src
.
From MDN https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script/type/importmap
The src, async, nomodule, defer, crossorigin, integrity, and referrerpolicy attributes must not be specified.
Pay attention that src
is specifically mention as not allowed.
At the same time, in the proposal I see the src
being described in https://github.com/wicg/import-maps#import-map-processing
You can install an import map for your application using a <script> element, either inline or with a src="" attribute:
Is there actually a consensus about this feature?
In general we try not to add non-standard features, at least without a good confidence that they will become a standard and got enough support from browser vendors and other stakeholders. In this case I can imagine the src
involves an extra HTTP call which must be a blocking request due to how essential this information is for the module resolution, so maybe that's why it's not implemented natively.
from web.
See WICG/import-maps#235. @domenic wrote that external import maps will be implemented in Chromium, but can't give an ETA.
Import maps can be very large and generated by third-party tools. Inline them manually into HTML is a poor DX.
from web.
Thanks for sharing this link, it does shed some light on this.
I quickly scrolled through and didn't find a confirmation about other browsers vendors, except Chrome. There is a link to a Mozilla/gecko repo where it's also raising an exception for external import maps.
I have a bad feeling about the future of this feature given it's taking already more than 3 years for Chrome and others to implement it, so I'd rather not run ahead of the locomotive.
from web.
Not sure if we had a practice before in Modern Web with experimental feature plugins, maybe that can be a sort of in the middle solution. Curious if @thepassle @Westbrook @koddsson have an idea?
You can also make your own plugin meanwhile and publish it yourself.
from web.
Related Issues (20)
- mergeConfigs should merge objects recursively HOT 1
- Cannot find module web-dev-server.config.mjs
- msw dependency throws error HOT 1
- Browserstack launcher: "WebDriver Error: Timed out waiting for asyncrhonous script" on iOS devices
- [rollup-plugin-html] Expose `html-minifier-terser` options HOT 1
- babel-plugin-istanbul plugin is not identified when running web-test-runner command HOT 4
- Web Test Runner with Playwright-like selectors? HOT 2
- getBoundingClientRect() gives different values on test run vs. in browser HOT 1
- Coverage not generated when we are using babel with custom browser [locally]
- Test Runner config rootPath is resolved relative to cwd, not the path of the config
- Test Runner 'manual' mode import path is not relative to rootPath
- Update @web/dev-server-esbuild dependencie esbuild to v0.21 HOT 2
- Contributing guide uses npm, GitHub actions use Yarn HOT 1
- [@web/test-runner] Tests do not finish when asserting frozen objects
- Node tests failing on Windows
- Out-of-date instruction to use run-playwright-tests HOT 1
- @web/rollup-plugin-import-meta-assets: Types not part of the exports declaration in package.json
- How can I set the browser's locale when using the Web Test Runner with Playwright?
- TypeError: URL.canParse is not a function HOT 1
- [dev-server] CVE-2024-29415: "ip SSRF improper categorization in isPublic" HOT 16
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from web.