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

Use package.json#exports #1185

Merged
merged 3 commits into from
Jul 5, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 24 additions & 0 deletions .changeset/healthy-cobras-worry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
"@changesets/get-version-range-type": minor
Copy link
Member Author

Choose a reason for hiding this comment

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

Some of those are in the 0.x range so I could consider using patch for them - it doesn't quite matter for them though anyway so I'm just using minor for every pkg here

"@changesets/assemble-release-plan": minor
"@changesets/get-dependents-graph": minor
"@changesets/apply-release-plan": minor
"@changesets/changelog-github": minor
"@changesets/get-release-plan": minor
"@changesets/get-github-info": minor
"@changesets/changelog-git": minor
"@changesets/release-utils": minor
"@changesets/test-utils": minor
"@changesets/config": minor
"@changesets/errors": minor
"@changesets/logger": minor
"@changesets/parse": minor
"@changesets/types": minor
"@changesets/write": minor
"@changesets/read": minor
"@changesets/cli": minor
"@changesets/git": minor
"@changesets/pre": minor
---

`package.json#exports` have been added to limit what (and how) code might be imported from the package
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"@babel/preset-typescript": "^7.18.6",
"@babel/runtime": "^7.20.1",
"@manypkg/cli": "^0.19.1",
"@preconstruct/cli": "^1.1.26",
"@preconstruct/cli": "^2.8.0",
"@types/fs-extra": "^5.1.0",
"@types/jest": "^24.0.12",
"@types/jest-in-case": "^1.0.6",
Expand All @@ -65,7 +65,7 @@
"jest-junit": "^15.0.0",
"jest-watch-typeahead": "^2.2.1",
"prettier": "^2.7.1",
"typescript": "^4.8.4"
"typescript": "^5.1.6"
},
"preconstruct": {
"packages": [
Expand Down
4 changes: 2 additions & 2 deletions packages/apply-release-plan/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"name": "@changesets/apply-release-plan",
"version": "6.1.4",
"description": "Takes a release plan and applies it to packages",
"main": "dist/apply-release-plan.cjs.js",
"module": "dist/apply-release-plan.esm.js",
"main": "dist/changesets-apply-release-plan.cjs.js",
"module": "dist/changesets-apply-release-plan.esm.js",
Copy link
Contributor

Choose a reason for hiding this comment

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

this field will have no effect. it will be ignored in favor of exports and can be removed

Copy link
Member Author

Choose a reason for hiding this comment

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

It's here to support older bundlers that don't support exports

Copy link
Contributor

Choose a reason for hiding this comment

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

fair, I guess. Though it seems hard to imagine that people are both bundling changeset packages to create their own changeset tools and doing so with a bundler that's that old

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree but this is auto-generated by a somewhat universal library builder ( https://github.com/preconstruct/preconstruct/ ) and for a lot of npm packages it might still make sense to have proper compat with webpack 4 etc.

"license": "MIT",
"repository": "https://github.com/changesets/changesets/tree/main/packages/apply-release-plan",
"dependencies": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
/*
BAD CODE ALERT!

You should never reach out of one package and into another in a multi-package repository.
(doing so is a leading cause of 'works on my machine' but then failure when the packages are published)

We are doing it here to avoide adding a circular dependency and as this is only used in testing.

This is wicked, and please don't copy us.
*/

export { default } from "../../../cli/changelog";
// We are doing it here to avoide adding a circular dependency and as this is only used in testing.
// This is wicked, and please don't copy us.
// eslint-disable-next-line import/no-extraneous-dependencies
export { default } from "@changesets/cli/changelog";
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
/*
BAD CODE ALERT!

You should never reach out of one package and into another in a multi-package repository.
(doing so is a leading cause of 'works on my machine' but then failure when the packages are published)

We are doing it here to avoide adding a circular dependency and as this is only used in testing.

This is wicked, and please don't copy us.
*/

export { default } from "../../../cli/commit";
// We are doing it here to avoide adding a circular dependency and as this is only used in testing.
// This is wicked, and please don't copy us.
// eslint-disable-next-line import/no-extraneous-dependencies
export { default } from "@changesets/cli/commit";
4 changes: 2 additions & 2 deletions packages/assemble-release-plan/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"name": "@changesets/assemble-release-plan",
"version": "5.2.4",
"description": "Reads changesets and adds information on dependents that need bumping",
"main": "dist/assemble-release-plan.cjs.js",
"module": "dist/assemble-release-plan.esm.js",
"main": "dist/changesets-assemble-release-plan.cjs.js",
"module": "dist/changesets-assemble-release-plan.esm.js",
"license": "MIT",
"repository": "https://github.com/changesets/changesets/tree/main/packages/assemble-release-plan",
"dependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/changelog-git/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"name": "@changesets/changelog-git",
"version": "0.1.14",
"description": "A changelog entry generator for git that writes hashes",
"main": "dist/changelog-git.cjs.js",
"module": "dist/changelog-git.esm.js",
"main": "dist/changesets-changelog-git.cjs.js",
"module": "dist/changesets-changelog-git.esm.js",
"license": "MIT",
"repository": "https://github.com/changesets/changesets/tree/main/packages/changelog-git",
"dependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/changelog-github/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"name": "@changesets/changelog-github",
"version": "0.4.8",
"description": "A changelog entry generator for GitHub that links to commits, PRs and users",
"main": "dist/changelog-github.cjs.js",
"module": "dist/changelog-github.esm.js",
"main": "dist/changesets-changelog-github.cjs.js",
"module": "dist/changesets-changelog-github.esm.js",
"license": "MIT",
"repository": "https://github.com/changesets/changesets/tree/main/packages/changelog-github",
"dependencies": {
Expand Down
7 changes: 2 additions & 5 deletions packages/cli/changelog/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
{
"main": "dist/cli.cjs.js",
"module": "dist/cli.esm.js",
"preconstruct": {
"source": "../src/changelog"
}
"main": "dist/changesets-cli-changelog.cjs.js",
"module": "dist/changesets-cli-changelog.esm.js"
}
7 changes: 2 additions & 5 deletions packages/cli/commit/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
{
"main": "dist/cli.cjs.js",
"module": "dist/cli.esm.js",
"preconstruct": {
"source": "../src/commit"
}
"main": "dist/changesets-cli-commit.cjs.js",
"module": "dist/changesets-cli-commit.esm.js"
}
10 changes: 5 additions & 5 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"changelog",
"commit"
],
"main": "dist/cli.cjs.js",
"module": "dist/cli.esm.js",
"main": "dist/changesets-cli.cjs.js",
"module": "dist/changesets-cli.esm.js",
"author": "Changesets Contributors",
"contributors": [
"Ben Conolly",
Expand All @@ -23,9 +23,9 @@
],
"preconstruct": {
"entrypoints": [
".",
"changelog",
"commit"
"./index.ts",
"./changelog.ts",
"./commit/index.ts"
]
},
"license": "MIT",
Expand Down
4 changes: 2 additions & 2 deletions packages/config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"name": "@changesets/config",
"version": "2.3.1",
"description": "Utilities for reading and parsing Changeset's config",
"main": "dist/config.cjs.js",
"module": "dist/config.esm.js",
"main": "dist/changesets-config.cjs.js",
"module": "dist/changesets-config.esm.js",
"license": "MIT",
"repository": "https://github.com/changesets/changesets/tree/main/packages/config",
"files": [
Expand Down
4 changes: 2 additions & 2 deletions packages/errors/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"name": "@changesets/errors",
"version": "0.1.4",
"description": "Error classes for @changesets",
"main": "dist/errors.cjs.js",
"module": "dist/errors.esm.js",
"main": "dist/changesets-errors.cjs.js",
"module": "dist/changesets-errors.esm.js",
"license": "MIT",
"repository": "https://github.com/changesets/changesets/tree/main/packages/errors",
"dependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/get-dependents-graph/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"name": "@changesets/get-dependents-graph",
"version": "1.3.6",
"description": "Get the graph of dependents in a monorepo",
"main": "dist/get-dependents-graph.cjs.js",
"module": "dist/get-dependents-graph.esm.js",
"main": "dist/changesets-get-dependents-graph.cjs.js",
"module": "dist/changesets-get-dependents-graph.esm.js",
"license": "MIT",
"repository": "https://github.com/changesets/changesets/tree/main/packages/get-dependents-graph",
"dependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/get-github-info/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"name": "@changesets/get-github-info",
"version": "0.5.2",
"description": "Get the GitHub username and PR number from a commit. Intended for use with changesets.",
"main": "dist/get-github-info.cjs.js",
"module": "dist/get-github-info.esm.js",
"main": "dist/changesets-get-github-info.cjs.js",
"module": "dist/changesets-get-github-info.esm.js",
"license": "MIT",
"repository": "https://github.com/changesets/changesets/tree/main/packages/get-github-info",
"dependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/get-release-plan/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"name": "@changesets/get-release-plan",
"version": "3.0.17",
"description": "Reads changesets and adds information on dependents that need bumping",
"main": "dist/get-release-plan.cjs.js",
"module": "dist/get-release-plan.esm.js",
"main": "dist/changesets-get-release-plan.cjs.js",
"module": "dist/changesets-get-release-plan.esm.js",
"license": "MIT",
"repository": "https://github.com/changesets/changesets/tree/main/packages/get-release-plan",
"dependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/get-version-range-type/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"name": "@changesets/get-version-range-type",
"version": "0.3.2",
"description": "Common get-version-range-type shared between changeset packages",
"main": "dist/get-version-range-type.cjs.js",
"module": "dist/get-version-range-type.esm.js",
"main": "dist/changesets-get-version-range-type.cjs.js",
"module": "dist/changesets-get-version-range-type.esm.js",
"license": "MIT",
"repository": "https://github.com/changesets/changesets/tree/main/packages/get-version-range-type"
}
4 changes: 2 additions & 2 deletions packages/git/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"name": "@changesets/git",
"version": "2.0.0",
"description": "Some git helpers that changesets use to get information",
"main": "dist/git.cjs.js",
"module": "dist/git.esm.js",
"main": "dist/changesets-git.cjs.js",
"module": "dist/changesets-git.esm.js",
"license": "MIT",
"repository": "https://github.com/changesets/changesets/tree/main/packages/git",
"dependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/logger/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"name": "@changesets/logger",
"version": "0.0.5",
"description": "Console log alias",
"main": "dist/logger.cjs.js",
"module": "dist/logger.esm.js",
"main": "dist/changesets-logger.cjs.js",
"module": "dist/changesets-logger.esm.js",
"license": "MIT",
"repository": "https://github.com/changesets/changesets/tree/main/packages/logger",
"dependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/parse/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"name": "@changesets/parse",
"version": "0.3.16",
"description": "Parse a changeset file's contents into a usable json object",
"main": "dist/parse.cjs.js",
"module": "dist/parse.esm.js",
"main": "dist/changesets-parse.cjs.js",
"module": "dist/changesets-parse.esm.js",
"license": "MIT",
"repository": "https://github.com/changesets/changesets/tree/main/packages/parse",
"dependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/pre/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"name": "@changesets/pre",
"version": "1.0.14",
"description": "Utils to make a Changesets repo enter and exit pre mode",
"main": "dist/pre.cjs.js",
"module": "dist/pre.esm.js",
"main": "dist/changesets-pre.cjs.js",
"module": "dist/changesets-pre.esm.js",
"license": "MIT",
"repository": "https://github.com/changesets/changesets/tree/main/packages/pre",
"dependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/read/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"name": "@changesets/read",
"version": "0.5.9",
"description": "Read changesets from disc, and return the information as JSON",
"main": "dist/read.cjs.js",
"module": "dist/read.esm.js",
"main": "dist/changesets-read.cjs.js",
"module": "dist/changesets-read.esm.js",
"license": "MIT",
"repository": "https://github.com/changesets/changesets/tree/main/packages/read",
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/release-utils/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@changesets/release-utils",
"version": "0.1.13",
"main": "dist/release-utils.cjs.js",
"main": "dist/changesets-release-utils.cjs.js",
"dependencies": {
"@changesets/pre": "^1.0.14",
"@changesets/read": "^0.5.9",
Expand Down
4 changes: 2 additions & 2 deletions packages/types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"name": "@changesets/types",
"version": "5.2.1",
"description": "Common types shared between changeset packages",
"main": "dist/types.cjs.js",
"module": "dist/types.esm.js",
"main": "dist/changesets-types.cjs.js",
"module": "dist/changesets-types.esm.js",
"license": "MIT",
"repository": "https://github.com/changesets/changesets/tree/main/packages/types"
}
4 changes: 2 additions & 2 deletions packages/write/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"name": "@changesets/write",
"version": "0.2.3",
"description": "Writes a changeset to a file",
"main": "dist/write.cjs.js",
"module": "dist/write.esm.js",
"main": "dist/changesets-write.cjs.js",
"module": "dist/changesets-write.esm.js",
"license": "MIT",
"repository": "https://github.com/changesets/changesets/tree/main/packages/write",
"dependencies": {
Expand Down
4 changes: 2 additions & 2 deletions scripts/test-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"version": "0.0.5",
"private": true,
"description": "Utils for testing changesets packages",
"main": "dist/test-utils.cjs.js",
"module": "dist/test-utils.esm.js",
"main": "dist/changesets-test-utils.cjs.js",
"module": "dist/changesets-test-utils.esm.js",
"license": "MIT",
"repository": "https://github.com/changesets/changesets/tree/main/packages/test-utils",
"dependencies": {
Expand Down
63 changes: 5 additions & 58 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,64 +1,11 @@
{
"compilerOptions": {
/* Basic Options */
"target": "esnext" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */,
"module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */,
"target": "esnext",
"module": "commonjs",
"moduleResolution": "node",
"esModuleInterop": true,
"resolveJsonModule": true,
// "lib": [], /* Specify library files to be included in the compilation. */
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
// "declaration": true, /* Generates corresponding '.d.ts' file. */
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
// "sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
// "outDir": "./", /* Redirect output structure to the directory. */
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "composite": true, /* Enable project compilation */
// "incremental": true, /* Enable incremental compilation */
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
// "removeComments": true, /* Do not emit comments to output. */
// "noEmit": true, /* Do not emit outputs. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */

/* Strict Type-Checking Options */
"strict": true /* Enable all strict type-checking options. */,
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */

/* Additional Checks */
// "noUnusedLocals": true, /* Report errors on unused locals. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */

/* Module Resolution Options */
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
// "typeRoots": [], /* List of folders to include type definitions from. */
// "types": [], /* Type declaration files to be included in compilation. */
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */

/* Source Map Options */
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */

/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
"strict": true,
"noEmit": true
}
}