Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .yarn/versions/2be36fd1.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
releases:
"@yarnpkg/core": minor
"@yarnpkg/plugin-pack": minor

declined:
- "@yarnpkg/plugin-compat"
- "@yarnpkg/plugin-constraints"
- "@yarnpkg/plugin-dlx"
- "@yarnpkg/plugin-essentials"
- "@yarnpkg/plugin-exec"
- "@yarnpkg/plugin-file"
- "@yarnpkg/plugin-git"
- "@yarnpkg/plugin-github"
- "@yarnpkg/plugin-http"
- "@yarnpkg/plugin-init"
- "@yarnpkg/plugin-interactive-tools"
- "@yarnpkg/plugin-link"
- "@yarnpkg/plugin-nm"
- "@yarnpkg/plugin-npm"
- "@yarnpkg/plugin-npm-cli"
- "@yarnpkg/plugin-patch"
- "@yarnpkg/plugin-pnp"
- "@yarnpkg/plugin-pnpm"
- "@yarnpkg/plugin-stage"
- "@yarnpkg/plugin-typescript"
- "@yarnpkg/plugin-version"
- "@yarnpkg/plugin-workspace-tools"
- "@yarnpkg/builder"
- "@yarnpkg/cli"
- "@yarnpkg/doctor"
- "@yarnpkg/nm"
- "@yarnpkg/pnpify"
- "@yarnpkg/sdks"
Original file line number Diff line number Diff line change
Expand Up @@ -298,13 +298,19 @@ describe(`Commands`, () => {
);

test(
`it should override main and module in the packed manifest`,
`it should override fields in the packed manifest`,
makeTemporaryEnv({
type: `commonjs`,
main: `./index.js`,
module: `./index.mjs`,
browser: `./index.umd.js`,
exports: `./index.modern.js`,
publishConfig: {
type: `module`,
main: `./published.js`,
module: `./published.mjs`,
browser: `./published.umd.js`,
exports: `./published.modern.js`,
},
}, async ({path, run, source}) => {
await run(`install`);
Expand All @@ -314,13 +320,19 @@ describe(`Commands`, () => {

const packedManifest = await fsUtils.readJson(`${path}/package/package.json`);

expect(packedManifest.type).toBe(`module`);
expect(packedManifest.main).toBe(`./published.js`);
expect(packedManifest.module).toBe(`./published.mjs`);
expect(packedManifest.browser).toBe(`./published.umd.js`);
expect(packedManifest.exports).toBe(`./published.modern.js`);

const originalManifest = await fsUtils.readJson(`${path}/package.json`);

expect(originalManifest.type).toBe(`commonjs`);
expect(originalManifest.main).toBe(`./index.js`);
expect(originalManifest.module).toBe(`./index.mjs`);
expect(originalManifest.browser).toBe(`./index.umd.js`);
expect(originalManifest.exports).toBe(`./index.modern.js`);
}),
);

Expand Down
5 changes: 5 additions & 0 deletions packages/gatsby/static/configuration/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,11 @@
"enum": ["public", "restricted"],
"examples": ["public"]
},
"type": {
"description": "Same principle as the `publishConfig.type` property; this value will be used instead of the top-level `type` field when generating the workspace tarball.",
"type": "string",
"enum": ["commonjs", "module"]
},
"bin": {
"description": "If present, the top-level `bin` field from the manifest will be set to this new value before the package is packed to be shipped to remote registries. This won't modify the real manifest, just the one stored within the tarball.",
"type": "string",
Expand Down
3 changes: 3 additions & 0 deletions packages/plugin-pack/sources/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ const WORKSPACE_PROTOCOL = `workspace:`;

const beforeWorkspacePacking = (workspace: Workspace, rawManifest: any) => {
if (rawManifest.publishConfig) {
if (rawManifest.publishConfig.type)
rawManifest.type = rawManifest.publishConfig.type;

if (rawManifest.publishConfig.main)
rawManifest.main = rawManifest.publishConfig.main;

Expand Down
1 change: 1 addition & 0 deletions packages/yarnpkg-core/sources/Manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export interface PublishConfig {
access?: string;
main?: PortablePath;
module?: PortablePath;
type?: string;
browser?: PortablePath | Map<PortablePath, boolean | PortablePath>;
bin?: Map<string, PortablePath>;
registry?: string;
Expand Down