Skip to content

Commit

Permalink
Explicitly mark all packages with commonjs type
Browse files Browse the repository at this point in the history
See: https://nodejs.org/api/packages.html#packages_determining_module_system

> Package authors should include the "type" field, even in packages where all sources are CommonJS. Being explicit about the type of the package will future-proof the package in case the default type of Node.js ever changes, and it will also make things easier for build tools and loaders to determine how the files in the package should be interpreted.

Related issue: #2341
  • Loading branch information
mrtnzlml committed May 21, 2021
1 parent 31d99b3 commit 484d88e
Show file tree
Hide file tree
Showing 27 changed files with 36 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/babel-plugin-transform-sx-tailwind/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"private": false,
"version": "0.18.0",
"main": "./src/index.js",
"type": "commonjs",
"sideEffects": false,
"dependencies": {
"@adeira/murmur-hash": "^2.0.0",
Expand Down
1 change: 1 addition & 0 deletions src/babel-preset-adeira/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"license": "MIT",
"version": "3.0.0",
"main": "./src/index.js",
"type": "commonjs",
"sideEffects": false,
"dependencies": {
"@babel/plugin-proposal-class-properties": "^7.12.13",
Expand Down
1 change: 1 addition & 0 deletions src/css-colors/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"sideEffects": false,
"private": false,
"main": "./src/index.js",
"type": "commonjs",
"license": "MIT",
"dependencies": {
"@adeira/js": "^2.1.0",
Expand Down
1 change: 1 addition & 0 deletions src/eslint-config-adeira/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"private": false,
"version": "6.0.0",
"main": "./index.js",
"type": "commonjs",
"sideEffects": false,
"dependencies": {
"@babel/runtime": "^7.14.0",
Expand Down
1 change: 1 addition & 0 deletions src/eslint-fixtures-tester/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"homepage": "https://github.com/adeira/universe/tree/master/src/eslint-fixtures-tester",
"version": "0.1.0",
"main": "./src/index.js",
"type": "commonjs",
"license": "MIT",
"private": false,
"dependencies": {
Expand Down
1 change: 1 addition & 0 deletions src/eslint-plugin-adeira/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"private": false,
"version": "0.13.0",
"main": "./src/index.js",
"type": "commonjs",
"sideEffects": false,
"dependencies": {
"@babel/runtime": "^7.14.0",
Expand Down
1 change: 1 addition & 0 deletions src/eslint-plugin-sx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"eslint-plugin"
],
"main": "./src/index.js",
"type": "commonjs",
"dependencies": {
"@babel/runtime": "^7.14.0"
},
Expand Down
1 change: 1 addition & 0 deletions src/fetch/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"license": "MIT",
"version": "2.1.0",
"main": "./src/fetchWithRetries.js",
"type": "commonjs",
"sideEffects": false,
"homepage": "https://github.com/adeira/universe/tree/master/src/fetch",
"description": "Production ready fetch function with advanced capabilities like retries with delay and request cancellation after timeout.",
Expand Down
1 change: 1 addition & 0 deletions src/fixtures-tester/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"private": false,
"version": "1.0.1",
"main": "./src/index.js",
"type": "commonjs",
"sideEffects": false,
"dependencies": {
"@adeira/js": "^2.1.0",
Expand Down
1 change: 1 addition & 0 deletions src/flow-config-parser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"private": false,
"license": "MIT",
"main": "./src/index.js",
"type": "commonjs",
"dependencies": {
"@adeira/fixtures-tester": "^1.0.1",
"@adeira/js": "^2.1.0",
Expand Down
1 change: 1 addition & 0 deletions src/flow-types-eslint/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"version": "0.0.0",
"private": true,
"main": "./src/index.js",
"type": "commonjs",
"license": "MIT",
"dependencies": {}
}
1 change: 1 addition & 0 deletions src/graphql-bc-checker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"private": false,
"version": "0.3.0",
"main": "./src/index.js",
"type": "commonjs",
"sideEffects": false,
"dependencies": {
"@adeira/signed-source": "^2.0.0",
Expand Down
1 change: 1 addition & 0 deletions src/graphql-global-id/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"private": false,
"version": "2.0.1",
"main": "./src/index.js",
"type": "commonjs",
"sideEffects": false,
"dependencies": {
"@adeira/js": "^2.1.0",
Expand Down
1 change: 1 addition & 0 deletions src/graphql-relay-fauna/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"private": false,
"version": "0.3.0",
"main": "./src/index.js",
"type": "commonjs",
"sideEffects": false,
"homepage": "https://github.com/adeira/universe/tree/master/src/graphql-relay-fauna",
"description": "Helpers for Relay compliant GraphQL server with FaunaDB backend",
Expand Down
1 change: 1 addition & 0 deletions src/graphql-relay/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"url": "http://github.com/adeira/universe.git"
},
"main": "./src/index.js",
"type": "commonjs",
"peerDependencies": {
"graphql": "^15.0.0"
},
Expand Down
1 change: 1 addition & 0 deletions src/graphql-resolve-wrapper/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"private": false,
"version": "0.3.0",
"main": "./src/index.js",
"type": "commonjs",
"sideEffects": false,
"dependencies": {
"@babel/runtime": "^7.14.0"
Expand Down
1 change: 1 addition & 0 deletions src/js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"private": false,
"version": "2.1.0",
"main": "./src/index.js",
"type": "commonjs",
"sideEffects": false,
"dependencies": {
"@babel/runtime": "^7.14.0"
Expand Down
1 change: 1 addition & 0 deletions src/monorepo-npm-publisher/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"private": false,
"version": "2.0.0",
"main": "./src/index.js",
"type": "commonjs",
"sideEffects": false,
"dependencies": {
"@adeira/babel-preset-adeira": "^3.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,22 @@ Workspaces.iterateWorkspaces((packageJSONLocation) => {
test(`${packageJson.name}`, () => {
const dirname = path.dirname(packageJSONLocation);
const main = packageJson.main;
const type = packageJson.type;

if (main != null) {
const mainEntrypoint = path.join(dirname, main);
// $FlowIssue[incompatible-call]: https://github.com/facebook/flow/issues/3018
expect(fs.existsSync(mainEntrypoint)).toGiveHelp(
`The file specified in main field does not exist (${mainEntrypoint}). If this is intentional, you can remove this field from package.json`,
);

expect(type != null).toGiveHelp(
`Each package must specify "type" to be either "commonjs" or "module".`,
);

expect(['commonjs', 'module'].includes(type)).toGiveHelp(
`Package type must be either "commonjs" or "module" (given "${type}").`,
);
}
});
});
1 change: 1 addition & 0 deletions src/monorepo-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"private": false,
"version": "0.11.0",
"main": "./src/index.js",
"type": "commonjs",
"sideEffects": false,
"bin": {
"monorepo-babel-node": "bin/monorepo-babel-node.js",
Expand Down
1 change: 1 addition & 0 deletions src/murmur-hash/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"private": false,
"version": "2.0.0",
"main": "./src/murmurHash.js",
"type": "commonjs",
"sideEffects": false,
"dependencies": {
"@babel/runtime": "^7.14.0"
Expand Down
1 change: 1 addition & 0 deletions src/relay/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"private": false,
"version": "3.2.4",
"main": "./src/index.js",
"type": "commonjs",
"sideEffects": false,
"homepage": "https://github.com/adeira/universe/tree/master/src/relay",
"description": "Opinionated wrapper around Relay - a JavaScript framework for building data-driven React applications",
Expand Down
1 change: 1 addition & 0 deletions src/signed-source/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"private": false,
"version": "2.0.0",
"main": "./src/SignedSource.js",
"type": "commonjs",
"sideEffects": false,
"dependencies": {
"@babel/runtime": "^7.14.0"
Expand Down
1 change: 1 addition & 0 deletions src/sx-design/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"private": false,
"version": "0.10.0",
"main": "./index.js",
"type": "commonjs",
"sideEffects": false,
"dependencies": {
"@adeira/js": "^2.1.0",
Expand Down
1 change: 1 addition & 0 deletions src/sx-jest-snapshot-serializer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"private": false,
"version": "0.1.0",
"main": "./index.js",
"type": "commonjs",
"sideEffects": true,
"dependencies": {
"@adeira/sx": "^0.25.0",
Expand Down
1 change: 1 addition & 0 deletions src/sx-tailwind/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"private": false,
"version": "0.12.0",
"main": "./index.js",
"type": "commonjs",
"sideEffects": false,
"dependencies": {
"@adeira/js": "^2.1.0",
Expand Down
1 change: 1 addition & 0 deletions src/sx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"private": false,
"version": "0.25.0",
"main": "./index.js",
"type": "commonjs",
"sideEffects": false,
"dependencies": {
"@adeira/css-colors": "^2.0.0",
Expand Down

0 comments on commit 484d88e

Please sign in to comment.