Skip to content

Commit 4be6e56

Browse files
authored
Add export fields to manifests to prevent deep imports (#4834)
* Add `export` fields to manifests to prevent deep imports Also made sure to export some utils that may not have been exported before. * fix test polyfills from failing to resolve * fix two test files that were not importing right. * temp workaround to rollup not supporting the exports right * fix gatsby build * workaround for `pnp-esm.test.ts` failing to import * fix imports in `prunedNativeDeps.test.ts` * fix `test-typescript-patch.js` make the `gatsby-node.js` fix more simple. * removed `./command/*` from exports removed `./sync` and `./async` from `@yarnpkg/libzip` Normalized some Command Class names. * remove `types` condition from `exports` export the command from `@yarnpkg/shell` * remove `types` in root and `publishConfig` Typescript can find the type definition files without these helpers.
1 parent 1452383 commit 4be6e56

File tree

82 files changed

+657
-199
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+657
-199
lines changed

.yarn/versions/eceb2ca1.yml

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
releases:
2+
"@yarnpkg/builder": major
3+
"@yarnpkg/cli": major
4+
"@yarnpkg/core": major
5+
"@yarnpkg/doctor": major
6+
"@yarnpkg/eslint-config": minor
7+
"@yarnpkg/extensions": major
8+
"@yarnpkg/fslib": major
9+
"@yarnpkg/libzip": major
10+
"@yarnpkg/nm": major
11+
"@yarnpkg/parsers": major
12+
"@yarnpkg/plugin-compat": major
13+
"@yarnpkg/plugin-constraints": major
14+
"@yarnpkg/plugin-dlx": major
15+
"@yarnpkg/plugin-essentials": major
16+
"@yarnpkg/plugin-exec": major
17+
"@yarnpkg/plugin-file": major
18+
"@yarnpkg/plugin-git": major
19+
"@yarnpkg/plugin-github": major
20+
"@yarnpkg/plugin-http": major
21+
"@yarnpkg/plugin-init": major
22+
"@yarnpkg/plugin-interactive-tools": major
23+
"@yarnpkg/plugin-link": major
24+
"@yarnpkg/plugin-nm": major
25+
"@yarnpkg/plugin-npm": major
26+
"@yarnpkg/plugin-npm-cli": major
27+
"@yarnpkg/plugin-pack": major
28+
"@yarnpkg/plugin-patch": major
29+
"@yarnpkg/plugin-pnp": major
30+
"@yarnpkg/plugin-pnpm": major
31+
"@yarnpkg/plugin-stage": major
32+
"@yarnpkg/plugin-typescript": major
33+
"@yarnpkg/plugin-version": major
34+
"@yarnpkg/plugin-workspace-tools": major
35+
"@yarnpkg/pnp": major
36+
"@yarnpkg/pnpify": major
37+
"@yarnpkg/sdks": major
38+
"@yarnpkg/shell": major
39+
vscode-zipfs: patch

jest.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ module.exports = {
66
`<rootDir>/packages/gatsby/.cache`,
77
`<rootDir>/packages/plugin-compat`,
88
],
9-
setupFiles: [require.resolve(`@yarnpkg/cli/sources/polyfills.ts`)],
9+
setupFiles: [require.resolve(`@yarnpkg/cli/polyfills`)],
1010
testTimeout: 50000,
1111
};

packages/acceptance-tests/pkg-tests-core/package.json

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
"private": true,
44
"license": "BSD-2-Clause",
55
"main": "./sources/index.ts",
6+
"exports": {
7+
".": "./sources/index.ts",
8+
"./package.json": "./package.json"
9+
},
610
"devDependencies": {
711
"@types/finalhandler": "1.1.0",
812
"@types/invariant": "^2.2.30",

packages/acceptance-tests/pkg-tests-specs/package.json

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
"private": true,
44
"license": "BSD-2-Clause",
55
"main": "./sources/index.js",
6+
"exports": {
7+
".": "./sources/index.ts",
8+
"./package.json": "./package.json"
9+
},
610
"repository": {
711
"type": "git",
812
"url": "ssh://[email protected]/yarnpkg/berry.git",

packages/acceptance-tests/pkg-tests-specs/sources/features/prunedNativeDeps.test.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
import {Filename, PortablePath, ppath, xfs} from '@yarnpkg/fslib';
2-
import {RequestType, startRegistryRecording} from 'pkg-tests-core/sources/utils/tests';
1+
import {Filename, PortablePath, ppath, xfs} from '@yarnpkg/fslib';
2+
import {tests} from 'pkg-tests-core';
3+
4+
const {RequestType, startRegistryRecording} = tests;
35

46
export {};
57

packages/eslint-config/package.json

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
"name": "@yarnpkg/eslint-config",
33
"version": "1.0.0-rc.18",
44
"license": "BSD-2-Clause",
5+
"exports": {
6+
".": "./index.js",
7+
"./react": "./react.js"
8+
},
59
"dependencies": {
610
"@rushstack/eslint-patch": "^1.1.0",
711
"@typescript-eslint/eslint-plugin": "^5.3.1",

packages/gatsby/gatsby-plugin-yarn-introspection/gatsby-node.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ exports.sourceNodes = async ({actions, createNodeId, createContentDigest}, opts)
2020
});
2121

2222
const data = await execute([
23-
require.resolve(`@yarnpkg/monorepo/packages/yarnpkg-core/sources/Plugin.ts`),
23+
require.resolve(path.resolve(packageDirectory, `yarnpkg-core/sources/Plugin.ts`)),
2424
...indexList,
2525
]);
2626

packages/plugin-compat/package.json

+8-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
"stableVersion": "3.1.4",
55
"license": "BSD-2-Clause",
66
"main": "./sources/index.ts",
7+
"exports": {
8+
".": "./sources/index.ts",
9+
"./package.json": "./package.json"
10+
},
711
"peerDependencies": {
812
"@yarnpkg/core": "workspace:^",
913
"@yarnpkg/plugin-patch": "workspace:^"
@@ -36,7 +40,10 @@
3640
},
3741
"publishConfig": {
3842
"main": "./lib/index.js",
39-
"typings": "./lib/index.d.ts"
43+
"exports": {
44+
".": "./lib/index.js",
45+
"./package.json": "./package.json"
46+
}
4047
},
4148
"files": [
4249
"/lib/**/*"

packages/plugin-constraints/package.json

+8-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
"directory": "packages/plugin-constraints"
1010
},
1111
"main": "./sources/index.ts",
12+
"exports": {
13+
".": "./sources/index.ts",
14+
"./package.json": "./package.json"
15+
},
1216
"dependencies": {
1317
"@yarnpkg/fslib": "workspace:^",
1418
"clipanion": "^3.2.0-rc.10",
@@ -32,7 +36,10 @@
3236
},
3337
"publishConfig": {
3438
"main": "./lib/index.js",
35-
"typings": "./lib/index.d.ts"
39+
"exports": {
40+
".": "./lib/index.js",
41+
"./package.json": "./package.json"
42+
}
3643
},
3744
"files": [
3845
"/lib/**/*"

packages/plugin-constraints/sources/index.ts

+12-8
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1-
import {Plugin, SettingsType} from '@yarnpkg/core';
2-
import {PortablePath} from '@yarnpkg/fslib';
1+
import {Plugin, SettingsType} from '@yarnpkg/core';
2+
import {PortablePath} from '@yarnpkg/fslib';
33

4-
import queryConstraints from './commands/constraints/query';
5-
import sourceConstraints from './commands/constraints/source';
6-
import constraints from './commands/constraints';
4+
import ConstraintsQueryCommand from './commands/constraints/query';
5+
import ConstraintsSourceCommand from './commands/constraints/source';
6+
import ConstraintsCheckCommand from './commands/constraints';
7+
8+
export {ConstraintsQueryCommand};
9+
export {ConstraintsSourceCommand};
10+
export {ConstraintsCheckCommand};
711

812
declare module '@yarnpkg/core' {
913
interface ConfigurationValueMap {
@@ -20,9 +24,9 @@ const plugin: Plugin = {
2024
},
2125
},
2226
commands: [
23-
queryConstraints,
24-
sourceConstraints,
25-
constraints,
27+
ConstraintsQueryCommand,
28+
ConstraintsSourceCommand,
29+
ConstraintsCheckCommand,
2630
],
2731
};
2832

packages/plugin-dlx/package.json

+8-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
"stableVersion": "3.1.3",
55
"license": "BSD-2-Clause",
66
"main": "./sources/index.ts",
7+
"exports": {
8+
".": "./sources/index.ts",
9+
"./package.json": "./package.json"
10+
},
711
"dependencies": {
812
"@yarnpkg/fslib": "workspace:^",
913
"clipanion": "^3.2.0-rc.10",
@@ -28,7 +32,10 @@
2832
},
2933
"publishConfig": {
3034
"main": "./lib/index.js",
31-
"typings": "./lib/index.d.ts"
35+
"exports": {
36+
".": "./lib/index.js",
37+
"./package.json": "./package.json"
38+
}
3239
},
3340
"files": [
3441
"/lib/**/*"

packages/plugin-dlx/sources/index.ts

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1-
import {Plugin} from '@yarnpkg/core';
1+
import {Plugin} from '@yarnpkg/core';
22

3-
import create from './commands/create';
4-
import dlx from './commands/dlx';
3+
import CreateCommand from './commands/create';
4+
import DlxCommand from './commands/dlx';
5+
6+
export {CreateCommand};
7+
export {DlxCommand};
58

69
const plugin: Plugin = {
710
commands: [
8-
create,
9-
dlx,
11+
CreateCommand,
12+
DlxCommand,
1013
],
1114
};
1215

packages/plugin-essentials/package.json

+8-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
"version": "4.0.0-rc.18",
44
"license": "BSD-2-Clause",
55
"main": "./sources/index.ts",
6+
"exports": {
7+
".": "./sources/index.ts",
8+
"./package.json": "./package.json"
9+
},
610
"dependencies": {
711
"@yarnpkg/fslib": "workspace:^",
812
"@yarnpkg/parsers": "workspace:^",
@@ -39,7 +43,10 @@
3943
},
4044
"publishConfig": {
4145
"main": "./lib/index.js",
42-
"typings": "./lib/index.d.ts"
46+
"exports": {
47+
".": "./lib/index.js",
48+
"./package.json": "./package.json"
49+
}
4350
},
4451
"files": [
4552
"/lib/**/*"

packages/plugin-essentials/sources/commands/plugin/import.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {runInNewContext}
1010
import {getAvailablePlugins} from './list';
1111

1212
// eslint-disable-next-line arca/no-default-export
13-
export default class PluginDlCommand extends BaseCommand {
13+
export default class PluginImportCommand extends BaseCommand {
1414
static paths = [
1515
[`plugin`, `import`],
1616
];

packages/plugin-essentials/sources/commands/plugin/import/sources.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const buildWorkflow = ({pluginName, noMinify}: {noMinify: boolean, pluginName: s
1414
];
1515

1616
// eslint-disable-next-line arca/no-default-export
17-
export default class PluginDlSourcesCommand extends BaseCommand {
17+
export default class PluginImportSourcesCommand extends BaseCommand {
1818
static paths = [
1919
[`plugin`, `import`, `from`, `sources`],
2020
];

packages/plugin-essentials/sources/commands/plugin/list.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export async function getAvailablePlugins(configuration: Configuration, version:
1515
}
1616

1717
// eslint-disable-next-line arca/no-default-export
18-
export default class PluginDlCommand extends BaseCommand {
18+
export default class PluginListCommand extends BaseCommand {
1919
static paths = [
2020
[`plugin`, `list`],
2121
];

packages/plugin-essentials/sources/commands/plugin/runtime.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {Configuration, StreamReport} from '@yarnpkg/core';
33
import {Command, Option, Usage} from 'clipanion';
44

55
// eslint-disable-next-line arca/no-default-export
6-
export default class PluginListCommand extends BaseCommand {
6+
export default class PluginRuntimeCommand extends BaseCommand {
77
static paths = [
88
[`plugin`, `runtime`],
99
];

packages/plugin-essentials/sources/commands/rebuild.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {ThrowReport, structUtils, Project} from '@yarnpkg/core';
44
import {Command, Option, Usage} from 'clipanion';
55

66
// eslint-disable-next-line arca/no-default-export
7-
export default class RunCommand extends BaseCommand {
7+
export default class RebuildCommand extends BaseCommand {
88
static paths = [
99
[`rebuild`],
1010
];

packages/plugin-essentials/sources/commands/runIndex.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {miscUtils} from '@yarnpkg/core';
44
import {inspect} from 'util';
55

66
// eslint-disable-next-line arca/no-default-export
7-
export default class RunCommand extends BaseCommand {
7+
export default class RunIndexCommand extends BaseCommand {
88
static paths = [
99
[`run`],
1010
];

0 commit comments

Comments
 (0)