Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add export fields to manifests to prevent deep imports #4834

Merged
merged 11 commits into from
Sep 15, 2022
39 changes: 39 additions & 0 deletions .yarn/versions/eceb2ca1.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
releases:
"@yarnpkg/builder": major
"@yarnpkg/cli": major
"@yarnpkg/core": major
"@yarnpkg/doctor": major
"@yarnpkg/eslint-config": minor
"@yarnpkg/extensions": major
"@yarnpkg/fslib": major
"@yarnpkg/libzip": major
"@yarnpkg/nm": major
"@yarnpkg/parsers": major
"@yarnpkg/plugin-compat": major
"@yarnpkg/plugin-constraints": major
"@yarnpkg/plugin-dlx": major
"@yarnpkg/plugin-essentials": major
"@yarnpkg/plugin-exec": major
"@yarnpkg/plugin-file": major
"@yarnpkg/plugin-git": major
"@yarnpkg/plugin-github": major
"@yarnpkg/plugin-http": major
"@yarnpkg/plugin-init": major
"@yarnpkg/plugin-interactive-tools": major
"@yarnpkg/plugin-link": major
"@yarnpkg/plugin-nm": major
"@yarnpkg/plugin-npm": major
"@yarnpkg/plugin-npm-cli": major
"@yarnpkg/plugin-pack": major
"@yarnpkg/plugin-patch": major
"@yarnpkg/plugin-pnp": major
"@yarnpkg/plugin-pnpm": major
"@yarnpkg/plugin-stage": major
"@yarnpkg/plugin-typescript": major
"@yarnpkg/plugin-version": major
"@yarnpkg/plugin-workspace-tools": major
"@yarnpkg/pnp": major
"@yarnpkg/pnpify": major
"@yarnpkg/sdks": major
"@yarnpkg/shell": major
vscode-zipfs: patch
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ module.exports = {
`<rootDir>/packages/gatsby/.cache`,
`<rootDir>/packages/plugin-compat`,
],
setupFiles: [require.resolve(`@yarnpkg/cli/sources/polyfills.ts`)],
setupFiles: [require.resolve(`@yarnpkg/cli/polyfills`)],
testTimeout: 50000,
};
4 changes: 4 additions & 0 deletions packages/acceptance-tests/pkg-tests-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
"private": true,
"license": "BSD-2-Clause",
"main": "./sources/index.ts",
"exports": {
".": "./sources/index.ts",
"./package.json": "./package.json"
},
"devDependencies": {
"@types/finalhandler": "1.1.0",
"@types/invariant": "^2.2.30",
Expand Down
4 changes: 4 additions & 0 deletions packages/acceptance-tests/pkg-tests-specs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
"private": true,
"license": "BSD-2-Clause",
"main": "./sources/index.js",
"exports": {
".": "./sources/index.ts",
"./package.json": "./package.json"
},
"repository": {
"type": "git",
"url": "ssh://[email protected]/yarnpkg/berry.git",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import {Filename, PortablePath, ppath, xfs} from '@yarnpkg/fslib';
import {RequestType, startRegistryRecording} from 'pkg-tests-core/sources/utils/tests';
import {Filename, PortablePath, ppath, xfs} from '@yarnpkg/fslib';
import {tests} from 'pkg-tests-core';

const {RequestType, startRegistryRecording} = tests;

export {};

Expand Down
4 changes: 4 additions & 0 deletions packages/eslint-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
"name": "@yarnpkg/eslint-config",
"version": "1.0.0-rc.18",
"license": "BSD-2-Clause",
"exports": {
".": "./index.js",
"./react": "./react.js"
},
"dependencies": {
"@rushstack/eslint-patch": "^1.1.0",
"@typescript-eslint/eslint-plugin": "^5.3.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ exports.sourceNodes = async ({actions, createNodeId, createContentDigest}, opts)
});

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

Expand Down
9 changes: 8 additions & 1 deletion packages/plugin-compat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
"stableVersion": "3.1.4",
"license": "BSD-2-Clause",
"main": "./sources/index.ts",
"exports": {
".": "./sources/index.ts",
"./package.json": "./package.json"
},
"peerDependencies": {
"@yarnpkg/core": "workspace:^",
"@yarnpkg/plugin-patch": "workspace:^"
Expand Down Expand Up @@ -36,7 +40,10 @@
},
"publishConfig": {
"main": "./lib/index.js",
"typings": "./lib/index.d.ts"
"exports": {
".": "./lib/index.js",
"./package.json": "./package.json"
}
},
"files": [
"/lib/**/*"
Expand Down
9 changes: 8 additions & 1 deletion packages/plugin-constraints/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
"directory": "packages/plugin-constraints"
},
"main": "./sources/index.ts",
"exports": {
".": "./sources/index.ts",
"./package.json": "./package.json"
},
"dependencies": {
"@yarnpkg/fslib": "workspace:^",
"clipanion": "^3.2.0-rc.10",
Expand All @@ -32,7 +36,10 @@
},
"publishConfig": {
"main": "./lib/index.js",
"typings": "./lib/index.d.ts"
"exports": {
".": "./lib/index.js",
"./package.json": "./package.json"
}
},
"files": [
"/lib/**/*"
Expand Down
20 changes: 12 additions & 8 deletions packages/plugin-constraints/sources/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import {Plugin, SettingsType} from '@yarnpkg/core';
import {PortablePath} from '@yarnpkg/fslib';
import {Plugin, SettingsType} from '@yarnpkg/core';
import {PortablePath} from '@yarnpkg/fslib';

import queryConstraints from './commands/constraints/query';
import sourceConstraints from './commands/constraints/source';
import constraints from './commands/constraints';
import ConstraintsQueryCommand from './commands/constraints/query';
import ConstraintsSourceCommand from './commands/constraints/source';
import ConstraintsCheckCommand from './commands/constraints';

export {ConstraintsQueryCommand};
export {ConstraintsSourceCommand};
export {ConstraintsCheckCommand};

declare module '@yarnpkg/core' {
interface ConfigurationValueMap {
Expand All @@ -20,9 +24,9 @@ const plugin: Plugin = {
},
},
commands: [
queryConstraints,
sourceConstraints,
constraints,
ConstraintsQueryCommand,
ConstraintsSourceCommand,
ConstraintsCheckCommand,
],
};

Expand Down
9 changes: 8 additions & 1 deletion packages/plugin-dlx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
"stableVersion": "3.1.3",
"license": "BSD-2-Clause",
"main": "./sources/index.ts",
"exports": {
".": "./sources/index.ts",
"./package.json": "./package.json"
},
"dependencies": {
"@yarnpkg/fslib": "workspace:^",
"clipanion": "^3.2.0-rc.10",
Expand All @@ -28,7 +32,10 @@
},
"publishConfig": {
"main": "./lib/index.js",
"typings": "./lib/index.d.ts"
"exports": {
".": "./lib/index.js",
"./package.json": "./package.json"
}
},
"files": [
"/lib/**/*"
Expand Down
13 changes: 8 additions & 5 deletions packages/plugin-dlx/sources/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import {Plugin} from '@yarnpkg/core';
import {Plugin} from '@yarnpkg/core';

import create from './commands/create';
import dlx from './commands/dlx';
import CreateCommand from './commands/create';
import DlxCommand from './commands/dlx';

export {CreateCommand};
export {DlxCommand};

const plugin: Plugin = {
commands: [
create,
dlx,
CreateCommand,
DlxCommand,
],
};

Expand Down
9 changes: 8 additions & 1 deletion packages/plugin-essentials/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
"version": "4.0.0-rc.18",
"license": "BSD-2-Clause",
"main": "./sources/index.ts",
"exports": {
".": "./sources/index.ts",
"./package.json": "./package.json"
},
"dependencies": {
"@yarnpkg/fslib": "workspace:^",
"@yarnpkg/parsers": "workspace:^",
Expand Down Expand Up @@ -39,7 +43,10 @@
},
"publishConfig": {
"main": "./lib/index.js",
"typings": "./lib/index.d.ts"
"exports": {
".": "./lib/index.js",
"./package.json": "./package.json"
}
},
"files": [
"/lib/**/*"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {runInNewContext}
import {getAvailablePlugins} from './list';

// eslint-disable-next-line arca/no-default-export
export default class PluginDlCommand extends BaseCommand {
export default class PluginImportCommand extends BaseCommand {
static paths = [
[`plugin`, `import`],
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const buildWorkflow = ({pluginName, noMinify}: {noMinify: boolean, pluginName: s
];

// eslint-disable-next-line arca/no-default-export
export default class PluginDlSourcesCommand extends BaseCommand {
export default class PluginImportSourcesCommand extends BaseCommand {
static paths = [
[`plugin`, `import`, `from`, `sources`],
];
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-essentials/sources/commands/plugin/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export async function getAvailablePlugins(configuration: Configuration, version:
}

// eslint-disable-next-line arca/no-default-export
export default class PluginDlCommand extends BaseCommand {
export default class PluginListCommand extends BaseCommand {
static paths = [
[`plugin`, `list`],
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {Configuration, StreamReport} from '@yarnpkg/core';
import {Command, Option, Usage} from 'clipanion';

// eslint-disable-next-line arca/no-default-export
export default class PluginListCommand extends BaseCommand {
export default class PluginRuntimeCommand extends BaseCommand {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for cleaning all this, btw!

static paths = [
[`plugin`, `runtime`],
];
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-essentials/sources/commands/rebuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {ThrowReport, structUtils, Project} from '@yarnpkg/core';
import {Command, Option, Usage} from 'clipanion';

// eslint-disable-next-line arca/no-default-export
export default class RunCommand extends BaseCommand {
export default class RebuildCommand extends BaseCommand {
static paths = [
[`rebuild`],
];
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-essentials/sources/commands/runIndex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {miscUtils} from '@yarnpkg/core';
import {inspect} from 'util';

// eslint-disable-next-line arca/no-default-export
export default class RunCommand extends BaseCommand {
export default class RunIndexCommand extends BaseCommand {
static paths = [
[`run`],
];
Expand Down
Loading