Skip to content

Commit e249498

Browse files
committed
Merge branch 'main' into fix50916
# Conflicts: # src/compiler/checker.ts
2 parents cfaa7ef + 1ed0a5a commit e249498

File tree

2,651 files changed

+126272
-61465
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,651 files changed

+126272
-61465
lines changed

.eslintrc.json

+11-6
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"es6": true
1212
},
1313
"plugins": [
14-
"@typescript-eslint", "no-null", "import", "eslint-plugin-local"
14+
"@typescript-eslint", "no-null", "import", "eslint-plugin-local", "simple-import-sort"
1515
],
1616
"ignorePatterns": [
1717
"**/node_modules/**",
@@ -25,11 +25,8 @@
2525
"/coverage/**"
2626
],
2727
"rules": {
28-
"sort-imports": ["error", {
29-
"ignoreCase": true,
30-
"ignoreDeclarationSort": true,
31-
"allowSeparatedGroups": true
32-
}],
28+
"simple-import-sort/imports": "error",
29+
"simple-import-sort/exports": "error",
3330

3431
"@typescript-eslint/adjacent-overload-signatures": "error",
3532
"@typescript-eslint/array-type": "error",
@@ -180,6 +177,14 @@
180177
{ "name": "exports" }
181178
]
182179
}
180+
},
181+
{
182+
// These files contain imports in a specific order that are generally unsafe to modify.
183+
"files": ["**/_namespaces/**"],
184+
"rules": {
185+
"simple-import-sort/imports": "off",
186+
"simple-import-sort/exports": "off"
187+
}
183188
}
184189
]
185190
}

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
*.js linguist-language=TypeScript
2+
**/*.json linguist-language=jsonc
23
* -text

.github/fabricbot.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
{
3232
"name": "addReply",
3333
"parameters": {
34-
"comment": "Thanks for the PR! It looks like you've changed the TSServer protocol in some way. Please ensure that any changes here don't break consumers of the current TSServer API. For some extra review, we'll ping @sheetalkamat, @mjbvz, and @minestarks for you. Feel free to loop in other consumers/maintainers if necessary"
34+
"comment": "Thanks for the PR! It looks like you've changed the TSServer protocol in some way. Please ensure that any changes here don't break consumers of the current TSServer API. For some extra review, we'll ping @sheetalkamat, @mjbvz, @zkat, and @joj for you. Feel free to loop in other consumers/maintainers if necessary"
3535
}
3636
}
3737
],
@@ -487,7 +487,7 @@
487487
{
488488
"name": "addReply",
489489
"parameters": {
490-
"comment": "Thanks for the PR! It looks like you've changed 'preProcess.ts' in some way. Please ensure that any changes here don't break consumers with unique project systems such as Visual Studio. Pinging @sheetalkamat and @minestarks so they are aware of the changes."
490+
"comment": "Thanks for the PR! It looks like you've changed 'preProcess.ts' in some way. Please ensure that any changes here don't break consumers with unique project systems such as Visual Studio. Pinging @sheetalkamat, @zkat, and @joj so they are aware of the changes."
491491
}
492492
}
493493
]

.vscode/launch.template.json

+6
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@
4040
"env": {
4141
"NODE_ENV": "testing"
4242
},
43+
"outFiles": [
44+
"${workspaceFolder}/built/**/*.js",
45+
"${workspaceFolder}/built/**/*.mjs",
46+
"${workspaceFolder}/built/**/*.cjs",
47+
"!**/node_modules/**"
48+
],
4349
"sourceMaps": true,
4450
"smartStep": true,
4551
"preLaunchTask": "npm: build:tests",

.vscode/settings.template.json

+8
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@
1313
// ".git-blame-ignore-revs"
1414
// ]
1515

16+
// Match eslint-plugin-simple-import-sort in organize/auto-imports.
17+
"typescript.unstable": {
18+
"organizeImportsCollation": "unicode",
19+
"organizeImportsCaseFirst": "upper",
20+
"organizeImportsIgnoreCase": false,
21+
"organizeImportsNumericCollation": true
22+
},
23+
1624
// These options search the repo recursively and slow down
1725
// the build task menu. We define our own in tasks.json.
1826
"typescript.tsc.autoDetect": "off",

Herebyfile.mjs

+66-44
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
// @ts-check
2-
import path from "path";
3-
import fs from "fs";
2+
import { CancelToken } from "@esfx/canceltoken";
3+
import chalk from "chalk";
4+
import chokidar from "chokidar";
45
import del from "del";
5-
import { task } from "hereby";
6+
import esbuild from "esbuild";
7+
import { EventEmitter } from "events";
8+
import fs from "fs";
9+
import fsExtra from "fs-extra";
610
import _glob from "glob";
11+
import { task } from "hereby";
12+
import path from "path";
713
import util from "util";
8-
import chalk from "chalk";
9-
import fsExtra from "fs-extra";
10-
import { Debouncer, Deferred, exec, getDiffTool, getDirSize, memoize, needsUpdate, readJson } from "./scripts/build/utils.mjs";
11-
import { localBaseline, localRwcBaseline, refBaseline, refRwcBaseline, runConsoleTests } from "./scripts/build/tests.mjs";
12-
import { buildProject, cleanProject, watchProject } from "./scripts/build/projects.mjs";
14+
1315
import { localizationDirectories } from "./scripts/build/localization.mjs";
1416
import cmdLineOptions from "./scripts/build/options.mjs";
15-
import esbuild from "esbuild";
16-
import chokidar from "chokidar";
17-
import { EventEmitter } from "events";
18-
import { CancelToken } from "@esfx/canceltoken";
17+
import { buildProject, cleanProject, watchProject } from "./scripts/build/projects.mjs";
18+
import { localBaseline, localRwcBaseline, refBaseline, refRwcBaseline, runConsoleTests } from "./scripts/build/tests.mjs";
19+
import { Debouncer, Deferred, exec, getDiffTool, getDirSize, memoize, needsUpdate, readJson } from "./scripts/build/utils.mjs";
1920

2021
const glob = util.promisify(_glob);
2122

@@ -59,10 +60,7 @@ export const generateLibs = task({
5960

6061
for (const source of lib.sources) {
6162
const contents = await fs.promises.readFile(source, "utf-8");
62-
// TODO(jakebailey): "\n\n" is for compatibility with our current tests; our test baselines
63-
// are sensitive to the positions of things in the lib files. Eventually remove this,
64-
// or remove lib.d.ts line numbers from our baselines.
65-
output += "\n\n" + contents.replace(/\r\n/g, "\n");
63+
output += "\n" + contents.replace(/\r\n/g, "\n");
6664
}
6765

6866
await fs.promises.writeFile(lib.target, output);
@@ -163,7 +161,7 @@ async function runDtsBundler(entrypoint, output) {
163161
* @typedef BundlerTaskOptions
164162
* @property {boolean} [exportIsTsObject]
165163
* @property {boolean} [treeShaking]
166-
* @property {esbuild.WatchMode} [watchMode]
164+
* @property {() => void} [onWatchRebuild]
167165
*/
168166
function createBundler(entrypoint, outfile, taskOptions = {}) {
169167
const getOptions = memoize(async () => {
@@ -182,28 +180,6 @@ function createBundler(entrypoint, outfile, taskOptions = {}) {
182180
packages: "external",
183181
logLevel: "warning",
184182
// legalComments: "none", // If we add copyright headers to the source files, uncomment.
185-
plugins: [
186-
{
187-
name: "fix-require",
188-
setup: (build) => {
189-
build.onEnd(async () => {
190-
// esbuild converts calls to "require" to "__require"; this function
191-
// calls the real require if it exists, or throws if it does not (rather than
192-
// throwing an error like "require not defined"). But, since we want typescript
193-
// to be consumable by other bundlers, we need to convert these calls back to
194-
// require so our imports are visible again.
195-
//
196-
// The leading spaces are to keep the offsets the same within the files to keep
197-
// source maps working (though this only really matters for the line the require is on).
198-
//
199-
// See: https://github.com/evanw/esbuild/issues/1905
200-
let contents = await fs.promises.readFile(outfile, "utf-8");
201-
contents = contents.replace(/__require\(/g, " require(");
202-
await fs.promises.writeFile(outfile, contents);
203-
});
204-
},
205-
}
206-
]
207183
};
208184

209185
if (taskOptions.exportIsTsObject) {
@@ -213,14 +189,61 @@ function createBundler(entrypoint, outfile, taskOptions = {}) {
213189
options.globalName = "ts";
214190
// If we are in a CJS context, export the ts namespace.
215191
options.footer = { js: `\nif (typeof module !== "undefined" && module.exports) { module.exports = ts; }` };
192+
193+
// esbuild converts calls to "require" to "__require"; this function
194+
// calls the real require if it exists, or throws if it does not (rather than
195+
// throwing an error like "require not defined"). But, since we want typescript
196+
// to be consumable by other bundlers, we need to convert these calls back to
197+
// require so our imports are visible again.
198+
//
199+
// The leading spaces are to keep the offsets the same within the files to keep
200+
// source maps working (though this only really matters for the line the require is on).
201+
//
202+
// See: https://github.com/evanw/esbuild/issues/1905
203+
options.define = { require: "$$require" };
204+
options.plugins = [
205+
{
206+
name: "fix-require",
207+
setup: (build) => {
208+
build.onEnd(async () => {
209+
let contents = await fs.promises.readFile(outfile, "utf-8");
210+
contents = contents.replace(/\$\$require/g, " require");
211+
await fs.promises.writeFile(outfile, contents);
212+
});
213+
},
214+
}
215+
];
216216
}
217217

218218
return options;
219219
});
220220

221221
return {
222222
build: async () => esbuild.build(await getOptions()),
223-
watch: async () => esbuild.build({ ...await getOptions(), watch: taskOptions.watchMode ?? true, logLevel: "info" }),
223+
watch: async () => {
224+
/** @type {esbuild.BuildOptions} */
225+
const options = { ...await getOptions(), logLevel: "info" };
226+
if (taskOptions.onWatchRebuild) {
227+
const onRebuild = taskOptions.onWatchRebuild;
228+
options.plugins = (options.plugins?.slice(0) ?? []).concat([{
229+
name: "watch",
230+
setup: (build) => {
231+
let firstBuild = true;
232+
build.onEnd(() => {
233+
if (firstBuild) {
234+
firstBuild = false;
235+
}
236+
else {
237+
onRebuild();
238+
}
239+
});
240+
}
241+
}]);
242+
}
243+
244+
const ctx = await esbuild.context(options);
245+
ctx.watch();
246+
},
224247
};
225248
}
226249

@@ -426,10 +449,8 @@ const { main: tests, watch: watchTests } = entrypointBuildTask({
426449
bundlerOptions: {
427450
// Ensure we never drop any dead code, which might be helpful while debugging.
428451
treeShaking: false,
429-
watchMode: {
430-
onRebuild() {
431-
watchTestsEmitter.emit("rebuild");
432-
}
452+
onWatchRebuild() {
453+
watchTestsEmitter.emit("rebuild");
433454
}
434455
},
435456
});
@@ -494,6 +515,7 @@ const { main: watchGuard, watch: watchWatchGuard } = entrypointBuildTask({
494515
export const generateTypesMap = task({
495516
name: "generate-types-map",
496517
run: async () => {
518+
await fs.promises.mkdir("./built/local", { recursive: true });
497519
const source = "src/server/typesMap.json";
498520
const target = "built/local/typesMap.json";
499521
const contents = await fs.promises.readFile(source, "utf-8");

0 commit comments

Comments
 (0)