0.2.0 • Published 3 years ago

@estack/resolve-id v0.2.0

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

@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.