package.json exports: export file from other module

Is there a way for a package to export a file from another package directly? Something along the lines of;
// package.json
{
"name": "my-package",
"exports": {
"./foo.js": {
"default": "@org/pkg/foo.js"
}
}
}
// package.json
{
"name": "my-package",
"exports": {
"./foo.js": {
"default": "@org/pkg/foo.js"
}
}
}
Ideally I don't want to have files like;
export * from "@org/pkg/foo.js";
export * from "@org/pkg/foo.js";
The end result is users of the package can import from my-package, but actually be delivered files from @org/pkg;
// both grab the file at `node_modules/@org/pkg/.../foo.js`
import stuff from "my-package/foo.js";
import stuff from "@org/pkg/foo.js";
// both grab the file at `node_modules/@org/pkg/.../foo.js`
import stuff from "my-package/foo.js";
import stuff from "@org/pkg/foo.js";
My reason for doing this is I want one package in a monorepo to depend on & forward several other packages, this way users can grab everything from main-package/* rather than needing to grab from a several different packages.
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server