@estack/resolve-id
v0.2.0
Published
dev-server to create applications, sites or prototypes using only JS, HTML and CSS, No transpilation.
Downloads
5
Readme
@estack/resolve-id
Thanks to the es-module-lexer library, it allows the replacement of modules associated with code fragments.
It is with the objective of modifying the import
Usage
import { resolveId } from "@estack/resolve-id";
const code = `
import {deep} from "dep-1";
import {deep} from "dep-2";
`;
resolveId({
code,
resolve(dep) {
switch (deep) {
case "dep-1":
return "./dep-1.js";
case "dep-2":
return "./dep-1.js";
default:
return deep;
}
},
});
resolve
can be asynchronous.
Todo
[ ] Improve the resolution of dinamic import. [ ] Associate url import of assets.