jsenv / importmap-node-module

Generate importmap for node_modules
35 stars 4 forks source link

Reintroduce inputImportMapFileRelativeUrl #18

Closed dmail closed 4 years ago

dmail commented 4 years ago

I imagine something like this:

import-map-custom.importmap

{
  "imports": {
    "foo": "./bar.js"
  }
}

Then generate-import-map would be like this:

script/generate-import-map/generate-import-map.js

import { readFileSync } from "fs"
import { composeTwoImportMaps } from '@jsenv/import-map'
import { generateImportMapForProjectPackage } from "@jsenv/node-module-import-map"

const importMapForNodeModules = await generateImportMapForProjectPackage()
const importMap = composeTwoImportMaps(importMapForNodeModules, JSON.parse(readFileSync('./import-map-custom.importmap')))
writeFileSync('./import-map.importmap', JSON.stringify(importMap))

To simplify this, let's add a new parameter to generateImportMapForProjectPackage like customImportMapFileRelativeUrl

dmail commented 4 years ago

Done in 12.0.0 that is introducing generateImportMapForProject and importMapInputs