Open joeftiger opened 1 month ago
If anyone is running into the same problem right now, my current workaround is the following code snippet to (dirtily) cut out peer dependencies:
const importMap = JSON.parse(Deno.readTextFileSync("./deno.json"));
const blocklyVersion = (<string>importMap["imports"]["blockly"]).split("@")[1];
delete importMap["imports"]["blockly"];
Deno.writeTextFileSync("./deno-npm.json", JSON.stringify(importMap, null, 2));
/// ...
await build({
// ...
package: {
// ...
peerDependencies: {
blockly: blocklyVersion,
},
},
importMap: "./deno-npm.json",
});
Hello
I noticed that NPM imports inside
deno.json
cannot be specified as a peer dependency using@deno/dnt
and always end up insidedependencies
. When specifying the import usingesm.sh/
it works, however.Minimal example using Blockly as dependency:
deno.json
:mod.ts
:build_npm.ts
:Replacing the import with the
esm.sh/
version correctly transformsblockly
as peer dependency while using thenpm:
version keeps it as direct dependency.As a workaround one has to keep a separate import map or manually specify dependencies inside
package
in the build script.