New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't use "composite": true
in tsc (until it supports cycles)
#13242
Changes from 6 commits
5345bf6
6cbdc8c
c264b34
62eb474
0e1e6b1
ddef34a
0924838
c7c0b2b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,6 @@ import path from "path"; | |
import fs from "fs"; | ||
import { createRequire } from "module"; | ||
import { fileURLToPath } from "url"; | ||
|
||
import plumber from "gulp-plumber"; | ||
import through from "through2"; | ||
import chalk from "chalk"; | ||
|
@@ -31,7 +30,6 @@ const monorepoRoot = path.dirname(fileURLToPath(import.meta.url)); | |
|
||
const defaultPackagesGlob = "./@(codemods|packages|eslint)/*"; | ||
const defaultSourcesGlob = `${defaultPackagesGlob}/src/**/{*.js,*.cjs,!(*.d).ts}`; | ||
const defaultDtsGlob = `${defaultPackagesGlob}/lib/**/*.d.ts{,.map}`; | ||
|
||
const babelStandalonePluginConfigGlob = | ||
"./packages/babel-standalone/scripts/pluginConfig.json"; | ||
|
@@ -61,6 +59,10 @@ function mapSrcToLib(srcPath) { | |
return parts.join(path.sep); | ||
} | ||
|
||
function mapToDts(packageName) { | ||
return packageName.replace(/\bpackages\b/, "dts"); | ||
} | ||
|
||
function getIndexFromPackage(name) { | ||
try { | ||
fs.statSync(`./${name}/src/index.ts`); | ||
|
@@ -193,12 +195,6 @@ export const all = {${allList}};`; | |
.pipe(gulp.dest(dest)); | ||
} | ||
|
||
function unlink() { | ||
return through.obj(function (file, enc, callback) { | ||
fs.unlink(file.path, () => callback()); | ||
}); | ||
} | ||
|
||
function finish(stream) { | ||
return new Promise((resolve, reject) => { | ||
stream.on("end", resolve); | ||
|
@@ -422,19 +418,20 @@ function buildRollupDts(packages) { | |
const sourcemap = process.env.NODE_ENV === "production"; | ||
return Promise.all( | ||
packages.map(async packageName => { | ||
const input = `${packageName}/lib/index.d.ts`; | ||
fancyLog(`Bundling '${chalk.cyan(input)}' with rollup ...`); | ||
const input = `${mapToDts(packageName)}/src/index.d.ts`; | ||
const output = `${packageName}/lib/index.d.ts`; | ||
fancyLog(`Bundling '${chalk.cyan(output)}' with rollup ...`); | ||
|
||
const bundle = await rollup({ | ||
input, | ||
plugins: [rollupDts()], | ||
onwarn(warning, warn) { | ||
if (warning.code !== "CIRCULAR_DEPENDENCY") warn(warning); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why there is a warning about it? Can it cause issue when publishing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It doesn't cause issues because types are hoisted. It's only a problem when two modules depend on each other and they export/import non-hoistable declarations: // a.js
import { b } from "b";
export let a = b; import { a } from "a";
export let b = a; |
||
}, | ||
}); | ||
|
||
await finish( | ||
gulp.src(`${packageName}/lib/**/*.d.ts{,.map}`).pipe(unlink()) | ||
); | ||
|
||
await bundle.write({ | ||
file: `${packageName}/lib/index.d.ts`, | ||
file: output, | ||
format: "es", | ||
sourcemap: sourcemap, | ||
exports: "named", | ||
|
@@ -443,13 +440,9 @@ function buildRollupDts(packages) { | |
); | ||
} | ||
|
||
function removeDts(exclude) { | ||
return getFiles(defaultDtsGlob, { exclude }).pipe(unlink()); | ||
} | ||
|
||
function copyDts(packages) { | ||
return getFiles(`${defaultPackagesGlob}/src/**/*.d.ts`, { include: packages }) | ||
.pipe(rename(file => path.resolve(file.base, mapSrcToLib(file.relative)))) | ||
.pipe(rename(file => path.resolve(file.base, mapToDts(file.relative)))) | ||
.pipe(gulp.dest(monorepoRoot)); | ||
} | ||
|
||
|
@@ -516,7 +509,6 @@ gulp.task( | |
"bundle-dts", | ||
gulp.series("copy-dts", () => buildRollupDts(dtsBundles)) | ||
); | ||
gulp.task("clean-dts", () => removeDts(/* exclude */ dtsBundles)); | ||
|
||
gulp.task("build-babel", () => buildBabel(/* exclude */ libBundles)); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about eslint and codemods? - I guess eventually it should also be migrated to typescript