Skip to content
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

Convert the codebase to modules #51387

Merged
merged 36 commits into from Nov 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
df89c74
Make a few changes to allow all code to be loaded as one project
jakebailey Jul 26, 2022
7698653
Explicitly reference ts namespace in tsserverlibrary
jakebailey Jul 26, 2022
94724a8
Generated module conversion step - unindent
jakebailey Nov 7, 2022
9a0b85c
Generated module conversion step - explicitify
jakebailey Nov 7, 2022
b6c0538
Generated module conversion step - stripNamespaces
jakebailey Nov 7, 2022
07758c0
Generated module conversion step - inlineImports
jakebailey Nov 7, 2022
5f5ccc9
Generated module conversion step - .git-ignore-blame-revs
jakebailey Nov 7, 2022
d5274a9
Add gitlens settings suggestion
jakebailey Oct 14, 2022
180554c
Make processDiagnosticMessages generate a module
jakebailey May 26, 2022
39e27fb
Fix up linting, make lint clean
jakebailey Sep 7, 2022
8bd5e54
Undo changes needed to load codebase into ts-morph
jakebailey Oct 3, 2022
231fa27
Add JSDoc eslint rule
jakebailey Sep 24, 2022
d12116d
Fix all internal JSDoc comments
jakebailey Sep 7, 2022
01e5200
Convert require calls to imports
jakebailey May 27, 2022
6dfa429
Remove typescriptServices, protocol.d.ts, typescript_standalone.d.ts
jakebailey Sep 13, 2022
36e2944
Get codebase building pre bundling
jakebailey May 31, 2022
4139807
Add build via esbuild
jakebailey Sep 13, 2022
c651422
Add dts bundling
jakebailey Sep 2, 2022
dc92488
Consolidate checks that test if the current environment is Node
jakebailey Sep 26, 2022
776907c
Add ts to globalThis in run.js for convenience during debugging
jakebailey Sep 30, 2022
f45cc45
Rename Gulpfile to Herebyfile for improved git diff
jakebailey Oct 9, 2022
3cd72e7
Change build system to hereby
jakebailey Oct 9, 2022
d0db80e
Update baselines for corrected line endings in lib files
jakebailey Oct 10, 2022
394c4ae
Use jsonc-parser instead of LKG compiler in build
jakebailey Oct 9, 2022
aec2761
Modernize localize script, use new XML library
jakebailey Oct 10, 2022
bbc906d
Don't use needsUpdate for quick tasks
jakebailey Oct 10, 2022
acfe7ac
Remove mkdirp
jakebailey Oct 10, 2022
8486229
Export ts namespace from tsserver for hacky-post patching
jakebailey Oct 13, 2022
db440d8
Directly import namespaces for improved esbuild output
jakebailey Oct 18, 2022
c5a9573
Ensure ts object passed to plugins contains deprecatedCompat declarat…
jakebailey Oct 18, 2022
25a85d1
Move compiler-debug into Debug namespace, which allows the compiler t…
jakebailey Oct 15, 2022
43cf787
Remove Promise redeclaration
jakebailey Oct 19, 2022
b9e24ee
Remove globalThisShim and globalThis modification for TypeScriptServi…
jakebailey Oct 19, 2022
8edbf8d
Disable slow CodeQL queries
jakebailey Oct 22, 2022
7988e40
Remove outFiles from launch.json
jakebailey Oct 25, 2022
da6f067
Remove dynamicImport and setDynamicImport
jakebailey Nov 7, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Expand Up @@ -4,4 +4,4 @@
ARG VARIANT="14-buster"
FROM mcr.microsoft.com/vscode/devcontainers/javascript-node:0-${VARIANT}

RUN sudo -u node npm install -g gulp-cli
RUN sudo -u node npm install -g hereby
2 changes: 1 addition & 1 deletion .eslintignore
@@ -1,5 +1,5 @@
**/node_modules/**
/built/local/**
/built/**
/tests/**
/lib/**
/src/lib/*.generated.d.ts
Expand Down
2 changes: 1 addition & 1 deletion .eslintrc.json
Expand Up @@ -87,7 +87,7 @@
"local/simple-indent": "error",
"local/debug-assert": "error",
"local/no-keywords": "error",
"local/one-namespace-per-file": "error",
"local/jsdoc-format": "error",

// eslint-plugin-import
"import/no-extraneous-dependencies": ["error", { "optionalDependencies": false }],
Expand Down
8 changes: 8 additions & 0 deletions .git-blame-ignore-revs
@@ -0,0 +1,8 @@
# Generated module conversion step - inlineImports
07758c08ab72481885e662c98d67a0e3a071b032
# Generated module conversion step - stripNamespaces
b6c053882696af8ddd94a600429f30584d303d7f
# Generated module conversion step - explicitify
9a0b85ce2a3f85f498ab2c05474b4c0b96b111c9
# Generated module conversion step - unindent
94724a8c2e68a4c7e267072ca79971f317c45e4a
26 changes: 26 additions & 0 deletions .github/codeql/codeql-configuration.yml
Expand Up @@ -6,3 +6,29 @@ paths:
- Gulpfile.mjs
paths-ignore:
- src/lib

# These queries appear to time out after the module conversion.
# https://github.com/github/codeql/issues/10937
jakebailey marked this conversation as resolved.
Show resolved Hide resolved
query-filters:
- exclude:
id: js/path-injection # TaintedPath.ql
- exclude:
id: js/command-line-injection # CommandInjection.ql
- exclude:
id: js/code-injection # CodeInjection.ql
- exclude:
id: js/bad-code-sanitization # ImproperCodeSanitization.ql
- exclude:
id: js/unsafe-dynamic-method-access # UnsafeDynamicMethodAccess.ql
- exclude:
id: js/clear-text-logging # CleartextLogging.ql
- exclude:
id: js/regex-injection # RegExpInjection.ql
- exclude:
id: js/unvalidated-dynamic-method-call # UnvalidatedDynamicMethodCall.ql
- exclude:
id: js/insecure-download # InsecureDownload.ql
- exclude:
id: js/prototype-polluting-assignment # PrototypePollutingAssignment.ql
- exclude:
id: js/request-forgery # RequestForgery.ql
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Expand Up @@ -4,7 +4,7 @@ Thank you for submitting a pull request!
Please verify that:
* [ ] There is an associated issue in the `Backlog` milestone (**required**)
* [ ] Code is up-to-date with the `main` branch
* [ ] You've successfully run `gulp runtests` locally
* [ ] You've successfully run `hereby runtests` locally
* [ ] There are new or updated unit tests validating the change

Refer to CONTRIBUTING.MD for more details.
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/accept-baselines-fix-lints.yaml
Expand Up @@ -17,8 +17,8 @@ jobs:
git config user.name "TypeScript Bot"
npm install
git rm -r --quiet tests/baselines/reference :^tests/baselines/reference/docker :^tests/baselines/reference/user
gulp runtests-parallel --ci --fix || true
gulp baseline-accept
npx hereby runtests-parallel --ci --fix || true
npx hereby baseline-accept
git add ./src
git add ./tests/baselines/reference
git diff --cached
Expand Down
53 changes: 46 additions & 7 deletions .github/workflows/ci.yml
Expand Up @@ -21,6 +21,13 @@ jobs:
- "*"
- lts/*
- lts/-1
bundle:
- "true"
include:
- node-version: "*"
bundle: "false"

name: Test Node ${{ matrix.node-version }} with --bundle=${{ matrix.bundle }}

steps:
- uses: actions/checkout@v3
Expand All @@ -32,7 +39,7 @@ jobs:
- run: npm ci

- name: Tests
run: npm test
run: npm run test -- --bundle=${{ matrix.bundle }}

lint:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -62,11 +69,23 @@ jobs:
- name: Adding playwright
run: npm install --no-save --no-package-lock playwright

- name: Build local
run: gulp local

- name: Validate the browser can import TypeScript
run: gulp test-browser-integration
run: npx hereby test-browser-integration

typecheck:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: "*"
check-latest: true
- run: npm ci

- name: Build src
run: npx hereby build-src


misc:
runs-on: ubuntu-latest
Expand All @@ -80,7 +99,27 @@ jobs:
- run: npm ci

- name: Build scripts
run: gulp scripts
run: npx hereby scripts

- name: ESLint tests
run: gulp run-eslint-rules-tests
run: npx hereby run-eslint-rules-tests

self-check:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: "*"
check-latest: true
- run: npm ci

- name: Build tsc
run: npx hereby tsc

- name: Clean
run: npx hereby clean-src

- name: Self build
run: npx hereby build-src --built
2 changes: 1 addition & 1 deletion .github/workflows/new-release-branch.yaml
Expand Up @@ -21,7 +21,7 @@ jobs:
sed -i -e 's/const versionMajorMinor = ".*"/const versionMajorMinor = "${{ github.event.client_payload.core_major_minor }}"/g' tests/baselines/reference/api/tsserverlibrary.d.ts
sed -i -e 's/const version\(: string\)\{0,1\} = `${versionMajorMinor}.0-.*`/const version = `${versionMajorMinor}.0-${{ github.event.client_payload.core_tag || 'dev' }}`/g' src/compiler/corePublic.ts
npm ci
gulp LKG
npx hereby LKG
npm test
git diff
git add package.json
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/nightly.yaml
Expand Up @@ -23,10 +23,10 @@ jobs:
run: |
npm whoami
npm ci
gulp configure-nightly
gulp LKG
gulp runtests-parallel
gulp clean
npx hereby configure-nightly
npx hereby LKG
npx hereby runtests-parallel
npx hereby clean
npm publish --tag next
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
6 changes: 3 additions & 3 deletions .github/workflows/release-branch-artifact.yaml
Expand Up @@ -19,11 +19,11 @@ jobs:
- name: Adding playwright
run: npm install --no-save --no-package-lock playwright
- name: Validate the browser can import TypeScript
run: gulp test-browser-integration
run: npx hereby test-browser-integration
- name: LKG, clean, and pack
run: |
gulp LKG
gulp clean
npx hereby LKG
npx hereby clean
npm pack ./
mv typescript-*.tgz typescript.tgz
- name: Upload built tarfile
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/set-version.yaml
Expand Up @@ -27,7 +27,7 @@ jobs:
sed -i -e 's/const versionMajorMinor = ".*"/const versionMajorMinor = "${{ github.event.client_payload.core_major_minor }}"/g' tests/baselines/reference/api/tsserverlibrary.d.ts
sed -i -e 's/const version\(: string\)\{0,1\} = .*;/const version = "${{ github.event.client_payload.package_version }}" as string;/g' src/compiler/corePublic.ts
npm ci
gulp LKG
npx hereby LKG
npm test
git diff
git add package.json
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update-lkg.yml
Expand Up @@ -16,7 +16,7 @@ jobs:
git config user.email "typescriptbot@microsoft.com"
git config user.name "TypeScript Bot"
npm ci
gulp LKG
npx hereby LKG
npm test
git diff
git add ./lib
Expand Down
19 changes: 19 additions & 0 deletions .gulp.js
@@ -0,0 +1,19 @@
const cp = require("child_process");
const path = require("path");
const chalk = require("chalk");

const argv = process.argv.slice(2);

// --tasks-simple is used by VS Code to infer a task list; try and keep that working.
if (!argv.includes("--tasks-simple")) {
console.error(chalk.yellowBright("Warning: using gulp shim; please consider running hereby directly."));
}

const args = [
...process.execArgv,
path.join(__dirname, "node_modules", "hereby", "bin", "hereby.js"),
...argv,
];

const { status } = cp.spawnSync(process.execPath, args, { stdio: "inherit" });
process.exit(status ?? 1);
10 changes: 3 additions & 7 deletions .vscode/launch.template.json
Expand Up @@ -20,7 +20,6 @@
"configurations": [
{
"type": "node",
"protocol": "inspector",
"request": "launch",
"name": "Mocha Tests (currently opened test)",
"runtimeArgs": ["--nolazy"],
Expand All @@ -43,20 +42,17 @@
},
"sourceMaps": true,
"smartStep": true,
"preLaunchTask": "gulp: tests",
"preLaunchTask": "npm: build:tests",
"console": "integratedTerminal",
"outFiles": [
"${workspaceRoot}/built/local/run.js"
],
"customDescriptionGenerator": "'__tsDebuggerDisplay' in this ? this.__tsDebuggerDisplay(defaultValue) : defaultValue",
"customDescriptionGenerator": "'__tsDebuggerDisplay' in this ? this.__tsDebuggerDisplay(defaultValue) : defaultValue"
},
{
// See: https://github.com/microsoft/TypeScript/wiki/Debugging-Language-Service-in-VS-Code
"type": "node",
"request": "attach",
"name": "Attach to VS Code TS Server via Port",
"processId": "${command:PickProcess}",
"customDescriptionGenerator": "'__tsDebuggerDisplay' in this ? this.__tsDebuggerDisplay(defaultValue) : defaultValue",
"customDescriptionGenerator": "'__tsDebuggerDisplay' in this ? this.__tsDebuggerDisplay(defaultValue) : defaultValue"
}
]
}
14 changes: 14 additions & 0 deletions .vscode/settings.template.json
Expand Up @@ -6,4 +6,18 @@

// To use the locally built compiler, after 'npm run build':
// "typescript.tsdk": "built/local"

// To ignore commits listed in .git-blame-ignore-revs in GitLens:
// "gitlens.advanced.blame.customArguments": [
// "--ignore-revs-file",
// ".git-blame-ignore-revs"
// ]

// These options search the repo recursively and slow down
// the build task menu. We define our own in tasks.json.
"typescript.tsc.autoDetect": "off",
"npm.autoDetect": "off",
"grunt.autoDetect": "off",
"jake.autoDetect": "off",
"gulp.autoDetect": "off"
}
49 changes: 29 additions & 20 deletions .vscode/tasks.json
Expand Up @@ -4,42 +4,51 @@
"version": "2.0.0",
"tasks": [
{
"type": "gulp",
"label": "gulp: local",
"task": "local",
"group": {
"kind": "build",
"isDefault": true
},
// Kept for backwards compat for old launch.json files so it's
// less annoying if moving up to the new build or going back to
// the old build.
//
// This is first because the acutal "npm: build:tests" task
// below has the same script value, and VS Code ignores labels
// and deduplicates them.
// https://github.com/microsoft/vscode/issues/93001
"label": "gulp: tests",
"type": "npm",
"script": "build:tests",
"group": "build",
"hide": true,
"problemMatcher": [
"$tsc"
]
},
{
"type": "gulp",
"label": "gulp: tsc",
"task": "tsc",
"label": "tsc: watch ./src",
"type": "shell",
"command": "node",
"args": ["${workspaceFolder}/lib/tsc.js", "--build", "${workspaceFolder}/src", "--watch"],
"group": "build",
"isBackground": true,
"problemMatcher": [
"$tsc"
"$tsc-watch"
]
},
{
"type": "gulp",
"label": "gulp: tests",
"task": "tests",
"label": "npm: build:compiler",
"type": "npm",
"script": "build:compiler",
"group": "build",
"problemMatcher": [
"$tsc"
]
},
{
"type": "gulp",
"task": "services",
"label": "gulp: services",
"label": "npm: build:tests",
"type": "npm",
"script": "build:tests",
"group": "build",
"problemMatcher": [
"$tsc"
],
}
]
},
]
}
}