jsenv / importmap-node-module

Generate importmap for node_modules
33 stars 4 forks source link

Use param to get entry point file #48

Closed dmail closed 2 years ago

dmail commented 2 years ago

Currently the entry point of the project is resolved from package.json for each importmap file. It works fine but it's a bit "magic" so I would prefer to pass it explicitely.

import { writeImportMapFiles } from "@jsenv/importmap-node-module"

await writeImportMapFiles({
  projectDirectoryUrl: new URL("./", import.meta.url),
  importMapFiles: {
    "./dev.importmap": {
      mappingsForNodeResolution: true,
      packageUserConditions: ["development"],
+     entryPoint: "./main.js"
    },
    "./prod.importmap": {
      mappingsForNodeResolution: true,
      packageUserConditions: ["production"],
+     entryPoint: "./main_prod.js"
    },
  },
})