Skip to content

Commit

Permalink
Enforce setting type in package.json (#14675)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolo-ribaudo committed Jun 20, 2022
1 parent d016c15 commit 4c3365f
Show file tree
Hide file tree
Showing 162 changed files with 1,258 additions and 151 deletions.
2 changes: 2 additions & 0 deletions .yarnrc.yml
@@ -1,6 +1,8 @@
conditions:
BABEL_8_BREAKING:
default: false
USE_ESM:
default: false

enableGlobalCache: true

Expand Down
Expand Up @@ -36,10 +36,17 @@
{
"exports": null
}
],
"USE_ESM": [
{
"type": "module"
},
null
]
},
"exports": {
".": "./lib/index.js",
"./package.json": "./package.json"
}
},
"type": "commonjs"
}
Expand Up @@ -36,10 +36,17 @@
{
"exports": null
}
],
"USE_ESM": [
{
"type": "module"
},
null
]
},
"exports": {
".": "./lib/index.js",
"./package.json": "./package.json"
}
},
"type": "commonjs"
}
13 changes: 13 additions & 0 deletions constraints.pro
Expand Up @@ -86,3 +86,16 @@ gen_enforced_field(WorkspaceCwd, 'exports', '{ ".": "./lib/index.js", "./package
WorkspaceIdent \= '@babel/standalone',
\+ atom_concat('@babel/eslint-', _, WorkspaceIdent),
\+ atom_concat('@babel/runtime', _, WorkspaceIdent).

% Enforces the type field to be set
gen_enforced_field(WorkspaceCwd, 'type', 'commonjs') :-
\+ workspace_field(WorkspaceCwd, 'type', 'module').

% Enforce a default 'conditions', unless it's already specified
gen_enforced_field(WorkspaceCwd, 'conditions', '{ "USE_ESM": [{ "type": "module" }, null] }') :-
\+ workspace_field(WorkspaceCwd, 'private', true),
\+ workspace_field(WorkspaceCwd, 'conditions', _),
\+ workspace_field(WorkspaceCwd, 'main', './lib/index.cjs'),
% Exclude some packages
workspace_ident(WorkspaceCwd, WorkspaceIdent),
WorkspaceIdent \= '@babel/compat-data'.
3 changes: 2 additions & 1 deletion eslint/babel-eslint-plugin-development-internal/package.json
Expand Up @@ -21,5 +21,6 @@
},
"devDependencies": {
"eslint": "^7.27.0"
}
},
"type": "commonjs"
}
3 changes: 2 additions & 1 deletion eslint/babel-eslint-shared-fixtures/package.json
Expand Up @@ -16,5 +16,6 @@
"@babel/preset-flow": "workspace:^",
"@babel/preset-react": "workspace:^",
"eslint": "^7.27.0"
}
},
"type": "commonjs"
}
3 changes: 2 additions & 1 deletion eslint/babel-eslint-tests/package.json
Expand Up @@ -11,5 +11,6 @@
"eslint": "^7.27.0",
"eslint-plugin-import": "^2.25.4",
"npm-babel-parser": "npm:@babel/parser@^7.14.0"
}
},
"type": "commonjs"
}
9 changes: 8 additions & 1 deletion packages/babel-cli/package.json
Expand Up @@ -57,10 +57,17 @@
{
"exports": null
}
],
"USE_ESM": [
{
"type": "module"
},
null
]
},
"exports": {
".": "./lib/index.js",
"./package.json": "./package.json"
}
},
"type": "commonjs"
}
9 changes: 8 additions & 1 deletion packages/babel-code-frame/package.json
Expand Up @@ -32,10 +32,17 @@
{
"exports": null
}
],
"USE_ESM": [
{
"type": "module"
},
null
]
},
"exports": {
".": "./lib/index.js",
"./package.json": "./package.json"
}
},
"type": "commonjs"
}
3 changes: 2 additions & 1 deletion packages/babel-compat-data/package.json
Expand Up @@ -35,5 +35,6 @@
},
"engines": {
"node": ">=6.9.0"
}
},
"type": "commonjs"
}
9 changes: 8 additions & 1 deletion packages/babel-core/package.json
Expand Up @@ -81,10 +81,17 @@
{
"exports": null
}
],
"USE_ESM": [
{
"type": "module"
},
null
]
},
"exports": {
".": "./lib/index.js",
"./package.json": "./package.json"
}
},
"type": "commonjs"
}
9 changes: 8 additions & 1 deletion packages/babel-generator/package.json
Expand Up @@ -39,10 +39,17 @@
{
"exports": null
}
],
"USE_ESM": [
{
"type": "module"
},
null
]
},
"exports": {
".": "./lib/index.js",
"./package.json": "./package.json"
}
},
"type": "commonjs"
}
9 changes: 8 additions & 1 deletion packages/babel-helper-annotate-as-pure/package.json
Expand Up @@ -26,10 +26,17 @@
{
"exports": null
}
],
"USE_ESM": [
{
"type": "module"
},
null
]
},
"exports": {
".": "./lib/index.js",
"./package.json": "./package.json"
}
},
"type": "commonjs"
}
Expand Up @@ -27,10 +27,17 @@
{
"exports": null
}
],
"USE_ESM": [
{
"type": "module"
},
null
]
},
"exports": {
".": "./lib/index.js",
"./package.json": "./package.json"
}
},
"type": "commonjs"
}
9 changes: 8 additions & 1 deletion packages/babel-helper-builder-react-jsx/package.json
Expand Up @@ -30,10 +30,17 @@
{
"exports": null
}
],
"USE_ESM": [
{
"type": "module"
},
null
]
},
"exports": {
".": "./lib/index.js",
"./package.json": "./package.json"
}
},
"type": "commonjs"
}
9 changes: 9 additions & 0 deletions packages/babel-helper-check-duplicate-nodes/package.json
Expand Up @@ -32,5 +32,14 @@
},
"devDependencies": {
"@babel/core": "workspace:^"
},
"type": "commonjs",
"conditions": {
"USE_ESM": [
{
"type": "module"
},
null
]
}
}
9 changes: 9 additions & 0 deletions packages/babel-helper-compilation-targets/package.json
Expand Up @@ -37,5 +37,14 @@
},
"engines": {
"node": ">=6.9.0"
},
"type": "commonjs",
"conditions": {
"USE_ESM": [
{
"type": "module"
},
null
]
}
}
Expand Up @@ -44,10 +44,17 @@
{
"exports": null
}
],
"USE_ESM": [
{
"type": "module"
},
null
]
},
"exports": {
".": "./lib/index.js",
"./package.json": "./package.json"
}
},
"type": "commonjs"
}
Expand Up @@ -37,10 +37,17 @@
{
"exports": null
}
],
"USE_ESM": [
{
"type": "module"
},
null
]
},
"exports": {
".": "./lib/index.js",
"./package.json": "./package.json"
}
},
"type": "commonjs"
}
9 changes: 8 additions & 1 deletion packages/babel-helper-define-map/package.json
Expand Up @@ -27,10 +27,17 @@
{
"exports": null
}
],
"USE_ESM": [
{
"type": "module"
},
null
]
},
"exports": {
".": "./lib/index.js",
"./package.json": "./package.json"
}
},
"type": "commonjs"
}
11 changes: 10 additions & 1 deletion packages/babel-helper-environment-visitor/package.json
Expand Up @@ -24,5 +24,14 @@
"engines": {
"node": ">=6.9.0"
},
"author": "The Babel Team (https://babel.dev/team)"
"author": "The Babel Team (https://babel.dev/team)",
"type": "commonjs",
"conditions": {
"USE_ESM": [
{
"type": "module"
},
null
]
}
}
Expand Up @@ -29,10 +29,17 @@
{
"exports": null
}
],
"USE_ESM": [
{
"type": "module"
},
null
]
},
"exports": {
".": "./lib/index.js",
"./package.json": "./package.json"
}
},
"type": "commonjs"
}
9 changes: 8 additions & 1 deletion packages/babel-helper-fixtures/package.json
Expand Up @@ -29,10 +29,17 @@
{
"exports": null
}
],
"USE_ESM": [
{
"type": "module"
},
null
]
},
"exports": {
".": "./lib/index.js",
"./package.json": "./package.json"
}
},
"type": "commonjs"
}
9 changes: 8 additions & 1 deletion packages/babel-helper-function-name/package.json
Expand Up @@ -27,10 +27,17 @@
{
"exports": null
}
],
"USE_ESM": [
{
"type": "module"
},
null
]
},
"exports": {
".": "./lib/index.js",
"./package.json": "./package.json"
}
},
"type": "commonjs"
}

0 comments on commit 4c3365f

Please sign in to comment.