-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Nicolò Ribaudo <hello@nicr.dev>
- Loading branch information
1 parent
5e1c5f0
commit 76d2dcd
Showing
16 changed files
with
5,101 additions
and
5,072 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
% Enforces `exports` to be consistent | ||
gen_enforced_field(WorkspaceCwd, 'exports', '{ ".": "./lib/index.js", "./package.json": "./package.json" }') :- | ||
\+ workspace_field(WorkspaceCwd, 'private', true), | ||
% Exclude packages with more complex `exports` | ||
workspace_ident(WorkspaceCwd, WorkspaceIdent), | ||
WorkspaceIdent \= '@babel/compat-data', | ||
WorkspaceIdent \= '@babel/helper-plugin-test-runner', % TODO: Remove in Babel 8 | ||
WorkspaceIdent \= '@babel/core', % TODO: Remove in Babel 8 | ||
WorkspaceIdent \= '@babel/parser', | ||
WorkspaceIdent \= '@babel/plugin-transform-react-jsx', % TODO: Remove in Babel 8 | ||
WorkspaceIdent \= '@babel/standalone', | ||
WorkspaceIdent \= '@babel/types', % @babel/types has types exports | ||
\+ atom_concat('@babel/eslint-', _, WorkspaceIdent), | ||
\+ atom_concat('@babel/runtime', _, WorkspaceIdent). | ||
*/ | ||
|
||
function enforcePackageExports({ Yarn }) { | ||
for (const workspace of Yarn.workspaces()) { | ||
if (workspace.manifest.private) continue; | ||
// Exclude packages with more complex `exports` | ||
const packageName = workspace.pkg.ident; | ||
if ( | ||
[ | ||
"@babel/compat-data", | ||
"@babel/helper-plugin-test-runner", // TODO: Remove in Babel 8 | ||
"@babel/core", // TODO: Remove in Babel 8 | ||
"@babel/parser", | ||
"@babel/plugin-transform-react-jsx", // TODO: Remove in Babel 8 | ||
"@babel/standalone", | ||
"@babel/types", // @babel/types has types exports | ||
].includes(packageName) || | ||
packageName.startsWith("@babel/eslint-") || | ||
packageName.startsWith("@babel/runtime") | ||
) { | ||
continue; | ||
} | ||
|
||
const desiredExports = { | ||
".": "./lib/index.js", | ||
"./package.json": "./package.json", | ||
}; | ||
|
||
workspace.set("exports", desiredExports); | ||
} | ||
} | ||
|
||
module.exports = { | ||
constraints: async ctx => { | ||
enforcePackageExports(ctx); | ||
}, | ||
}; |
Oops, something went wrong.