diff --git a/src/babel-plugin-transform-sx-tailwind/package.json b/src/babel-plugin-transform-sx-tailwind/package.json index a1ae1bbd36..49e3de0f62 100644 --- a/src/babel-plugin-transform-sx-tailwind/package.json +++ b/src/babel-plugin-transform-sx-tailwind/package.json @@ -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", diff --git a/src/babel-preset-adeira/package.json b/src/babel-preset-adeira/package.json index 6c55216895..0f8d6e68a1 100644 --- a/src/babel-preset-adeira/package.json +++ b/src/babel-preset-adeira/package.json @@ -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", diff --git a/src/css-colors/package.json b/src/css-colors/package.json index 03a7243c5a..74273775db 100644 --- a/src/css-colors/package.json +++ b/src/css-colors/package.json @@ -6,6 +6,7 @@ "sideEffects": false, "private": false, "main": "./src/index.js", + "type": "commonjs", "license": "MIT", "dependencies": { "@adeira/js": "^2.1.0", diff --git a/src/eslint-config-adeira/package.json b/src/eslint-config-adeira/package.json index b19990a188..11af69d29d 100644 --- a/src/eslint-config-adeira/package.json +++ b/src/eslint-config-adeira/package.json @@ -6,6 +6,7 @@ "private": false, "version": "6.0.0", "main": "./index.js", + "type": "commonjs", "sideEffects": false, "dependencies": { "@babel/runtime": "^7.14.0", diff --git a/src/eslint-fixtures-tester/package.json b/src/eslint-fixtures-tester/package.json index bd7e0bd7ed..db1f742459 100644 --- a/src/eslint-fixtures-tester/package.json +++ b/src/eslint-fixtures-tester/package.json @@ -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": { diff --git a/src/eslint-plugin-adeira/package.json b/src/eslint-plugin-adeira/package.json index 58b8ae8c74..eaebbb4f93 100644 --- a/src/eslint-plugin-adeira/package.json +++ b/src/eslint-plugin-adeira/package.json @@ -6,6 +6,7 @@ "private": false, "version": "0.13.0", "main": "./src/index.js", + "type": "commonjs", "sideEffects": false, "dependencies": { "@babel/runtime": "^7.14.0", diff --git a/src/eslint-plugin-sx/package.json b/src/eslint-plugin-sx/package.json index bc1061ad35..ba228611be 100644 --- a/src/eslint-plugin-sx/package.json +++ b/src/eslint-plugin-sx/package.json @@ -11,6 +11,7 @@ "eslint-plugin" ], "main": "./src/index.js", + "type": "commonjs", "dependencies": { "@babel/runtime": "^7.14.0" }, diff --git a/src/fetch/package.json b/src/fetch/package.json index 091119c3b8..5e4fdcb7e4 100644 --- a/src/fetch/package.json +++ b/src/fetch/package.json @@ -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.", diff --git a/src/fixtures-tester/package.json b/src/fixtures-tester/package.json index 8c76baca81..08b1bea12d 100644 --- a/src/fixtures-tester/package.json +++ b/src/fixtures-tester/package.json @@ -6,6 +6,7 @@ "private": false, "version": "1.0.1", "main": "./src/index.js", + "type": "commonjs", "sideEffects": false, "dependencies": { "@adeira/js": "^2.1.0", diff --git a/src/flow-config-parser/package.json b/src/flow-config-parser/package.json index 2cbb989fba..a73503a9b2 100644 --- a/src/flow-config-parser/package.json +++ b/src/flow-config-parser/package.json @@ -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", diff --git a/src/flow-types-eslint/package.json b/src/flow-types-eslint/package.json index 65aa621a9a..f7f16658e9 100644 --- a/src/flow-types-eslint/package.json +++ b/src/flow-types-eslint/package.json @@ -4,6 +4,7 @@ "version": "0.0.0", "private": true, "main": "./src/index.js", + "type": "commonjs", "license": "MIT", "dependencies": {} } diff --git a/src/graphql-bc-checker/package.json b/src/graphql-bc-checker/package.json index 25cf0e1221..8bfab6393b 100644 --- a/src/graphql-bc-checker/package.json +++ b/src/graphql-bc-checker/package.json @@ -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", diff --git a/src/graphql-global-id/package.json b/src/graphql-global-id/package.json index 1a93bcd151..b2b5835193 100644 --- a/src/graphql-global-id/package.json +++ b/src/graphql-global-id/package.json @@ -6,6 +6,7 @@ "private": false, "version": "2.0.1", "main": "./src/index.js", + "type": "commonjs", "sideEffects": false, "dependencies": { "@adeira/js": "^2.1.0", diff --git a/src/graphql-relay-fauna/package.json b/src/graphql-relay-fauna/package.json index c37e0d4627..80ed8f96b9 100644 --- a/src/graphql-relay-fauna/package.json +++ b/src/graphql-relay-fauna/package.json @@ -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", diff --git a/src/graphql-relay/package.json b/src/graphql-relay/package.json index a63746e568..3f7d29df89 100644 --- a/src/graphql-relay/package.json +++ b/src/graphql-relay/package.json @@ -14,6 +14,7 @@ "url": "http://github.com/adeira/universe.git" }, "main": "./src/index.js", + "type": "commonjs", "peerDependencies": { "graphql": "^15.0.0" }, diff --git a/src/graphql-resolve-wrapper/package.json b/src/graphql-resolve-wrapper/package.json index 99db7aa8a5..bffbd02e01 100644 --- a/src/graphql-resolve-wrapper/package.json +++ b/src/graphql-resolve-wrapper/package.json @@ -6,6 +6,7 @@ "private": false, "version": "0.3.0", "main": "./src/index.js", + "type": "commonjs", "sideEffects": false, "dependencies": { "@babel/runtime": "^7.14.0" diff --git a/src/js/package.json b/src/js/package.json index d9234b613b..c86f0180a1 100644 --- a/src/js/package.json +++ b/src/js/package.json @@ -6,6 +6,7 @@ "private": false, "version": "2.1.0", "main": "./src/index.js", + "type": "commonjs", "sideEffects": false, "dependencies": { "@babel/runtime": "^7.14.0" diff --git a/src/monorepo-npm-publisher/package.json b/src/monorepo-npm-publisher/package.json index d9bb5b96b9..5f3fd59e18 100644 --- a/src/monorepo-npm-publisher/package.json +++ b/src/monorepo-npm-publisher/package.json @@ -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", diff --git a/src/monorepo-scanner/src/scans/MainFields.scan.js b/src/monorepo-scanner/src/scans/PackageJson.scan.js similarity index 60% rename from src/monorepo-scanner/src/scans/MainFields.scan.js rename to src/monorepo-scanner/src/scans/PackageJson.scan.js index 37788a7616..c56285e3bc 100644 --- a/src/monorepo-scanner/src/scans/MainFields.scan.js +++ b/src/monorepo-scanner/src/scans/PackageJson.scan.js @@ -9,12 +9,24 @@ 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`, ); + + // $FlowIssue[incompatible-call]: https://github.com/facebook/flow/issues/3018 + expect(type != null).toGiveHelp( + `Each package must specify "type" to be either "commonjs" or "module".`, + ); + + // $FlowIssue[incompatible-call]: https://github.com/facebook/flow/issues/3018 + expect(['commonjs', 'module'].includes(type)).toGiveHelp( + `Package type must be either "commonjs" or "module" (given "${type}").`, + ); } }); }); diff --git a/src/monorepo-utils/package.json b/src/monorepo-utils/package.json index 8590220eaf..cf11d24a89 100644 --- a/src/monorepo-utils/package.json +++ b/src/monorepo-utils/package.json @@ -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", diff --git a/src/murmur-hash/package.json b/src/murmur-hash/package.json index 9d3d2afb5a..6ab3a92394 100644 --- a/src/murmur-hash/package.json +++ b/src/murmur-hash/package.json @@ -6,6 +6,7 @@ "private": false, "version": "2.0.0", "main": "./src/murmurHash.js", + "type": "commonjs", "sideEffects": false, "dependencies": { "@babel/runtime": "^7.14.0" diff --git a/src/relay/package.json b/src/relay/package.json index 1f44d44593..8b55a03203 100644 --- a/src/relay/package.json +++ b/src/relay/package.json @@ -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", diff --git a/src/signed-source/package.json b/src/signed-source/package.json index 4f440272f0..aaa349f06f 100644 --- a/src/signed-source/package.json +++ b/src/signed-source/package.json @@ -6,6 +6,7 @@ "private": false, "version": "2.0.0", "main": "./src/SignedSource.js", + "type": "commonjs", "sideEffects": false, "dependencies": { "@babel/runtime": "^7.14.0" diff --git a/src/sx-design/package.json b/src/sx-design/package.json index c55cbf0bf2..d9570c4006 100644 --- a/src/sx-design/package.json +++ b/src/sx-design/package.json @@ -6,6 +6,7 @@ "private": false, "version": "0.10.0", "main": "./index.js", + "type": "commonjs", "sideEffects": false, "dependencies": { "@adeira/js": "^2.1.0", diff --git a/src/sx-jest-snapshot-serializer/package.json b/src/sx-jest-snapshot-serializer/package.json index 39d2c6f194..d23c320755 100644 --- a/src/sx-jest-snapshot-serializer/package.json +++ b/src/sx-jest-snapshot-serializer/package.json @@ -6,6 +6,7 @@ "private": false, "version": "0.1.0", "main": "./index.js", + "type": "commonjs", "sideEffects": true, "dependencies": { "@adeira/sx": "^0.25.0", diff --git a/src/sx-tailwind/package.json b/src/sx-tailwind/package.json index a84bb77351..4c0aaec718 100644 --- a/src/sx-tailwind/package.json +++ b/src/sx-tailwind/package.json @@ -6,6 +6,7 @@ "private": false, "version": "0.12.0", "main": "./index.js", + "type": "commonjs", "sideEffects": false, "dependencies": { "@adeira/js": "^2.1.0", diff --git a/src/sx/package.json b/src/sx/package.json index f74397202b..6b7b57b5b1 100644 --- a/src/sx/package.json +++ b/src/sx/package.json @@ -6,6 +6,7 @@ "private": false, "version": "0.25.0", "main": "./index.js", + "type": "commonjs", "sideEffects": false, "dependencies": { "@adeira/css-colors": "^2.0.0",