Encourage Explicit Import Paths for Better Compatibility and Predictability #4587
Unanswered
jimmywarting
asked this question in
5. Bugs
Replies: 1 comment 2 replies
-
I know it's not the point of the issue but you should use a cdn to build your own bundle. Deno supports npm and I suspect it will be okay if you pull your file locally. If it's for code running in the browser, you shouldn't use the source code but the file in the dist folder. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Title:
Description:
When using Alpine.js via a CDN (e.g., jsDelivr), importing modules without explicit file extensions may lead to issues. For example, attempting to import the CSP build results in a 404 error:
This error occurs because Alpine.js includes module imports without explicitly specifying file extensions. Some runtime environments and CDNs, including Deno, enforce stricter module resolution and do not guess the correct extension.
Example Error:
Suggested Solution:
.js
in all import paths, e.g.:javascript import Alpine from './index.js';
Ryan dhal did regreted the hole module resolver thinking index was cute, but oh so wrong he was. it adds complexity to a simple solution that don't even work in the browser/esm. It gets harder to make the switch by refactoring code to esm. paths need to be guessed/looked up: did you meant to import
foo.js
orfoo/index.js
? Remote path resolver don't have this luxury where it dose not have direct access to the harddrive and can't lookup the file that is needed.Beta Was this translation helpful? Give feedback.
All reactions