Skip to content

Commit

Permalink
Final configuration changes in preparation for TS (#12351)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolo-ribaudo committed Nov 12, 2020
1 parent 5bbad89 commit 3e0fa92
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 63 deletions.
1 change: 0 additions & 1 deletion .eslintignore
Expand Up @@ -9,7 +9,6 @@ packages/babel-runtime-corejs2
packages/babel-runtime-corejs3
packages/*/node_modules
packages/*/lib
packages/*/dts
packages/*/dist
packages/*/test/fixtures
packages/*/test/tmp
Expand Down
8 changes: 2 additions & 6 deletions .gitignore
Expand Up @@ -71,9 +71,5 @@ packages/babel-standalone/babel.min.js
!/packages/babel-eslint-plugin/LICENSE
/.vscode

/tsconfig.json
/packages/*/tsconfig.json
/packages/*/tsconfig.tsbuildinfo
/packages/*/dts
/codemods/*/dts
/eslint/*/dts
tsconfig.json
tsconfig.tsbuildinfo
14 changes: 10 additions & 4 deletions Makefile
Expand Up @@ -146,7 +146,9 @@ clean: test-clean

clean-tsconfig:
rm -f tsconfig.json
rm -f packages/*/tsconfig.json
rm -f packages/*/tsconfig.{tsbuildinfo,json}
rm -f codemods/*/tsconfig.{tsbuildinfo,json}
rm -f eslint/*/tsconfig.{tsbuildinfo,json}

test-clean:
$(foreach source, $(SOURCES), \
Expand Down Expand Up @@ -223,14 +225,18 @@ clone-license:
prepublish-build: clean-lib clean-runtime-helpers
NODE_ENV=production BABEL_ENV=production $(MAKE) build-bundle
$(MAKE) prepublish-build-standalone clone-license
# We don't want to publish .d.ts files yet
rm -rf packages/*/dts

prepublish:
$(MAKE) check-yarn-bug-1882
$(MAKE) bootstrap-only
$(MAKE) prepublish-build
IS_PUBLISH=true $(MAKE) test
# We don't want to publish TS-related files yet, except for @babel/types
rm -f packages/*/lib/**/*.d.ts{,.map}
rm -f codemods/*/lib/**/*.d.ts{,.map}
rm -f eslint/*/lib/**/*.d.ts{,.map}
$(MAKE) clean-tsconfig
$(MAKE) build-typescript-typings

new-version:
git pull --rebase
Expand Down Expand Up @@ -272,7 +278,7 @@ endif
bootstrap-only: clean-all
yarn install

bootstrap: bootstrap-only
bootstrap: bootstrap-only generate-tsconfig
$(MAKE) build

clean-lib:
Expand Down
9 changes: 3 additions & 6 deletions jest.config.js
@@ -1,11 +1,8 @@
module.exports = {
collectCoverageFrom: [
"packages/*/src/**/*.mjs",
"packages/*/src/**/*.js",
"codemods/*/src/**/*.mjs",
"codemods/*/src/**/*.js",
"eslint/*/src/**/*.mjs",
"eslint/*/src/**/*.js",
"packages/*/src/**/*.{js,mjs,ts}",
"codemods/*/src/**/*.{js,mjs,ts}",
"eslint/*/src/**/*.{js,mjs,ts}",
],
// The eslint/* packages use ESLint v6, which has dropped support for Node v6.
// TODO: Remove this process.version check in Babel 8.
Expand Down
5 changes: 4 additions & 1 deletion package.json
Expand Up @@ -74,7 +74,10 @@
],
"resolutions": {
"browserslist": "npm:4.14.5",
"caniuse-lite": "npm:1.0.30001077"
"caniuse-lite": "npm:1.0.30001077",
"@types/babel__core": "link:./nope",
"@types/babel__traverse": "link:./nope",
"@babel/parser/@babel/types": "workspace:*"
},
"engines": {
"node": ">= 6.9.0",
Expand Down
18 changes: 13 additions & 5 deletions scripts/generators/tsconfig.js
Expand Up @@ -24,8 +24,18 @@ const tsPkgs = fs
for (const { dir } of tsPkgs) {
const pkg = require(`${dir}/package.json`);

try {
const tsconfig = require(`${dir}/tsconfig.json`);
// Don't overwrite manually written configs
if (!tsconfig.generated) continue;
} catch {}

const deps = [];
if (pkg.dependencies) deps.push(...Object.keys(pkg.dependencies));
if (pkg.peerDependencies) deps.push(...Object.keys(pkg.peerDependencies));

const references = [];
for (const dep of Object.keys(pkg.dependencies)) {
for (const dep of deps) {
if (!dep.startsWith("@babel/")) continue;
for (const { name, dir: depDir } of tsPkgs) {
if (name === dep) {
Expand All @@ -39,12 +49,10 @@ for (const { dir } of tsPkgs) {
path.resolve(dir, "tsconfig.json"),
JSON.stringify(
{
generated: true,
extends: "../../tsconfig.base.json",
compilerOptions: {
// Until we have converted every package, we cannot store
// .d.ts files inside lib/ because it causes conflicts
// with Babel-related type definitions in node_modules/@types
outDir: "./dts",
outDir: "./lib",
rootDir: "./src",
},
include: ["./src/**/*"],
Expand Down
2 changes: 1 addition & 1 deletion scripts/utils/formatCode.js
Expand Up @@ -15,7 +15,7 @@ if (process.env.CI && parseInt(process.versions.node, 10) < 10) {
filename = filename || __filename;
const prettierConfig = prettier.resolveConfig.sync(filename);
prettierConfig.filepath = filename;
prettierConfig.parser = "babel";
prettierConfig.parser = filename.endsWith(".ts") ? "babel-ts" : "babel";

return prettier.format(code, prettierConfig);
};
Expand Down
2 changes: 2 additions & 0 deletions tsconfig.base.json
Expand Up @@ -5,6 +5,8 @@
"lib": [
"esnext"
],
"declaration": true,
"declarationMap": true,
"emitDeclarationOnly": true,
"composite": true,
"moduleResolution": "node",
Expand Down
49 changes: 10 additions & 39 deletions yarn.lock
Expand Up @@ -889,7 +889,7 @@ __metadata:
languageName: unknown
linkType: soft

"@babel/parser@npm:^7.0.0, @babel/parser@npm:^7.1.0, @babel/parser@npm:^7.10.4, @babel/parser@npm:^7.12.0, @babel/parser@npm:^7.12.5":
"@babel/parser@npm:^7.0.0, @babel/parser@npm:^7.10.4, @babel/parser@npm:^7.12.0, @babel/parser@npm:^7.12.5":
version: 7.12.5
resolution: "@babel/parser@npm:7.12.5"
bin:
Expand Down Expand Up @@ -3379,7 +3379,7 @@ __metadata:
languageName: unknown
linkType: soft

"@babel/types@npm:^7.0.0, @babel/types@npm:^7.10.4, @babel/types@npm:^7.10.5, @babel/types@npm:^7.11.0, @babel/types@npm:^7.12.0, @babel/types@npm:^7.12.1, @babel/types@npm:^7.12.5, @babel/types@npm:^7.3.0, @babel/types@npm:^7.3.3, @babel/types@npm:^7.4.4, @babel/types@npm:^7.8.3":
"@babel/types@npm:^7.0.0, @babel/types@npm:^7.10.4, @babel/types@npm:^7.10.5, @babel/types@npm:^7.11.0, @babel/types@npm:^7.12.0, @babel/types@npm:^7.12.1, @babel/types@npm:^7.12.5, @babel/types@npm:^7.3.3, @babel/types@npm:^7.4.4":
version: 7.12.6
resolution: "@babel/types@npm:7.12.6"
dependencies:
Expand Down Expand Up @@ -3807,46 +3807,17 @@ __metadata:
languageName: node
linkType: hard

"@types/babel__core@npm:^7.0.0, @types/babel__core@npm:^7.1.7":
version: 7.1.10
resolution: "@types/babel__core@npm:7.1.10"
dependencies:
"@babel/parser": ^7.1.0
"@babel/types": ^7.0.0
"@types/babel__generator": "*"
"@types/babel__template": "*"
"@types/babel__traverse": "*"
checksum: fd013086d241527c708844ff379ec5204b31dfb4e50a427bc24e77172af74041f6eab650da16edf1a20f445595052505792ec7fa1978bb5f8f2c191bfc8c767d
languageName: node
linkType: hard

"@types/babel__generator@npm:*":
version: 7.6.0
resolution: "@types/babel__generator@npm:7.6.0"
dependencies:
"@babel/types": ^7.0.0
checksum: 97228549b9bba6351d92891b29acfa7eb324a832a6b1d8373042ae8b1bce4e2aa300e9a349e1ec10d06115f597adcd3881635da8dfe7e21724da19e56800fe09
languageName: node
linkType: hard

"@types/babel__template@npm:*":
version: 7.0.2
resolution: "@types/babel__template@npm:7.0.2"
dependencies:
"@babel/parser": ^7.1.0
"@babel/types": ^7.0.0
checksum: dd13bcf6f016866dba8310053302ac657de9966d85c67748d07ee385d07bdd8af56930ed4192c426b5118f43db268c17784bc6eb051ba94c5fcd50d5ca2db74f
"@types/babel__core@link:./nope::locator=babel%40workspace%3A.":
version: 0.0.0-use.local
resolution: "@types/babel__core@link:./nope::locator=babel%40workspace%3A."
languageName: node
linkType: hard
linkType: soft

"@types/babel__traverse@npm:*, @types/babel__traverse@npm:^7.0.4, @types/babel__traverse@npm:^7.0.6":
version: 7.0.8
resolution: "@types/babel__traverse@npm:7.0.8"
dependencies:
"@babel/types": ^7.3.0
checksum: 01ac8f7c1426184330a3d510b7701cc731da0f1778772e7c8c31edd1350b21ea55ee28a8de2e1546dff679cd05c731b03505231965a92ec2422f17dc81800bf9
"@types/babel__traverse@link:./nope::locator=babel%40workspace%3A.":
version: 0.0.0-use.local
resolution: "@types/babel__traverse@link:./nope::locator=babel%40workspace%3A."
languageName: node
linkType: hard
linkType: soft

"@types/color-name@npm:^1.1.1":
version: 1.1.1
Expand Down

0 comments on commit 3e0fa92

Please sign in to comment.