diff --git a/.eslintignore b/.eslintignore index 0299f2c1080..a742b0ae304 100644 --- a/.eslintignore +++ b/.eslintignore @@ -30,13 +30,6 @@ **/src/vs/*/**/*.d.ts **/src/vs/base/test/common/filters.perf.data.js **/src/vs/loader.js -**/src2/**/dompurify.js -**/src2/**/marked.js -**/src2/**/semver.js -**/src2/typings/**/*.d.ts -**/src2/vs/*/**/*.d.ts -**/src2/vs/base/test/common/filters.perf.data.js -**/src2/vs/loader.js **/test/unit/assert.js **/test/unit/assert-esm.js **/test/automation/out/** diff --git a/.vscode/settings.json b/.vscode/settings.json index 1f0f99b5df7..15945149179 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -52,8 +52,7 @@ "extensions/**/out/**": true, "test/smoke/out/**": true, "test/automation/out/**": true, - "test/integration/browser/out/**": true, - "src2/**": true, + "test/integration/browser/out/**": true }, "files.readonlyExclude": { "build/builtin/*.js": true, diff --git a/build/azure-pipelines/darwin/product-build-darwin-test.yml b/build/azure-pipelines/darwin/product-build-darwin-test.yml index 937d9d70c3e..359aa460a59 100644 --- a/build/azure-pipelines/darwin/product-build-darwin-test.yml +++ b/build/azure-pipelines/darwin/product-build-darwin-test.yml @@ -7,9 +7,6 @@ parameters: type: boolean - name: VSCODE_RUN_SMOKE_TESTS type: boolean - - name: VSCODE_BUILD_AMD - type: boolean - default: false steps: - script: npm exec -- npm-run-all -lp "electron $(VSCODE_ARCH)" "playwright-install" @@ -20,56 +17,30 @@ steps: - ${{ if eq(parameters.VSCODE_RUN_UNIT_TESTS, true) }}: - ${{ if eq(parameters.VSCODE_QUALITY, 'oss') }}: - - ${{ if eq(parameters.VSCODE_BUILD_AMD, true) }}: - - script: ./scripts/test-amd.sh --tfs "Unit Tests" - displayName: Run unit tests (Electron) [AMD] - timeoutInMinutes: 15 - - script: npm run test-node-amd - displayName: Run unit tests (node.js) [AMD] - timeoutInMinutes: 15 - - script: npm run test-browser-amd-no-install -- --sequential --browser chromium --browser webkit --tfs "Browser Unit Tests" - env: - DEBUG: "*browser*" - displayName: Run unit tests (Browser, Chromium & Webkit) [AMD] - timeoutInMinutes: 30 - - ${{ if eq(parameters.VSCODE_BUILD_AMD, false) }}: - - script: ./scripts/test.sh --tfs "Unit Tests" - displayName: Run unit tests (Electron) - timeoutInMinutes: 15 - - script: npm run test-node - displayName: Run unit tests (node.js) - timeoutInMinutes: 15 - - script: npm run test-browser-no-install -- --sequential --browser chromium --browser webkit --tfs "Browser Unit Tests" - env: - DEBUG: "*browser*" - displayName: Run unit tests (Browser, Chromium & Webkit) - timeoutInMinutes: 30 + - script: ./scripts/test.sh --tfs "Unit Tests" + displayName: Run unit tests (Electron) + timeoutInMinutes: 15 + - script: npm run test-node + displayName: Run unit tests (node.js) + timeoutInMinutes: 15 + - script: npm run test-browser-no-install -- --sequential --browser chromium --browser webkit --tfs "Browser Unit Tests" + env: + DEBUG: "*browser*" + displayName: Run unit tests (Browser, Chromium & Webkit) + timeoutInMinutes: 30 - ${{ if ne(parameters.VSCODE_QUALITY, 'oss') }}: - - ${{ if eq(parameters.VSCODE_BUILD_AMD, true) }}: - - script: ./scripts/test-amd.sh --build --tfs "Unit Tests" - displayName: Run unit tests (Electron) [AMD] - timeoutInMinutes: 15 - - script: npm run test-node-amd -- --build - displayName: Run unit tests (node.js) [AMD] - timeoutInMinutes: 15 - - script: npm run test-browser-amd-no-install -- --sequential --build --browser chromium --browser webkit --tfs "Browser Unit Tests" - env: - DEBUG: "*browser*" - displayName: Run unit tests (Browser, Chromium & Webkit) [AMD] - timeoutInMinutes: 30 - - ${{ if eq(parameters.VSCODE_BUILD_AMD, false) }}: - - script: ./scripts/test.sh --build --tfs "Unit Tests" - displayName: Run unit tests (Electron) - timeoutInMinutes: 15 - - script: npm run test-node -- --build - displayName: Run unit tests (node.js) - timeoutInMinutes: 15 - - script: npm run test-browser-no-install -- --sequential --build --browser chromium --browser webkit --tfs "Browser Unit Tests" - env: - DEBUG: "*browser*" - displayName: Run unit tests (Browser, Chromium & Webkit) - timeoutInMinutes: 30 + - script: ./scripts/test.sh --build --tfs "Unit Tests" + displayName: Run unit tests (Electron) + timeoutInMinutes: 15 + - script: npm run test-node -- --build + displayName: Run unit tests (node.js) + timeoutInMinutes: 15 + - script: npm run test-browser-no-install -- --sequential --build --browser chromium --browser webkit --tfs "Browser Unit Tests" + env: + DEBUG: "*browser*" + displayName: Run unit tests (Browser, Chromium & Webkit) + timeoutInMinutes: 30 - ${{ if eq(parameters.VSCODE_RUN_INTEGRATION_TESTS, true) }}: - script: | @@ -94,44 +65,24 @@ steps: displayName: Build integration tests - ${{ if eq(parameters.VSCODE_QUALITY, 'oss') }}: - - ${{ if eq(parameters.VSCODE_BUILD_AMD, true) }}: - - script: ./scripts/test-integration-amd.sh --tfs "Integration Tests" - displayName: Run integration tests (Electron) [AMD] - timeoutInMinutes: 20 - - ${{ if eq(parameters.VSCODE_BUILD_AMD, false) }}: - - script: ./scripts/test-integration --tfs "Integration Tests" - displayName: Run integration tests (Electron) - timeoutInMinutes: 20 + - script: ./scripts/test-integration --tfs "Integration Tests" + displayName: Run integration tests (Electron) + timeoutInMinutes: 20 - ${{ if ne(parameters.VSCODE_QUALITY, 'oss') }}: - - ${{ if eq(parameters.VSCODE_BUILD_AMD, true) }}: - - script: | - # Figure out the full absolute path of the product we just built - # including the remote server and configure the integration tests - # to run with these builds instead of running out of sources. - set -e - APP_ROOT="$(agent.builddirectory)/VSCode-darwin-$(VSCODE_ARCH)" - APP_NAME="`ls $APP_ROOT | head -n 1`" - INTEGRATION_TEST_ELECTRON_PATH="$APP_ROOT/$APP_NAME/Contents/MacOS/Electron" \ - ./scripts/test-integration-amd.sh --build --tfs "Integration Tests" - env: - VSCODE_REMOTE_SERVER_PATH: $(agent.builddirectory)/vscode-server-darwin-$(VSCODE_ARCH) - displayName: Run integration tests (Electron) [AMD] - timeoutInMinutes: 20 - - ${{ if eq(parameters.VSCODE_BUILD_AMD, false) }}: - - script: | - # Figure out the full absolute path of the product we just built - # including the remote server and configure the integration tests - # to run with these builds instead of running out of sources. - set -e - APP_ROOT="$(agent.builddirectory)/VSCode-darwin-$(VSCODE_ARCH)" - APP_NAME="`ls $APP_ROOT | head -n 1`" - INTEGRATION_TEST_ELECTRON_PATH="$APP_ROOT/$APP_NAME/Contents/MacOS/Electron" \ - ./scripts/test-integration.sh --build --tfs "Integration Tests" - env: - VSCODE_REMOTE_SERVER_PATH: $(agent.builddirectory)/vscode-server-darwin-$(VSCODE_ARCH) - displayName: Run integration tests (Electron) - timeoutInMinutes: 20 + - script: | + # Figure out the full absolute path of the product we just built + # including the remote server and configure the integration tests + # to run with these builds instead of running out of sources. + set -e + APP_ROOT="$(agent.builddirectory)/VSCode-darwin-$(VSCODE_ARCH)" + APP_NAME="`ls $APP_ROOT | head -n 1`" + INTEGRATION_TEST_ELECTRON_PATH="$APP_ROOT/$APP_NAME/Contents/MacOS/Electron" \ + ./scripts/test-integration.sh --build --tfs "Integration Tests" + env: + VSCODE_REMOTE_SERVER_PATH: $(agent.builddirectory)/vscode-server-darwin-$(VSCODE_ARCH) + displayName: Run integration tests (Electron) + timeoutInMinutes: 20 - script: ./scripts/test-web-integration.sh --browser webkit env: diff --git a/build/azure-pipelines/darwin/product-build-darwin.yml b/build/azure-pipelines/darwin/product-build-darwin.yml index a76ab27b520..c863c60d502 100644 --- a/build/azure-pipelines/darwin/product-build-darwin.yml +++ b/build/azure-pipelines/darwin/product-build-darwin.yml @@ -9,9 +9,6 @@ parameters: type: boolean - name: VSCODE_RUN_SMOKE_TESTS type: boolean - - name: VSCODE_BUILD_AMD - type: boolean - default: false steps: - ${{ if eq(parameters.VSCODE_QUALITY, 'oss') }}: @@ -176,7 +173,6 @@ steps: VSCODE_RUN_UNIT_TESTS: ${{ parameters.VSCODE_RUN_UNIT_TESTS }} VSCODE_RUN_INTEGRATION_TESTS: ${{ parameters.VSCODE_RUN_INTEGRATION_TESTS }} VSCODE_RUN_SMOKE_TESTS: ${{ parameters.VSCODE_RUN_SMOKE_TESTS }} - VSCODE_BUILD_AMD: ${{ parameters.VSCODE_BUILD_AMD }} - ${{ elseif and(ne(parameters.VSCODE_CIBUILD, true), ne(parameters.VSCODE_QUALITY, 'oss')) }}: - task: DownloadPipelineArtifact@2 diff --git a/build/azure-pipelines/linux/product-build-linux-legacy-server.yml b/build/azure-pipelines/linux/product-build-linux-legacy-server.yml index ce9d71a5290..649a3d224d9 100644 --- a/build/azure-pipelines/linux/product-build-linux-legacy-server.yml +++ b/build/azure-pipelines/linux/product-build-linux-legacy-server.yml @@ -5,9 +5,6 @@ parameters: type: boolean - name: VSCODE_ARCH type: string - - name: VSCODE_BUILD_AMD - type: boolean - default: false steps: - task: NodeTool@0 @@ -206,7 +203,6 @@ steps: VSCODE_RUN_UNIT_TESTS: false VSCODE_RUN_INTEGRATION_TESTS: ${{ parameters.VSCODE_RUN_INTEGRATION_TESTS }} VSCODE_RUN_SMOKE_TESTS: false - VSCODE_BUILD_AMD: ${{ parameters.VSCODE_BUILD_AMD }} ${{ if ne(parameters.VSCODE_QUALITY, 'oss') }}: PUBLISH_TASK_NAME: 1ES.PublishPipelineArtifact@1 diff --git a/build/azure-pipelines/linux/product-build-linux-test.yml b/build/azure-pipelines/linux/product-build-linux-test.yml index 2443e2b1299..5f7381d487c 100644 --- a/build/azure-pipelines/linux/product-build-linux-test.yml +++ b/build/azure-pipelines/linux/product-build-linux-test.yml @@ -10,9 +10,6 @@ parameters: - name: PUBLISH_TASK_NAME type: string default: PublishPipelineArtifact@0 - - name: VSCODE_BUILD_AMD - type: boolean - default: false steps: - script: npm exec -- npm-run-all -lp "electron $(VSCODE_ARCH)" "playwright-install" @@ -36,61 +33,33 @@ steps: - ${{ if eq(parameters.VSCODE_RUN_UNIT_TESTS, true) }}: - ${{ if eq(parameters.VSCODE_QUALITY, 'oss') }}: - - ${{ if eq(parameters.VSCODE_BUILD_AMD, true) }}: - - script: ./scripts/test-amd.sh --tfs "Unit Tests" - env: - DISPLAY: ":10" - displayName: Run unit tests (Electron) [AMD] - timeoutInMinutes: 15 - - script: npm run test-node-amd - displayName: Run unit tests (node.js) [AMD] - timeoutInMinutes: 15 - - script: npm run test-browser-amd-no-install -- --browser chromium --tfs "Browser Unit Tests" - env: - DEBUG: "*browser*" - displayName: Run unit tests (Browser, Chromium) [AMD] - timeoutInMinutes: 15 - - ${{ if eq(parameters.VSCODE_BUILD_AMD, false) }}: - - script: ./scripts/test.sh --tfs "Unit Tests" - env: - DISPLAY: ":10" - displayName: Run unit tests (Electron) - timeoutInMinutes: 15 - - script: npm run test-node - displayName: Run unit tests (node.js) - timeoutInMinutes: 15 - - script: npm run test-browser-no-install -- --browser chromium --tfs "Browser Unit Tests" - env: - DEBUG: "*browser*" - displayName: Run unit tests (Browser, Chromium) - timeoutInMinutes: 15 + - script: ./scripts/test.sh --tfs "Unit Tests" + env: + DISPLAY: ":10" + displayName: Run unit tests (Electron) + timeoutInMinutes: 15 + - script: npm run test-node + displayName: Run unit tests (node.js) + timeoutInMinutes: 15 + - script: npm run test-browser-no-install -- --browser chromium --tfs "Browser Unit Tests" + env: + DEBUG: "*browser*" + displayName: Run unit tests (Browser, Chromium) + timeoutInMinutes: 15 - ${{ if ne(parameters.VSCODE_QUALITY, 'oss') }}: - - ${{ if eq(parameters.VSCODE_BUILD_AMD, true) }}: - - script: ./scripts/test-amd.sh --build --tfs "Unit Tests" - displayName: Run unit tests (Electron) [AMD] - timeoutInMinutes: 15 - - script: npm run test-node-amd -- --build - displayName: Run unit tests (node.js) [AMD] - timeoutInMinutes: 15 - - script: npm run test-browser-amd-no-install -- --build --browser chromium --tfs "Browser Unit Tests" - env: - DEBUG: "*browser*" - displayName: Run unit tests (Browser, Chromium) [AMD] - timeoutInMinutes: 15 - - ${{ if eq(parameters.VSCODE_BUILD_AMD, false) }}: - - script: ./scripts/test.sh --build --tfs "Unit Tests" - displayName: Run unit tests (Electron) - timeoutInMinutes: 15 - - script: npm run test-node -- --build - displayName: Run unit tests (node.js) - timeoutInMinutes: 15 - - script: npm run test-browser-no-install -- --build --browser chromium --tfs "Browser Unit Tests" - env: - DEBUG: "*browser*" - displayName: Run unit tests (Browser, Chromium) - timeoutInMinutes: 15 + - script: ./scripts/test.sh --build --tfs "Unit Tests" + displayName: Run unit tests (Electron) + timeoutInMinutes: 15 + - script: npm run test-node -- --build + displayName: Run unit tests (node.js) + timeoutInMinutes: 15 + - script: npm run test-browser-no-install -- --build --browser chromium --tfs "Browser Unit Tests" + env: + DEBUG: "*browser*" + displayName: Run unit tests (Browser, Chromium) + timeoutInMinutes: 15 - ${{ if eq(parameters.VSCODE_RUN_INTEGRATION_TESTS, true) }}: - script: | @@ -116,18 +85,11 @@ steps: - ${{ if eq(parameters.VSCODE_RUN_INTEGRATION_TESTS, true) }}: - ${{ if eq(parameters.VSCODE_QUALITY, 'oss') }}: - - ${{ if eq(parameters.VSCODE_BUILD_AMD, true) }}: - - script: ./scripts/test-integration-amd.sh --tfs "Integration Tests" - env: - DISPLAY: ":10" - displayName: Run integration tests (Electron) [AMD] - timeoutInMinutes: 20 - - ${{ if eq(parameters.VSCODE_BUILD_AMD, false) }}: - - script: ./scripts/test-integration.sh --tfs "Integration Tests" - env: - DISPLAY: ":10" - displayName: Run integration tests (Electron) - timeoutInMinutes: 20 + - script: ./scripts/test-integration.sh --tfs "Integration Tests" + env: + DISPLAY: ":10" + displayName: Run integration tests (Electron) + timeoutInMinutes: 20 - script: ./scripts/test-web-integration.sh --browser chromium displayName: Run integration tests (Browser, Chromium) @@ -138,36 +100,20 @@ steps: timeoutInMinutes: 20 - ${{ if ne(parameters.VSCODE_QUALITY, 'oss') }}: - - ${{ if eq(parameters.VSCODE_BUILD_AMD, true) }}: - - script: | - # Figure out the full absolute path of the product we just built - # including the remote server and configure the integration tests - # to run with these builds instead of running out of sources. - set -e - APP_ROOT=$(agent.builddirectory)/VSCode-linux-$(VSCODE_ARCH) - APP_NAME=$(node -p "require(\"$APP_ROOT/resources/app/product.json\").applicationName") - INTEGRATION_TEST_APP_NAME="$APP_NAME" \ - INTEGRATION_TEST_ELECTRON_PATH="$APP_ROOT/$APP_NAME" \ - ./scripts/test-integration-amd.sh --build --tfs "Integration Tests" - env: - VSCODE_REMOTE_SERVER_PATH: $(agent.builddirectory)/vscode-server-linux-$(VSCODE_ARCH) - displayName: Run integration tests (Electron) [AMD] - timeoutInMinutes: 20 - - ${{ if eq(parameters.VSCODE_BUILD_AMD, false) }}: - - script: | - # Figure out the full absolute path of the product we just built - # including the remote server and configure the integration tests - # to run with these builds instead of running out of sources. - set -e - APP_ROOT=$(agent.builddirectory)/VSCode-linux-$(VSCODE_ARCH) - APP_NAME=$(node -p "require(\"$APP_ROOT/resources/app/product.json\").applicationName") - INTEGRATION_TEST_APP_NAME="$APP_NAME" \ - INTEGRATION_TEST_ELECTRON_PATH="$APP_ROOT/$APP_NAME" \ - ./scripts/test-integration.sh --build --tfs "Integration Tests" - env: - VSCODE_REMOTE_SERVER_PATH: $(agent.builddirectory)/vscode-server-linux-$(VSCODE_ARCH) - displayName: Run integration tests (Electron) - timeoutInMinutes: 20 + - script: | + # Figure out the full absolute path of the product we just built + # including the remote server and configure the integration tests + # to run with these builds instead of running out of sources. + set -e + APP_ROOT=$(agent.builddirectory)/VSCode-linux-$(VSCODE_ARCH) + APP_NAME=$(node -p "require(\"$APP_ROOT/resources/app/product.json\").applicationName") + INTEGRATION_TEST_APP_NAME="$APP_NAME" \ + INTEGRATION_TEST_ELECTRON_PATH="$APP_ROOT/$APP_NAME" \ + ./scripts/test-integration.sh --build --tfs "Integration Tests" + env: + VSCODE_REMOTE_SERVER_PATH: $(agent.builddirectory)/vscode-server-linux-$(VSCODE_ARCH) + displayName: Run integration tests (Electron) + timeoutInMinutes: 20 - script: ./scripts/test-web-integration.sh --browser chromium env: diff --git a/build/azure-pipelines/linux/product-build-linux.yml b/build/azure-pipelines/linux/product-build-linux.yml index 3f53731b70a..3fb7b4fe679 100644 --- a/build/azure-pipelines/linux/product-build-linux.yml +++ b/build/azure-pipelines/linux/product-build-linux.yml @@ -11,9 +11,6 @@ parameters: type: boolean - name: VSCODE_ARCH type: string - - name: VSCODE_BUILD_AMD - type: boolean - default: false steps: - ${{ if eq(parameters.VSCODE_QUALITY, 'oss') }}: @@ -290,7 +287,6 @@ steps: VSCODE_RUN_UNIT_TESTS: ${{ parameters.VSCODE_RUN_UNIT_TESTS }} VSCODE_RUN_INTEGRATION_TESTS: ${{ parameters.VSCODE_RUN_INTEGRATION_TESTS }} VSCODE_RUN_SMOKE_TESTS: ${{ parameters.VSCODE_RUN_SMOKE_TESTS }} - VSCODE_BUILD_AMD: ${{ parameters.VSCODE_BUILD_AMD }} ${{ if ne(parameters.VSCODE_QUALITY, 'oss') }}: PUBLISH_TASK_NAME: 1ES.PublishPipelineArtifact@1 diff --git a/build/azure-pipelines/product-build-pr.yml b/build/azure-pipelines/product-build-pr.yml index 025a1eeac67..2d66ff3945d 100644 --- a/build/azure-pipelines/product-build-pr.yml +++ b/build/azure-pipelines/product-build-pr.yml @@ -21,8 +21,6 @@ variables: value: oss - name: VSCODE_STEP_ON_IT value: false - - name: VSCODE_BUILD_AMD - value: false jobs: - ${{ if ne(variables['VSCODE_CIBUILD'], true) }}: @@ -50,7 +48,6 @@ jobs: parameters: VSCODE_ARCH: x64 VSCODE_QUALITY: ${{ variables.VSCODE_QUALITY }} - VSCODE_BUILD_AMD: ${{ variables.VSCODE_BUILD_AMD }} VSCODE_CIBUILD: ${{ variables.VSCODE_CIBUILD }} VSCODE_RUN_UNIT_TESTS: true VSCODE_RUN_INTEGRATION_TESTS: false @@ -69,7 +66,6 @@ jobs: parameters: VSCODE_ARCH: x64 VSCODE_QUALITY: ${{ variables.VSCODE_QUALITY }} - VSCODE_BUILD_AMD: ${{ variables.VSCODE_BUILD_AMD }} VSCODE_CIBUILD: ${{ variables.VSCODE_CIBUILD }} VSCODE_RUN_UNIT_TESTS: false VSCODE_RUN_INTEGRATION_TESTS: true @@ -88,7 +84,6 @@ jobs: parameters: VSCODE_ARCH: x64 VSCODE_QUALITY: ${{ variables.VSCODE_QUALITY }} - VSCODE_BUILD_AMD: ${{ variables.VSCODE_BUILD_AMD }} VSCODE_CIBUILD: ${{ variables.VSCODE_CIBUILD }} VSCODE_RUN_UNIT_TESTS: false VSCODE_RUN_INTEGRATION_TESTS: false @@ -112,7 +107,6 @@ jobs: - template: win32/product-build-win32.yml@self parameters: VSCODE_QUALITY: ${{ variables.VSCODE_QUALITY }} - VSCODE_BUILD_AMD: ${{ variables.VSCODE_BUILD_AMD }} VSCODE_ARCH: x64 VSCODE_CIBUILD: ${{ variables.VSCODE_CIBUILD }} VSCODE_RUN_UNIT_TESTS: true @@ -130,7 +124,6 @@ jobs: - template: win32/product-build-win32.yml@self parameters: VSCODE_QUALITY: ${{ variables.VSCODE_QUALITY }} - VSCODE_BUILD_AMD: ${{ variables.VSCODE_BUILD_AMD }} VSCODE_ARCH: x64 VSCODE_CIBUILD: ${{ variables.VSCODE_CIBUILD }} VSCODE_RUN_UNIT_TESTS: false diff --git a/build/azure-pipelines/product-build.yml b/build/azure-pipelines/product-build.yml index d4038dced08..a061c23e8dc 100644 --- a/build/azure-pipelines/product-build.yml +++ b/build/azure-pipelines/product-build.yml @@ -100,10 +100,6 @@ parameters: displayName: "Skip tests" type: boolean default: false - - name: VSCODE_BUILD_AMD # TODO@bpasero TODO@esm remove me once AMD is removed - displayName: "️❗ Build as AMD (!FOR EMERGENCY ONLY!) ️❗" - type: boolean - default: false variables: - name: VSCODE_PRIVATE_BUILD @@ -114,8 +110,6 @@ variables: value: ${{ parameters.CARGO_REGISTRY }} - name: VSCODE_QUALITY value: ${{ parameters.VSCODE_QUALITY }} - - name: VSCODE_BUILD_AMD - value: ${{ parameters.VSCODE_BUILD_AMD }} - name: VSCODE_BUILD_STAGE_WINDOWS value: ${{ or(eq(parameters.VSCODE_BUILD_WIN32, true), eq(parameters.VSCODE_BUILD_WIN32_ARM64, true)) }} - name: VSCODE_BUILD_STAGE_LINUX @@ -225,7 +219,6 @@ extends: - template: build/azure-pipelines/product-compile.yml@self parameters: VSCODE_QUALITY: ${{ variables.VSCODE_QUALITY }} - VSCODE_BUILD_AMD: ${{ variables.VSCODE_BUILD_AMD }} - ${{ if or(eq(parameters.VSCODE_BUILD_LINUX, true),eq(parameters.VSCODE_BUILD_LINUX_ARMHF, true),eq(parameters.VSCODE_BUILD_LINUX_ARM64, true),eq(parameters.VSCODE_BUILD_ALPINE, true),eq(parameters.VSCODE_BUILD_ALPINE_ARM64, true),eq(parameters.VSCODE_BUILD_MACOS, true),eq(parameters.VSCODE_BUILD_MACOS_ARM64, true),eq(parameters.VSCODE_BUILD_WIN32, true),eq(parameters.VSCODE_BUILD_WIN32_ARM64, true)) }}: - stage: CompileCLI @@ -363,7 +356,6 @@ extends: - template: build/azure-pipelines/win32/product-build-win32.yml@self parameters: VSCODE_QUALITY: ${{ variables.VSCODE_QUALITY }} - VSCODE_BUILD_AMD: ${{ variables.VSCODE_BUILD_AMD }} VSCODE_ARCH: x64 VSCODE_CIBUILD: ${{ variables.VSCODE_CIBUILD }} VSCODE_RUN_UNIT_TESTS: true @@ -378,7 +370,6 @@ extends: - template: build/azure-pipelines/win32/product-build-win32.yml@self parameters: VSCODE_QUALITY: ${{ variables.VSCODE_QUALITY }} - VSCODE_BUILD_AMD: ${{ variables.VSCODE_BUILD_AMD }} VSCODE_ARCH: x64 VSCODE_CIBUILD: ${{ variables.VSCODE_CIBUILD }} VSCODE_RUN_UNIT_TESTS: false @@ -393,7 +384,6 @@ extends: - template: build/azure-pipelines/win32/product-build-win32.yml@self parameters: VSCODE_QUALITY: ${{ variables.VSCODE_QUALITY }} - VSCODE_BUILD_AMD: ${{ variables.VSCODE_BUILD_AMD }} VSCODE_ARCH: x64 VSCODE_CIBUILD: ${{ variables.VSCODE_CIBUILD }} VSCODE_RUN_UNIT_TESTS: false @@ -409,7 +399,6 @@ extends: - template: build/azure-pipelines/win32/product-build-win32.yml@self parameters: VSCODE_QUALITY: ${{ variables.VSCODE_QUALITY }} - VSCODE_BUILD_AMD: ${{ variables.VSCODE_BUILD_AMD }} VSCODE_ARCH: x64 VSCODE_CIBUILD: ${{ variables.VSCODE_CIBUILD }} VSCODE_RUN_UNIT_TESTS: ${{ eq(parameters.VSCODE_STEP_ON_IT, false) }} @@ -433,7 +422,6 @@ extends: - template: build/azure-pipelines/win32/product-build-win32.yml@self parameters: VSCODE_QUALITY: ${{ variables.VSCODE_QUALITY }} - VSCODE_BUILD_AMD: ${{ variables.VSCODE_BUILD_AMD }} VSCODE_ARCH: arm64 VSCODE_CIBUILD: ${{ variables.VSCODE_CIBUILD }} VSCODE_RUN_UNIT_TESTS: false @@ -462,7 +450,6 @@ extends: parameters: VSCODE_ARCH: x64 VSCODE_QUALITY: ${{ variables.VSCODE_QUALITY }} - VSCODE_BUILD_AMD: ${{ variables.VSCODE_BUILD_AMD }} VSCODE_CIBUILD: ${{ variables.VSCODE_CIBUILD }} VSCODE_RUN_UNIT_TESTS: true VSCODE_RUN_INTEGRATION_TESTS: false @@ -478,7 +465,6 @@ extends: parameters: VSCODE_ARCH: x64 VSCODE_QUALITY: ${{ variables.VSCODE_QUALITY }} - VSCODE_BUILD_AMD: ${{ variables.VSCODE_BUILD_AMD }} VSCODE_CIBUILD: ${{ variables.VSCODE_CIBUILD }} VSCODE_RUN_UNIT_TESTS: false VSCODE_RUN_INTEGRATION_TESTS: true @@ -494,7 +480,6 @@ extends: parameters: VSCODE_ARCH: x64 VSCODE_QUALITY: ${{ variables.VSCODE_QUALITY }} - VSCODE_BUILD_AMD: ${{ variables.VSCODE_BUILD_AMD }} VSCODE_CIBUILD: ${{ variables.VSCODE_CIBUILD }} VSCODE_RUN_UNIT_TESTS: false VSCODE_RUN_INTEGRATION_TESTS: false @@ -512,7 +497,6 @@ extends: parameters: VSCODE_ARCH: x64 VSCODE_QUALITY: ${{ variables.VSCODE_QUALITY }} - VSCODE_BUILD_AMD: ${{ variables.VSCODE_BUILD_AMD }} VSCODE_CIBUILD: ${{ variables.VSCODE_CIBUILD }} VSCODE_RUN_UNIT_TESTS: ${{ eq(parameters.VSCODE_STEP_ON_IT, false) }} VSCODE_RUN_INTEGRATION_TESTS: ${{ eq(parameters.VSCODE_STEP_ON_IT, false) }} @@ -538,7 +522,6 @@ extends: parameters: VSCODE_ARCH: armhf VSCODE_QUALITY: ${{ variables.VSCODE_QUALITY }} - VSCODE_BUILD_AMD: ${{ variables.VSCODE_BUILD_AMD }} VSCODE_CIBUILD: ${{ variables.VSCODE_CIBUILD }} VSCODE_RUN_UNIT_TESTS: false VSCODE_RUN_INTEGRATION_TESTS: false @@ -554,7 +537,6 @@ extends: parameters: VSCODE_ARCH: arm64 VSCODE_QUALITY: ${{ variables.VSCODE_QUALITY }} - VSCODE_BUILD_AMD: ${{ variables.VSCODE_BUILD_AMD }} VSCODE_CIBUILD: ${{ variables.VSCODE_CIBUILD }} VSCODE_RUN_UNIT_TESTS: false VSCODE_RUN_INTEGRATION_TESTS: false @@ -579,7 +561,6 @@ extends: parameters: VSCODE_ARCH: x64 VSCODE_QUALITY: ${{ variables.VSCODE_QUALITY }} - VSCODE_BUILD_AMD: ${{ variables.VSCODE_BUILD_AMD }} VSCODE_RUN_INTEGRATION_TESTS: ${{ eq(parameters.VSCODE_STEP_ON_IT, false) }} - ${{ if eq(parameters.VSCODE_BUILD_LINUX_ARMHF_LEGACY_SERVER, true) }}: @@ -592,7 +573,6 @@ extends: parameters: VSCODE_ARCH: armhf VSCODE_QUALITY: ${{ variables.VSCODE_QUALITY }} - VSCODE_BUILD_AMD: ${{ variables.VSCODE_BUILD_AMD }} VSCODE_RUN_INTEGRATION_TESTS: false - ${{ if eq(parameters.VSCODE_BUILD_LINUX_ARM64_LEGACY_SERVER, true) }}: @@ -605,7 +585,6 @@ extends: parameters: VSCODE_ARCH: arm64 VSCODE_QUALITY: ${{ variables.VSCODE_QUALITY }} - VSCODE_BUILD_AMD: ${{ variables.VSCODE_BUILD_AMD }} VSCODE_RUN_INTEGRATION_TESTS: false - ${{ if and(eq(variables['VSCODE_CIBUILD'], false), eq(parameters.VSCODE_COMPILE_ONLY, false), eq(variables['VSCODE_BUILD_STAGE_ALPINE'], true)) }}: @@ -658,7 +637,6 @@ extends: - template: build/azure-pipelines/darwin/product-build-darwin.yml@self parameters: VSCODE_QUALITY: ${{ variables.VSCODE_QUALITY }} - VSCODE_BUILD_AMD: ${{ variables.VSCODE_BUILD_AMD }} VSCODE_CIBUILD: ${{ variables.VSCODE_CIBUILD }} VSCODE_RUN_UNIT_TESTS: true VSCODE_RUN_INTEGRATION_TESTS: false @@ -672,7 +650,6 @@ extends: - template: build/azure-pipelines/darwin/product-build-darwin.yml@self parameters: VSCODE_QUALITY: ${{ variables.VSCODE_QUALITY }} - VSCODE_BUILD_AMD: ${{ variables.VSCODE_BUILD_AMD }} VSCODE_CIBUILD: ${{ variables.VSCODE_CIBUILD }} VSCODE_RUN_UNIT_TESTS: false VSCODE_RUN_INTEGRATION_TESTS: true @@ -686,7 +663,6 @@ extends: - template: build/azure-pipelines/darwin/product-build-darwin.yml@self parameters: VSCODE_QUALITY: ${{ variables.VSCODE_QUALITY }} - VSCODE_BUILD_AMD: ${{ variables.VSCODE_BUILD_AMD }} VSCODE_CIBUILD: ${{ variables.VSCODE_CIBUILD }} VSCODE_RUN_UNIT_TESTS: false VSCODE_RUN_INTEGRATION_TESTS: false @@ -701,7 +677,6 @@ extends: - template: build/azure-pipelines/darwin/product-build-darwin.yml@self parameters: VSCODE_QUALITY: ${{ variables.VSCODE_QUALITY }} - VSCODE_BUILD_AMD: ${{ variables.VSCODE_BUILD_AMD }} VSCODE_CIBUILD: ${{ variables.VSCODE_CIBUILD }} VSCODE_RUN_UNIT_TESTS: false VSCODE_RUN_INTEGRATION_TESTS: false @@ -716,7 +691,6 @@ extends: - template: build/azure-pipelines/darwin/product-build-darwin.yml@self parameters: VSCODE_QUALITY: ${{ variables.VSCODE_QUALITY }} - VSCODE_BUILD_AMD: ${{ variables.VSCODE_BUILD_AMD }} VSCODE_CIBUILD: ${{ variables.VSCODE_CIBUILD }} VSCODE_RUN_UNIT_TESTS: ${{ eq(parameters.VSCODE_STEP_ON_IT, false) }} VSCODE_RUN_INTEGRATION_TESTS: ${{ eq(parameters.VSCODE_STEP_ON_IT, false) }} @@ -748,7 +722,6 @@ extends: - template: build/azure-pipelines/darwin/product-build-darwin.yml@self parameters: VSCODE_QUALITY: ${{ variables.VSCODE_QUALITY }} - VSCODE_BUILD_AMD: ${{ variables.VSCODE_BUILD_AMD }} VSCODE_CIBUILD: ${{ variables.VSCODE_CIBUILD }} VSCODE_RUN_UNIT_TESTS: false VSCODE_RUN_INTEGRATION_TESTS: false diff --git a/build/azure-pipelines/product-compile.yml b/build/azure-pipelines/product-compile.yml index ca8b6a7b3ea..facc7af4bc2 100644 --- a/build/azure-pipelines/product-compile.yml +++ b/build/azure-pipelines/product-compile.yml @@ -1,9 +1,6 @@ parameters: - name: VSCODE_QUALITY type: string - - name: VSCODE_BUILD_AMD - type: boolean - default: false steps: - task: NodeTool@0 @@ -103,10 +100,6 @@ steps: - script: node build/azure-pipelines/distro/mixin-quality displayName: Mixin distro quality - - ${{ if eq(parameters.VSCODE_BUILD_AMD, true) }}: - - script: node migrate.mjs --disable-watch --enable-esm-to-amd - displayName: Migrate ESM -> AMD - - template: common/install-builtin-extensions.yml@self - ${{ if eq(parameters.VSCODE_QUALITY, 'oss') }}: diff --git a/build/azure-pipelines/upload-sourcemaps.js b/build/azure-pipelines/upload-sourcemaps.js index 2a01ab79d6b..83c1cae596d 100644 --- a/build/azure-pipelines/upload-sourcemaps.js +++ b/build/azure-pipelines/upload-sourcemaps.js @@ -8,7 +8,6 @@ const path = require("path"); const es = require("event-stream"); const vfs = require("vinyl-fs"); const util = require("../lib/util"); -const amd_1 = require("../lib/amd"); // @ts-ignore const deps = require("../lib/dependencies"); const identity_1 = require("@azure/identity"); @@ -26,9 +25,6 @@ function src(base, maps = `${base}/**/*.map`) { })); } function main() { - if ((0, amd_1.isAMD)()) { - return Promise.resolve(); // in AMD we run into some issues, but we want to unblock the build for recovery - } const sources = []; // vscode client maps (default) if (!base) { diff --git a/build/azure-pipelines/upload-sourcemaps.ts b/build/azure-pipelines/upload-sourcemaps.ts index aed6446d7e5..8e148c6095f 100644 --- a/build/azure-pipelines/upload-sourcemaps.ts +++ b/build/azure-pipelines/upload-sourcemaps.ts @@ -8,7 +8,6 @@ import * as es from 'event-stream'; import * as Vinyl from 'vinyl'; import * as vfs from 'vinyl-fs'; import * as util from '../lib/util'; -import { isAMD } from '../lib/amd'; // @ts-ignore import * as deps from '../lib/dependencies'; import { ClientSecretCredential } from '@azure/identity'; @@ -30,9 +29,6 @@ function src(base: string, maps = `${base}/**/*.map`) { } function main(): Promise { - if (isAMD()) { - return Promise.resolve(); // in AMD we run into some issues, but we want to unblock the build for recovery - } const sources: any[] = []; // vscode client maps (default) diff --git a/build/azure-pipelines/win32/product-build-win32-test.yml b/build/azure-pipelines/win32/product-build-win32-test.yml index 6c6a0949d0d..cdcccd7684b 100644 --- a/build/azure-pipelines/win32/product-build-win32-test.yml +++ b/build/azure-pipelines/win32/product-build-win32-test.yml @@ -12,9 +12,6 @@ parameters: - name: PUBLISH_TASK_NAME type: string default: PublishPipelineArtifact@0 - - name: VSCODE_BUILD_AMD - type: boolean - default: false steps: - powershell: npm exec -- npm-run-all -lp "electron $(VSCODE_ARCH)" "playwright-install" @@ -25,48 +22,26 @@ steps: - ${{ if eq(parameters.VSCODE_RUN_UNIT_TESTS, true) }}: - ${{ if eq(parameters.VSCODE_QUALITY, 'oss') }}: - - ${{ if eq(parameters.VSCODE_BUILD_AMD, true) }}: - - powershell: .\scripts\test-amd.bat --tfs "Unit Tests" - displayName: Run unit tests (Electron) [AMD] - timeoutInMinutes: 15 - - powershell: npm run test-node-amd - displayName: Run unit tests (node.js) [AMD] - timeoutInMinutes: 15 - - powershell: node test/unit/browser/index.amd.js --sequential --browser chromium --tfs "Browser Unit Tests" - displayName: Run unit tests (Browser, Chromium) [AMD] - timeoutInMinutes: 20 - - ${{ if eq(parameters.VSCODE_BUILD_AMD, false) }}: - - powershell: .\scripts\test.bat --tfs "Unit Tests" - displayName: Run unit tests (Electron) - timeoutInMinutes: 15 - - powershell: npm run test-node - displayName: Run unit tests (node.js) - timeoutInMinutes: 15 - - powershell: node test/unit/browser/index.js --sequential --browser chromium --tfs "Browser Unit Tests" - displayName: Run unit tests (Browser, Chromium) - timeoutInMinutes: 20 + - powershell: .\scripts\test.bat --tfs "Unit Tests" + displayName: Run unit tests (Electron) + timeoutInMinutes: 15 + - powershell: npm run test-node + displayName: Run unit tests (node.js) + timeoutInMinutes: 15 + - powershell: node test/unit/browser/index.js --sequential --browser chromium --tfs "Browser Unit Tests" + displayName: Run unit tests (Browser, Chromium) + timeoutInMinutes: 20 - ${{ if ne(parameters.VSCODE_QUALITY, 'oss') }}: - - ${{ if eq(parameters.VSCODE_BUILD_AMD, true) }}: - - powershell: .\scripts\test-amd.bat --build --tfs "Unit Tests" - displayName: Run unit tests (Electron) [AMD] - timeoutInMinutes: 15 - - script: npm run test-node-amd -- --build - displayName: Run unit tests (node.js) [AMD] - timeoutInMinutes: 15 - - powershell: npm run test-browser-amd-no-install -- --sequential --build --browser chromium --tfs "Browser Unit Tests" - displayName: Run unit tests (Browser, Chromium) [AMD] - timeoutInMinutes: 20 - - ${{ if eq(parameters.VSCODE_BUILD_AMD, false) }}: - - powershell: .\scripts\test.bat --build --tfs "Unit Tests" - displayName: Run unit tests (Electron) - timeoutInMinutes: 15 - - powershell: npm run test-node -- --build - displayName: Run unit tests (node.js) - timeoutInMinutes: 15 - - powershell: npm run test-browser-no-install -- --sequential --build --browser chromium --tfs "Browser Unit Tests" - displayName: Run unit tests (Browser, Chromium) - timeoutInMinutes: 20 + - powershell: .\scripts\test.bat --build --tfs "Unit Tests" + displayName: Run unit tests (Electron) + timeoutInMinutes: 15 + - powershell: npm run test-node -- --build + displayName: Run unit tests (node.js) + timeoutInMinutes: 15 + - powershell: npm run test-browser-no-install -- --sequential --build --browser chromium --tfs "Browser Unit Tests" + displayName: Run unit tests (Browser, Chromium) + timeoutInMinutes: 20 - ${{ if eq(parameters.VSCODE_RUN_INTEGRATION_TESTS, true) }}: - powershell: | @@ -98,14 +73,9 @@ steps: condition: succeededOrFailed() - ${{ if eq(parameters.VSCODE_QUALITY, 'oss') }}: - - ${{ if eq(parameters.VSCODE_BUILD_AMD, true) }}: - - powershell: .\scripts\test-integration-amd.bat --tfs "Integration Tests" - displayName: Run integration tests (Electron) [AMD] - timeoutInMinutes: 20 - - ${{ if eq(parameters.VSCODE_BUILD_AMD, false) }}: - - powershell: .\scripts\test-integration.bat --tfs "Integration Tests" - displayName: Run integration tests (Electron) - timeoutInMinutes: 20 + - powershell: .\scripts\test-integration.bat --tfs "Integration Tests" + displayName: Run integration tests (Electron) + timeoutInMinutes: 20 - powershell: .\scripts\test-web-integration.bat --browser chromium displayName: Run integration tests (Browser, Chromium) @@ -116,36 +86,20 @@ steps: timeoutInMinutes: 20 - ${{ if ne(parameters.VSCODE_QUALITY, 'oss') }}: - - ${{ if eq(parameters.VSCODE_BUILD_AMD, true) }}: - - powershell: | - # Figure out the full absolute path of the product we just built - # including the remote server and configure the integration tests - # to run with these builds instead of running out of sources. - . build/azure-pipelines/win32/exec.ps1 - $ErrorActionPreference = "Stop" - $AppRoot = "$(agent.builddirectory)\VSCode-win32-$(VSCODE_ARCH)" - $AppProductJson = Get-Content -Raw -Path "$AppRoot\resources\app\product.json" | ConvertFrom-Json - $AppNameShort = $AppProductJson.nameShort - $env:INTEGRATION_TEST_ELECTRON_PATH = "$AppRoot\$AppNameShort.exe" - $env:VSCODE_REMOTE_SERVER_PATH = "$(agent.builddirectory)\vscode-server-win32-$(VSCODE_ARCH)" - exec { .\scripts\test-integration-amd.bat --build --tfs "Integration Tests" } - displayName: Run integration tests (Electron) [AMD] - timeoutInMinutes: 20 - - ${{ if eq(parameters.VSCODE_BUILD_AMD, false) }}: - - powershell: | - # Figure out the full absolute path of the product we just built - # including the remote server and configure the integration tests - # to run with these builds instead of running out of sources. - . build/azure-pipelines/win32/exec.ps1 - $ErrorActionPreference = "Stop" - $AppRoot = "$(agent.builddirectory)\VSCode-win32-$(VSCODE_ARCH)" - $AppProductJson = Get-Content -Raw -Path "$AppRoot\resources\app\product.json" | ConvertFrom-Json - $AppNameShort = $AppProductJson.nameShort - $env:INTEGRATION_TEST_ELECTRON_PATH = "$AppRoot\$AppNameShort.exe" - $env:VSCODE_REMOTE_SERVER_PATH = "$(agent.builddirectory)\vscode-server-win32-$(VSCODE_ARCH)" - exec { .\scripts\test-integration.bat --build --tfs "Integration Tests" } - displayName: Run integration tests (Electron) - timeoutInMinutes: 20 + - powershell: | + # Figure out the full absolute path of the product we just built + # including the remote server and configure the integration tests + # to run with these builds instead of running out of sources. + . build/azure-pipelines/win32/exec.ps1 + $ErrorActionPreference = "Stop" + $AppRoot = "$(agent.builddirectory)\VSCode-win32-$(VSCODE_ARCH)" + $AppProductJson = Get-Content -Raw -Path "$AppRoot\resources\app\product.json" | ConvertFrom-Json + $AppNameShort = $AppProductJson.nameShort + $env:INTEGRATION_TEST_ELECTRON_PATH = "$AppRoot\$AppNameShort.exe" + $env:VSCODE_REMOTE_SERVER_PATH = "$(agent.builddirectory)\vscode-server-win32-$(VSCODE_ARCH)" + exec { .\scripts\test-integration.bat --build --tfs "Integration Tests" } + displayName: Run integration tests (Electron) + timeoutInMinutes: 20 - powershell: | . build/azure-pipelines/win32/exec.ps1 diff --git a/build/azure-pipelines/win32/product-build-win32.yml b/build/azure-pipelines/win32/product-build-win32.yml index dddcb34a894..a30d4ca8029 100644 --- a/build/azure-pipelines/win32/product-build-win32.yml +++ b/build/azure-pipelines/win32/product-build-win32.yml @@ -11,9 +11,6 @@ parameters: type: boolean - name: VSCODE_RUN_SMOKE_TESTS type: boolean - - name: VSCODE_BUILD_AMD - type: boolean - default: false steps: - ${{ if eq(parameters.VSCODE_QUALITY, 'oss') }}: @@ -182,7 +179,6 @@ steps: VSCODE_RUN_UNIT_TESTS: ${{ parameters.VSCODE_RUN_UNIT_TESTS }} VSCODE_RUN_INTEGRATION_TESTS: ${{ parameters.VSCODE_RUN_INTEGRATION_TESTS }} VSCODE_RUN_SMOKE_TESTS: ${{ parameters.VSCODE_RUN_SMOKE_TESTS }} - VSCODE_BUILD_AMD: ${{ parameters.VSCODE_BUILD_AMD }} ${{ if ne(parameters.VSCODE_QUALITY, 'oss') }}: PUBLISH_TASK_NAME: 1ES.PublishPipelineArtifact@1 diff --git a/build/buildfile.js b/build/buildfile.js index 0e323ac0faf..279f407c036 100644 --- a/build/buildfile.js +++ b/build/buildfile.js @@ -3,8 +3,6 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -const { isAMD } = require('./lib/amd'); - /** * @param {string} name * @param {string[]=} exclude @@ -70,34 +68,16 @@ exports.workerProfileAnalysis = createEditorWorkerModuleDescription('vs/platform exports.workerOutputLinks = createEditorWorkerModuleDescription('vs/workbench/contrib/output/common/outputLinkComputer'); exports.workerBackgroundTokenization = createEditorWorkerModuleDescription('vs/workbench/services/textMate/browser/backgroundTokenization/worker/textMateTokenizationWorker.worker'); -exports.workbenchDesktop = function () { - return !isAMD() ? [ - createModuleDescription('vs/workbench/contrib/debug/node/telemetryApp'), - createModuleDescription('vs/platform/files/node/watcher/watcherMain'), - createModuleDescription('vs/platform/terminal/node/ptyHostMain'), - createModuleDescription('vs/workbench/api/node/extensionHostProcess'), - createModuleDescription('vs/workbench/contrib/issue/electron-sandbox/issueReporterMain'), - createModuleDescription('vs/workbench/workbench.desktop.main') - ] : [ - ...createEditorWorkerModuleDescription('vs/workbench/contrib/output/common/outputLinkComputer'), - ...createEditorWorkerModuleDescription('vs/workbench/services/textMate/browser/backgroundTokenization/worker/textMateTokenizationWorker.worker'), - createModuleDescription('vs/workbench/contrib/debug/node/telemetryApp'), - createModuleDescription('vs/platform/files/node/watcher/watcherMain'), - createModuleDescription('vs/platform/terminal/node/ptyHostMain'), - createModuleDescription('vs/workbench/api/node/extensionHostProcess'), - createModuleDescription('vs/workbench/contrib/issue/electron-sandbox/issueReporterMain'), - ]; -}; +exports.workbenchDesktop = [ + createModuleDescription('vs/workbench/contrib/debug/node/telemetryApp'), + createModuleDescription('vs/platform/files/node/watcher/watcherMain'), + createModuleDescription('vs/platform/terminal/node/ptyHostMain'), + createModuleDescription('vs/workbench/api/node/extensionHostProcess'), + createModuleDescription('vs/workbench/contrib/issue/electron-sandbox/issueReporterMain'), + createModuleDescription('vs/workbench/workbench.desktop.main') +]; -exports.workbenchWeb = function () { - return !isAMD() ? [ - createModuleDescription('vs/workbench/workbench.web.main') - ] : [ - ...createEditorWorkerModuleDescription('vs/workbench/contrib/output/common/outputLinkComputer'), - ...createEditorWorkerModuleDescription('vs/workbench/services/textMate/browser/backgroundTokenization/worker/textMateTokenizationWorker.worker'), - createModuleDescription('vs/code/browser/workbench/workbench', ['vs/workbench/workbench.web.main.internal']) - ]; -}; +exports.workbenchWeb = createModuleDescription('vs/workbench/workbench.web.main'); exports.keyboardMaps = [ createModuleDescription('vs/workbench/services/keybinding/browser/keyboardLayouts/layout.contribution.linux'), diff --git a/build/gulpfile.compile.js b/build/gulpfile.compile.js index a8d8fb094b2..de8f3c4fb57 100644 --- a/build/gulpfile.compile.js +++ b/build/gulpfile.compile.js @@ -9,13 +9,10 @@ const gulp = require('gulp'); const util = require('./lib/util'); const date = require('./lib/date'); -const amd = require('./lib/amd'); const task = require('./lib/task'); const compilation = require('./lib/compilation'); const optimize = require('./lib/optimize'); -const isAMDBuild = typeof process.env.VSCODE_BUILD_AMD === 'string' && process.env.VSCODE_BUILD_AMD.toLowerCase() === 'true'; - /** * @param {boolean} disableMangle */ @@ -24,9 +21,8 @@ function makeCompileBuildTask(disableMangle) { util.rimraf('out-build'), util.buildWebNodePaths('out-build'), date.writeISODate('out-build'), - amd.setAMD(isAMDBuild), compilation.compileApiProposalNamesTask, - compilation.compileTask(isAMDBuild ? 'src2' : 'src', 'out-build', true, { disableMangle }), + compilation.compileTask('src', 'out-build', true, { disableMangle }), optimize.optimizeLoaderTask('out-build', 'out-build', true) ); } diff --git a/build/gulpfile.js b/build/gulpfile.js index 5f7b71a40f2..e945c06eed4 100644 --- a/build/gulpfile.js +++ b/build/gulpfile.js @@ -34,15 +34,11 @@ gulp.task(compileClientTask); const watchClientTask = task.define('watch-client', task.series(util.rimraf('out'), util.buildWebNodePaths('out'), task.parallel(watchTask('out', false), watchApiProposalNamesTask))); gulp.task(watchClientTask); -const watchClientAMDTask = task.define('watch-client-amd', task.series(util.rimraf('out'), util.buildWebNodePaths('out'), task.parallel(watchTask('out', false, 'src2'), watchApiProposalNamesTask))); -gulp.task(watchClientAMDTask); - // All const _compileTask = task.define('compile', task.parallel(monacoTypecheckTask, compileClientTask, compileExtensionsTask, compileExtensionMediaTask)); gulp.task(_compileTask); gulp.task(task.define('watch', task.parallel(/* monacoTypecheckWatchTask, */ watchClientTask, watchExtensionsTask))); -gulp.task(task.define('watch-amd', task.parallel(/* monacoTypecheckWatchTask, */ watchClientAMDTask, watchExtensionsTask))); // Default gulp.task('default', _compileTask); diff --git a/build/gulpfile.reh.js b/build/gulpfile.reh.js index e3147945f84..f6afeabb2bc 100644 --- a/build/gulpfile.reh.js +++ b/build/gulpfile.reh.js @@ -31,7 +31,6 @@ const { compileExtensionsBuildTask, compileExtensionMediaBuildTask } = require(' const { vscodeWebResourceIncludes, createVSCodeWebFileContentMapper } = require('./gulpfile.vscode.web'); const cp = require('child_process'); const log = require('fancy-log'); -const { isAMD } = require('./lib/amd'); const buildfile = require('./buildfile'); const REPO_ROOT = path.dirname(__dirname); @@ -89,13 +88,10 @@ const serverResources = [ ...serverResourceExcludes ]; -const serverWithWebResourceIncludes = !isAMD() ? [ +const serverWithWebResourceIncludes = [ ...serverResourceIncludes, 'out-build/vs/code/browser/workbench/*.html', ...vscodeWebResourceIncludes -] : [ - ...serverResourceIncludes, - ...vscodeWebResourceIncludes ]; const serverWithWebResourceExcludes = [ @@ -132,7 +128,7 @@ const serverEntryPoints = [ } ]; -const webEntryPoints = !isAMD() ? [ +const webEntryPoints = [ buildfile.base, buildfile.workerExtensionHost, buildfile.workerNotebook, @@ -142,15 +138,6 @@ const webEntryPoints = !isAMD() ? [ buildfile.workerBackgroundTokenization, buildfile.keyboardMaps, buildfile.codeWeb -].flat() : [ - buildfile.entrypoint('vs/workbench/workbench.web.main.internal'), - buildfile.base, - buildfile.workerExtensionHost, - buildfile.workerNotebook, - buildfile.workerLanguageDetection, - buildfile.workerLocalFileSearch, - buildfile.keyboardMaps, - buildfile.workbenchWeb() ].flat(); const serverWithWebEntryPoints = [ @@ -344,7 +331,7 @@ function packageTask(type, platform, arch, sourceFolderName, destinationFolderNa let packageJsonContents; const packageJsonStream = gulp.src(['remote/package.json'], { base: 'remote' }) - .pipe(json({ name, version, dependencies: undefined, optionalDependencies: undefined, ...(!isAMD() ? { type: 'module' } : {}) })) // TODO@esm this should be configured in the top level package.json + .pipe(json({ name, version, dependencies: undefined, optionalDependencies: undefined, ...{ type: 'module' } })) // TODO@esm this should be configured in the top level package.json .pipe(es.through(function (file) { packageJsonContents = file.contents.toString(); this.emit('data', file); diff --git a/build/gulpfile.vscode.js b/build/gulpfile.vscode.js index 9dfb6a3848c..d21bc6b5812 100644 --- a/build/gulpfile.vscode.js +++ b/build/gulpfile.vscode.js @@ -33,12 +33,11 @@ const minimist = require('minimist'); const { compileBuildTask } = require('./gulpfile.compile'); const { compileExtensionsBuildTask, compileExtensionMediaBuildTask } = require('./gulpfile.extensions'); const { promisify } = require('util'); -const { isAMD } = require('./lib/amd'); const glob = promisify(require('glob')); const rcedit = promisify(require('rcedit')); // Build -const vscodeEntryPoints = !isAMD() ? [ +const vscodeEntryPoints = [ buildfile.base, buildfile.workerExtensionHost, buildfile.workerNotebook, @@ -47,21 +46,11 @@ const vscodeEntryPoints = !isAMD() ? [ buildfile.workerProfileAnalysis, buildfile.workerOutputLinks, buildfile.workerBackgroundTokenization, - buildfile.workbenchDesktop(), - buildfile.code -].flat() : [ - buildfile.entrypoint('vs/workbench/workbench.desktop.main'), - buildfile.base, - buildfile.workerExtensionHost, - buildfile.workerNotebook, - buildfile.workerLanguageDetection, - buildfile.workerLocalFileSearch, - buildfile.workerProfileAnalysis, - buildfile.workbenchDesktop(), + buildfile.workbenchDesktop, buildfile.code ].flat(); -const vscodeResourceIncludes = !isAMD() ? [ +const vscodeResourceIncludes = [ // NLS 'out-build/nls.messages.json', @@ -115,33 +104,6 @@ const vscodeResourceIncludes = !isAMD() ? [ // Issue Reporter 'out-build/vs/workbench/contrib/issue/electron-sandbox/issueReporter.esm.html' -] : [ - 'out-build/nls.messages.json', - 'out-build/nls.keys.json', - 'out-build/vs/**/*.{svg,png,html,jpg,mp3}', - '!out-build/vs/code/browser/**/*.html', - '!out-build/vs/code/**/*-dev.html', - '!out-build/vs/code/**/*-dev.esm.html', - '!out-build/vs/editor/standalone/**/*.svg', - 'out-build/vs/base/node/{stdForkStart.js,terminateProcess.sh,cpuUsage.sh,ps.sh}', - 'out-build/vs/base/browser/ui/codicons/codicon/**', - 'out-build/vs/base/parts/sandbox/electron-sandbox/preload.js', - 'out-build/vs/base/parts/sandbox/electron-sandbox/preload-aux.js', - 'out-build/vs/workbench/browser/media/*-theme.css', - 'out-build/vs/workbench/contrib/debug/**/*.json', - 'out-build/vs/workbench/contrib/externalTerminal/**/*.scpt', - 'out-build/vs/workbench/contrib/terminal/common/scripts/fish_xdg_data/fish/vendor_conf.d/*.fish', - 'out-build/vs/workbench/contrib/terminal/common/scripts/*.ps1', - 'out-build/vs/workbench/contrib/terminal/common/scripts/*.psm1', - 'out-build/vs/workbench/contrib/terminal/common/scripts/*.sh', - 'out-build/vs/workbench/contrib/terminal/common/scripts/*.zsh', - 'out-build/vs/workbench/contrib/webview/browser/pre/*.js', - '!out-build/vs/workbench/contrib/issue/**/*-dev.html', - '!out-build/vs/workbench/contrib/issue/**/*-dev.esm.html', - 'out-build/vs/editor/common/languages/highlights/*.scm', - 'out-build/vs/**/markdown.css', - 'out-build/vs/workbench/contrib/tasks/**/*.json', - '!**/test/**' ]; const vscodeResources = [ @@ -162,11 +124,9 @@ const vscodeResources = [ // Do not change the order of these files! They will // be inlined into the target window file in this order // and they depend on each other in this way. -const windowBootstrapFiles = []; -if (isAMD()) { - windowBootstrapFiles.push('out-build/vs/loader.js'); -} -windowBootstrapFiles.push('out-build/bootstrap-window.js'); +const windowBootstrapFiles = [ + 'out-build/bootstrap-window.js' +]; const commonJSEntryPoints = [ 'out-build/main.js', @@ -296,7 +256,7 @@ function packageTask(platform, arch, sourceFolderName, destinationFolderName, op 'vs/workbench/workbench.desktop.main.js', 'vs/workbench/workbench.desktop.main.css', 'vs/workbench/api/node/extensionHostProcess.js', - !isAMD() ? 'vs/code/electron-sandbox/workbench/workbench.esm.html' : 'vs/code/electron-sandbox/workbench/workbench.html', + 'vs/code/electron-sandbox/workbench/workbench.esm.html', 'vs/code/electron-sandbox/workbench/workbench.js' ]); @@ -326,7 +286,7 @@ function packageTask(platform, arch, sourceFolderName, destinationFolderName, op } const name = product.nameShort; - const packageJsonUpdates = { name, version, ...(!isAMD() ? { type: 'module', main: 'out/main.js' } : {}) }; // TODO@esm this should be configured in the top level package.json + const packageJsonUpdates = { name, version, ...{ type: 'module', main: 'out/main.js' } }; // TODO@esm this should be configured in the top level package.json // for linux url handling if (platform === 'linux') { @@ -377,12 +337,10 @@ function packageTask(platform, arch, sourceFolderName, destinationFolderName, op '**/node-pty/lib/shared/conout.js', '**/*.wasm', '**/@vscode/vsce-sign/bin/*', - ], isAMD() ? [ - '**/*.mk', - ] : [ + ], [ '**/*.mk', '!node_modules/vsda/**' // stay compatible with extensions that depend on us shipping `vsda` into ASAR - ], isAMD() ? [] : [ + ], [ 'node_modules/vsda/**' // retain copy of `vsda` in node_modules for internal use ], 'node_modules.asar')); diff --git a/build/gulpfile.vscode.web.js b/build/gulpfile.vscode.web.js index 80b7fc559a4..319da501fc9 100644 --- a/build/gulpfile.vscode.web.js +++ b/build/gulpfile.vscode.web.js @@ -21,7 +21,6 @@ const vfs = require('vinyl-fs'); const packageJson = require('../package.json'); const { compileBuildTask } = require('./gulpfile.compile'); const extensions = require('./lib/extensions'); -const { isAMD } = require('./lib/amd'); const VinylFile = require('vinyl'); const REPO_ROOT = path.dirname(__dirname); @@ -32,7 +31,7 @@ const commit = getVersion(REPO_ROOT); const quality = product.quality; const version = (quality && quality !== 'stable') ? `${packageJson.version}-${quality}` : packageJson.version; -const vscodeWebResourceIncludes = !isAMD() ? [ +const vscodeWebResourceIncludes = [ // NLS 'out-build/nls.messages.js', @@ -55,29 +54,6 @@ const vscodeWebResourceIncludes = !isAMD() ? [ // Extension Host Worker 'out-build/vs/workbench/services/extensions/worker/webWorkerExtensionHostIframe.esm.html', -] : [ - - // Workbench - 'out-build/vs/{base,platform,editor,workbench}/**/*.{svg,png,jpg,mp3}', - 'out-build/vs/code/browser/workbench/*.html', - 'out-build/vs/base/browser/ui/codicons/codicon/**/*.ttf', - 'out-build/vs/**/markdown.css', - - // NLS - 'out-build/nls.messages.js', - - // Webview - 'out-build/vs/workbench/contrib/webview/browser/pre/*.js', - 'out-build/vs/workbench/contrib/webview/browser/pre/*.html', - - // Extension Worker - 'out-build/vs/workbench/services/extensions/worker/webWorkerExtensionHostIframe.html', - - // Tree Sitter highlights - 'out-build/vs/editor/common/languages/highlights/*.scm', - - // Web node paths (needed for integration tests) - 'out-build/vs/webPackagePaths.js', ]; exports.vscodeWebResourceIncludes = vscodeWebResourceIncludes; @@ -97,7 +73,7 @@ const vscodeWebResources = [ const buildfile = require('./buildfile'); -const vscodeWebEntryPoints = !isAMD() ? [ +const vscodeWebEntryPoints = [ buildfile.base, buildfile.workerExtensionHost, buildfile.workerNotebook, @@ -106,17 +82,8 @@ const vscodeWebEntryPoints = !isAMD() ? [ buildfile.workerOutputLinks, buildfile.workerBackgroundTokenization, buildfile.keyboardMaps, - buildfile.workbenchWeb(), + buildfile.workbenchWeb, buildfile.entrypoint('vs/workbench/workbench.web.main.internal') // TODO@esm remove line when we stop supporting web-amd-esm-bridge -].flat() : [ - buildfile.entrypoint('vs/workbench/workbench.web.main.internal'), - buildfile.base, - buildfile.workerExtensionHost, - buildfile.workerNotebook, - buildfile.workerLanguageDetection, - buildfile.workerLocalFileSearch, - buildfile.keyboardMaps, - buildfile.workbenchWeb() ].flat(); /** @@ -233,7 +200,7 @@ function packageTask(sourceFolderName, destinationFolderName) { const loader = gulp.src('build/loader.min', { base: 'build', dot: true }).pipe(rename('out/vs/loader.js')); // TODO@esm remove line when we stop supporting web-amd-esm-bridge - const sources = es.merge(...(!isAMD() ? [src, extensions, loader] : [src, extensions])) + const sources = es.merge(src, extensions, loader) .pipe(filter(['**', '!**/*.js.map'], { dot: true })) // TODO@esm remove me once we stop supporting our web-esm-bridge .pipe(es.through(function (file) { diff --git a/build/lib/amd.js b/build/lib/amd.js deleted file mode 100644 index 8d4e428f830..00000000000 --- a/build/lib/amd.js +++ /dev/null @@ -1,41 +0,0 @@ -"use strict"; -/*--------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. - *--------------------------------------------------------------------------------------------*/ -Object.defineProperty(exports, "__esModule", { value: true }); -exports.setAMD = setAMD; -exports.isAMD = isAMD; -const path = require("path"); -const fs = require("fs"); -// TODO@esm remove this -const outDirectory = path.join(__dirname, '..', '..', 'out-build'); -const amdMarkerFile = path.join(outDirectory, 'amd'); -function setAMD(enabled) { - const result = () => new Promise((resolve, _) => { - if (enabled) { - fs.mkdirSync(outDirectory, { recursive: true }); - fs.writeFileSync(amdMarkerFile, 'true', 'utf8'); - console.warn(`Setting build to AMD: true`); - } - else { - console.warn(`Setting build to AMD: false`); - } - resolve(); - }); - result.taskName = 'set-amd'; - return result; -} -function isAMD(logWarning) { - try { - const res = (typeof process.env.VSCODE_BUILD_AMD === 'string' && process.env.VSCODE_BUILD_AMD.toLowerCase() === 'true') || (fs.readFileSync(amdMarkerFile, 'utf8') === 'true'); - if (res && logWarning) { - console.warn(`[amd] ${logWarning}`); - } - return res; - } - catch (error) { - return false; - } -} -//# sourceMappingURL=amd.js.map \ No newline at end of file diff --git a/build/lib/amd.ts b/build/lib/amd.ts deleted file mode 100644 index 5373024c6a0..00000000000 --- a/build/lib/amd.ts +++ /dev/null @@ -1,40 +0,0 @@ -/*--------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. - *--------------------------------------------------------------------------------------------*/ - -import * as path from 'path'; -import * as fs from 'fs'; - -// TODO@esm remove this - -const outDirectory = path.join(__dirname, '..', '..', 'out-build'); -const amdMarkerFile = path.join(outDirectory, 'amd'); - -export function setAMD(enabled: boolean) { - const result = () => new Promise((resolve, _) => { - if (enabled) { - fs.mkdirSync(outDirectory, { recursive: true }); - fs.writeFileSync(amdMarkerFile, 'true', 'utf8'); - console.warn(`Setting build to AMD: true`); - } else { - console.warn(`Setting build to AMD: false`); - } - - resolve(); - }); - result.taskName = 'set-amd'; - return result; -} - -export function isAMD(logWarning?: string): boolean { - try { - const res = (typeof process.env.VSCODE_BUILD_AMD === 'string' && process.env.VSCODE_BUILD_AMD.toLowerCase() === 'true') || (fs.readFileSync(amdMarkerFile, 'utf8') === 'true'); - if (res && logWarning) { - console.warn(`[amd] ${logWarning}`); - } - return res; - } catch (error) { - return false; - } -} diff --git a/build/lib/mangle/index.js b/build/lib/mangle/index.js index f429712f100..ff4f6b34552 100644 --- a/build/lib/mangle/index.js +++ b/build/lib/mangle/index.js @@ -14,7 +14,6 @@ const ts = require("typescript"); const url_1 = require("url"); const workerpool = require("workerpool"); const staticLanguageServiceHost_1 = require("./staticLanguageServiceHost"); -const amd_1 = require("../amd"); const buildfile = require('../../buildfile'); class ShortIdent { prefix; @@ -248,51 +247,37 @@ function isNameTakenInFile(node, name) { } return false; } -const skippedExportMangledFiles = function () { - return [ - // Build - 'css.build', - // Monaco - 'editorCommon', - 'editorOptions', - 'editorZoom', - 'standaloneEditor', - 'standaloneEnums', - 'standaloneLanguages', - // Generated - 'extensionsApiProposals', - // Module passed around as type - 'pfs', - // entry points - ...!(0, amd_1.isAMD)() ? [ - buildfile.entrypoint('vs/server/node/server.main'), - buildfile.base, - buildfile.workerExtensionHost, - buildfile.workerNotebook, - buildfile.workerLanguageDetection, - buildfile.workerLocalFileSearch, - buildfile.workerProfileAnalysis, - buildfile.workerOutputLinks, - buildfile.workerBackgroundTokenization, - buildfile.workbenchDesktop(), - buildfile.workbenchWeb(), - buildfile.code, - buildfile.codeWeb - ].flat().map(x => x.name) : [ - buildfile.entrypoint('vs/server/node/server.main'), - buildfile.entrypoint('vs/workbench/workbench.desktop.main'), - buildfile.base, - buildfile.workerExtensionHost, - buildfile.workerNotebook, - buildfile.workerLanguageDetection, - buildfile.workerLocalFileSearch, - buildfile.workerProfileAnalysis, - buildfile.workbenchDesktop(), - buildfile.workbenchWeb(), - buildfile.code - ].flat().map(x => x.name), - ]; -}; +const skippedExportMangledFiles = [ + // Build + 'css.build', + // Monaco + 'editorCommon', + 'editorOptions', + 'editorZoom', + 'standaloneEditor', + 'standaloneEnums', + 'standaloneLanguages', + // Generated + 'extensionsApiProposals', + // Module passed around as type + 'pfs', + // entry points + ...[ + buildfile.entrypoint('vs/server/node/server.main'), + buildfile.base, + buildfile.workerExtensionHost, + buildfile.workerNotebook, + buildfile.workerLanguageDetection, + buildfile.workerLocalFileSearch, + buildfile.workerProfileAnalysis, + buildfile.workerOutputLinks, + buildfile.workerBackgroundTokenization, + buildfile.workbenchDesktop, + buildfile.workbenchWeb, + buildfile.code, + buildfile.codeWeb + ].flat().map(x => x.name), +]; const skippedExportMangledProjects = [ // Test projects 'vscode-api-tests', @@ -536,7 +521,7 @@ class Mangler { for (const data of this.allExportedSymbols.values()) { if (data.fileName.endsWith('.d.ts') || skippedExportMangledProjects.some(proj => data.fileName.includes(proj)) - || skippedExportMangledFiles().some(file => data.fileName.endsWith(file + '.ts'))) { + || skippedExportMangledFiles.some(file => data.fileName.endsWith(file + '.ts'))) { continue; } if (!data.shouldMangle(data.replacementName)) { diff --git a/build/lib/mangle/index.ts b/build/lib/mangle/index.ts index ecede4cc108..f5860b7b448 100644 --- a/build/lib/mangle/index.ts +++ b/build/lib/mangle/index.ts @@ -12,7 +12,6 @@ import * as ts from 'typescript'; import { pathToFileURL } from 'url'; import * as workerpool from 'workerpool'; import { StaticLanguageServiceHost } from './staticLanguageServiceHost'; -import { isAMD } from '../amd'; const buildfile = require('../../buildfile'); class ShortIdent { @@ -280,55 +279,41 @@ function isNameTakenInFile(node: ts.Node, name: string): boolean { return false; } -const skippedExportMangledFiles = function () { // using a function() to ensure late isAMD() check - return [ - // Build - 'css.build', +const skippedExportMangledFiles = [ + // Build + 'css.build', - // Monaco - 'editorCommon', - 'editorOptions', - 'editorZoom', - 'standaloneEditor', - 'standaloneEnums', - 'standaloneLanguages', + // Monaco + 'editorCommon', + 'editorOptions', + 'editorZoom', + 'standaloneEditor', + 'standaloneEnums', + 'standaloneLanguages', - // Generated - 'extensionsApiProposals', + // Generated + 'extensionsApiProposals', - // Module passed around as type - 'pfs', + // Module passed around as type + 'pfs', - // entry points - ...!isAMD() ? [ - buildfile.entrypoint('vs/server/node/server.main'), - buildfile.base, - buildfile.workerExtensionHost, - buildfile.workerNotebook, - buildfile.workerLanguageDetection, - buildfile.workerLocalFileSearch, - buildfile.workerProfileAnalysis, - buildfile.workerOutputLinks, - buildfile.workerBackgroundTokenization, - buildfile.workbenchDesktop(), - buildfile.workbenchWeb(), - buildfile.code, - buildfile.codeWeb - ].flat().map(x => x.name) : [ - buildfile.entrypoint('vs/server/node/server.main'), - buildfile.entrypoint('vs/workbench/workbench.desktop.main'), - buildfile.base, - buildfile.workerExtensionHost, - buildfile.workerNotebook, - buildfile.workerLanguageDetection, - buildfile.workerLocalFileSearch, - buildfile.workerProfileAnalysis, - buildfile.workbenchDesktop(), - buildfile.workbenchWeb(), - buildfile.code - ].flat().map(x => x.name), - ]; -}; + // entry points + ...[ + buildfile.entrypoint('vs/server/node/server.main'), + buildfile.base, + buildfile.workerExtensionHost, + buildfile.workerNotebook, + buildfile.workerLanguageDetection, + buildfile.workerLocalFileSearch, + buildfile.workerProfileAnalysis, + buildfile.workerOutputLinks, + buildfile.workerBackgroundTokenization, + buildfile.workbenchDesktop, + buildfile.workbenchWeb, + buildfile.code, + buildfile.codeWeb + ].flat().map(x => x.name), +]; const skippedExportMangledProjects = [ // Test projects @@ -625,7 +610,7 @@ export class Mangler { for (const data of this.allExportedSymbols.values()) { if (data.fileName.endsWith('.d.ts') || skippedExportMangledProjects.some(proj => data.fileName.includes(proj)) - || skippedExportMangledFiles().some(file => data.fileName.endsWith(file + '.ts')) + || skippedExportMangledFiles.some(file => data.fileName.endsWith(file + '.ts')) ) { continue; } diff --git a/build/lib/nls.js b/build/lib/nls.js index 00b9c9262fa..6ddcd46167a 100644 --- a/build/lib/nls.js +++ b/build/lib/nls.js @@ -11,7 +11,6 @@ const File = require("vinyl"); const sm = require("source-map"); const path = require("path"); const sort = require("gulp-sort"); -const amd_1 = require("./amd"); var CollectStepResult; (function (CollectStepResult) { CollectStepResult[CollectStepResult["Yes"] = 0] = "Yes"; @@ -170,23 +169,13 @@ var _nls; .filter(n => n.kind === ts.SyntaxKind.ImportEqualsDeclaration) .map(n => n) .filter(d => d.moduleReference.kind === ts.SyntaxKind.ExternalModuleReference) - .filter(d => { - if (!(0, amd_1.isAMD)()) { - return d.moduleReference.expression.getText().endsWith(`/nls.js'`); - } - return d.moduleReference.expression.getText().endsWith(`/nls'`); - }); + .filter(d => d.moduleReference.expression.getText().endsWith(`/nls.js'`)); // import ... from 'vs/nls'; const importDeclarations = imports .filter(n => n.kind === ts.SyntaxKind.ImportDeclaration) .map(n => n) .filter(d => d.moduleSpecifier.kind === ts.SyntaxKind.StringLiteral) - .filter(d => { - if (!(0, amd_1.isAMD)()) { - return d.moduleSpecifier.getText().endsWith(`/nls.js'`); - } - return d.moduleSpecifier.getText().endsWith(`/nls'`); - }) + .filter(d => d.moduleSpecifier.getText().endsWith(`/nls.js'`)) .filter(d => !!d.importClause && !!d.importClause.namedBindings); // `nls.localize(...)` calls const nlsLocalizeCallExpressions = importDeclarations diff --git a/build/lib/nls.ts b/build/lib/nls.ts index a861122b1bb..4600fe43dc2 100644 --- a/build/lib/nls.ts +++ b/build/lib/nls.ts @@ -10,7 +10,6 @@ import * as File from 'vinyl'; import * as sm from 'source-map'; import * as path from 'path'; import * as sort from 'gulp-sort'; -import { isAMD } from './amd'; declare class FileSourceMap extends File { public sourceMap: sm.RawSourceMap; @@ -232,24 +231,14 @@ module _nls { .filter(n => n.kind === ts.SyntaxKind.ImportEqualsDeclaration) .map(n => n) .filter(d => d.moduleReference.kind === ts.SyntaxKind.ExternalModuleReference) - .filter(d => { - if (!isAMD()) { - return (d.moduleReference).expression.getText().endsWith(`/nls.js'`); - } - return (d.moduleReference).expression.getText().endsWith(`/nls'`); - }); + .filter(d => (d.moduleReference).expression.getText().endsWith(`/nls.js'`)); // import ... from 'vs/nls'; const importDeclarations = imports .filter(n => n.kind === ts.SyntaxKind.ImportDeclaration) .map(n => n) .filter(d => d.moduleSpecifier.kind === ts.SyntaxKind.StringLiteral) - .filter(d => { - if (!isAMD()) { - return d.moduleSpecifier.getText().endsWith(`/nls.js'`); - } - return d.moduleSpecifier.getText().endsWith(`/nls'`); - }) + .filter(d => d.moduleSpecifier.getText().endsWith(`/nls.js'`)) .filter(d => !!d.importClause && !!d.importClause.namedBindings); // `nls.localize(...)` calls diff --git a/build/lib/optimize.js b/build/lib/optimize.js index 8003b5763c4..a63f962851e 100644 --- a/build/lib/optimize.js +++ b/build/lib/optimize.js @@ -12,24 +12,16 @@ const es = require("event-stream"); const gulp = require("gulp"); const concat = require("gulp-concat"); const filter = require("gulp-filter"); -const fancyLog = require("fancy-log"); -const ansiColors = require("ansi-colors"); const path = require("path"); const fs = require("fs"); const pump = require("pump"); const VinylFile = require("vinyl"); const bundle = require("./bundle"); const i18n_1 = require("./i18n"); -const stats_1 = require("./stats"); -const util = require("./util"); const postcss_1 = require("./postcss"); const esbuild = require("esbuild"); const sourcemaps = require("gulp-sourcemaps"); -const amd_1 = require("./amd"); const REPO_ROOT_PATH = path.join(__dirname, '../..'); -function log(prefix, message) { - fancyLog(ansiColors.cyan('[' + prefix + ']'), message); -} function loaderConfig() { const result = { paths: { @@ -41,7 +33,6 @@ function loaderConfig() { result['vs/css'] = { inlineResources: true }; return result; } -const IS_OUR_COPYRIGHT_REGEXP = /Copyright \(C\) Microsoft Corporation/i; function loaderPlugin(src, base, amdModuleId) { return (gulp .src(src, { base }) @@ -106,97 +97,11 @@ function emitExternalLoaderInfo(externalLoaderInfo) { })();`; return code.replace('"$BASE_URL"', 'baseUrl'); } -function toConcatStream(src, bundledFileHeader, sources, dest, fileContentMapper) { - const useSourcemaps = /\.js$/.test(dest) && !/\.nls\.js$/.test(dest); - // If a bundle ends up including in any of the sources our copyright, then - // insert a fake source at the beginning of each bundle with our copyright - let containsOurCopyright = false; - for (let i = 0, len = sources.length; i < len; i++) { - const fileContents = sources[i].contents; - if (IS_OUR_COPYRIGHT_REGEXP.test(fileContents)) { - containsOurCopyright = true; - break; - } - } - if (containsOurCopyright) { - sources.unshift({ - path: null, - contents: bundledFileHeader - }); - } - const treatedSources = sources.map(function (source) { - const root = source.path ? REPO_ROOT_PATH.replace(/\\/g, '/') : ''; - const base = source.path ? root + `/${src}` : '.'; - const path = source.path ? root + '/' + source.path.replace(/\\/g, '/') : 'fake'; - const contents = source.path ? fileContentMapper(source.contents, path) : source.contents; - return new VinylFile({ - path: path, - base: base, - contents: Buffer.from(contents) - }); - }); - return es.readArray(treatedSources) - .pipe(useSourcemaps ? util.loadSourcemaps() : es.through()) - .pipe(concat(dest)) - .pipe((0, stats_1.createStatsStream)(dest)); -} -function toBundleStream(src, bundledFileHeader, bundles, fileContentMapper) { - return es.merge(bundles.map(function (bundle) { - return toConcatStream(src, bundledFileHeader, bundle.sources, bundle.dest, fileContentMapper); - })); -} const DEFAULT_FILE_HEADER = [ '/*!--------------------------------------------------------', ' * Copyright (C) Microsoft Corporation. All rights reserved.', ' *--------------------------------------------------------*/' ].join('\n'); -function optimizeAMDTask(opts) { - const src = opts.src; - const entryPoints = opts.entryPoints.filter(d => d.target !== 'esm'); - const resources = opts.resources; - const loaderConfig = opts.loaderConfig; - const bundledFileHeader = opts.header || DEFAULT_FILE_HEADER; - const fileContentMapper = opts.fileContentMapper || ((contents, _path) => contents); - const bundlesStream = es.through(); // this stream will contain the bundled files - const resourcesStream = es.through(); // this stream will contain the resources - const bundleInfoStream = es.through(); // this stream will contain bundleInfo.json - bundle.bundle(entryPoints, loaderConfig, function (err, result) { - if (err || !result) { - return bundlesStream.emit('error', JSON.stringify(err)); - } - toBundleStream(src, bundledFileHeader, result.files, fileContentMapper).pipe(bundlesStream); - // Remove css inlined resources - const filteredResources = resources.slice(); - result.cssInlinedResources.forEach(function (resource) { - if (process.env['VSCODE_BUILD_VERBOSE']) { - log('optimizer', 'excluding inlined: ' + resource); - } - filteredResources.push('!' + resource); - }); - gulp.src(filteredResources, { base: `${src}`, allowEmpty: true }).pipe(resourcesStream); - const bundleInfoArray = []; - if (opts.bundleInfo) { - bundleInfoArray.push(new VinylFile({ - path: 'bundleInfo.json', - base: '.', - contents: Buffer.from(JSON.stringify(result.bundleData, null, '\t')) - })); - } - es.readArray(bundleInfoArray).pipe(bundleInfoStream); - }); - const result = es.merge(loader(src, bundledFileHeader, false, opts.externalLoaderInfo), bundlesStream, resourcesStream, bundleInfoStream); - return result - .pipe(sourcemaps.write('./', { - sourceRoot: undefined, - addComment: true, - includeContent: true - })) - .pipe(opts.languages && opts.languages.length ? (0, i18n_1.processNlsFiles)({ - out: opts.src, - fileHeader: bundledFileHeader, - languages: opts.languages - }) : es.through()); -} function optimizeESMTask(opts, cjsOpts) { const resourcesStream = es.through(); // this stream will contain the resources const bundlesStream = es.through(); // this stream will contain the bundled files @@ -320,24 +225,6 @@ function optimizeESMTask(opts, cjsOpts) { languages: opts.languages }) : es.through()); } -function optimizeCommonJSTask(opts) { - const src = opts.src; - const entryPoints = opts.entryPoints; - return gulp.src(entryPoints, { base: `${src}`, allowEmpty: true }) - .pipe(es.map((f, cb) => { - esbuild.build({ - entryPoints: [f.path], - bundle: true, - platform: opts.platform, - write: false, - external: opts.external - }).then(res => { - const jsFile = res.outputFiles[0]; - f.contents = Buffer.from(jsFile.contents); - cb(undefined, f); - }); - })); -} function optimizeManualTask(options) { const concatenations = options.map(opt => { return gulp @@ -352,15 +239,7 @@ function optimizeLoaderTask(src, out, bundleLoader, bundledFileHeader = '', exte function optimizeTask(opts) { return function () { const optimizers = []; - if (!(0, amd_1.isAMD)()) { - optimizers.push(optimizeESMTask(opts.amd, opts.commonJS)); - } - else { - optimizers.push(optimizeAMDTask(opts.amd)); - if (opts.commonJS) { - optimizers.push(optimizeCommonJSTask(opts.commonJS)); - } - } + optimizers.push(optimizeESMTask(opts.amd, opts.commonJS)); if (opts.manual) { optimizers.push(optimizeManualTask(opts.manual)); } diff --git a/build/lib/optimize.ts b/build/lib/optimize.ts index 3cb778111ae..ea5b471dec1 100644 --- a/build/lib/optimize.ts +++ b/build/lib/optimize.ts @@ -7,27 +7,19 @@ import * as es from 'event-stream'; import * as gulp from 'gulp'; import * as concat from 'gulp-concat'; import * as filter from 'gulp-filter'; -import * as fancyLog from 'fancy-log'; -import * as ansiColors from 'ansi-colors'; import * as path from 'path'; import * as fs from 'fs'; import * as pump from 'pump'; import * as VinylFile from 'vinyl'; import * as bundle from './bundle'; import { Language, processNlsFiles } from './i18n'; -import { createStatsStream } from './stats'; import * as util from './util'; import { gulpPostcss } from './postcss'; import * as esbuild from 'esbuild'; import * as sourcemaps from 'gulp-sourcemaps'; -import { isAMD } from './amd'; const REPO_ROOT_PATH = path.join(__dirname, '../..'); -function log(prefix: string, message: string): void { - fancyLog(ansiColors.cyan('[' + prefix + ']'), message); -} - export function loaderConfig() { const result: any = { paths: { @@ -42,8 +34,6 @@ export function loaderConfig() { return result; } -const IS_OUR_COPYRIGHT_REGEXP = /Copyright \(C\) Microsoft Corporation/i; - function loaderPlugin(src: string, base: string, amdModuleId: string | undefined): NodeJS.ReadWriteStream { return ( gulp @@ -121,52 +111,6 @@ function emitExternalLoaderInfo(externalLoaderInfo: util.IExternalLoaderInfo): s return code.replace('"$BASE_URL"', 'baseUrl'); } -function toConcatStream(src: string, bundledFileHeader: string, sources: bundle.IFile[], dest: string, fileContentMapper: (contents: string, path: string) => string): NodeJS.ReadWriteStream { - const useSourcemaps = /\.js$/.test(dest) && !/\.nls\.js$/.test(dest); - - // If a bundle ends up including in any of the sources our copyright, then - // insert a fake source at the beginning of each bundle with our copyright - let containsOurCopyright = false; - for (let i = 0, len = sources.length; i < len; i++) { - const fileContents = sources[i].contents; - if (IS_OUR_COPYRIGHT_REGEXP.test(fileContents)) { - containsOurCopyright = true; - break; - } - } - - if (containsOurCopyright) { - sources.unshift({ - path: null, - contents: bundledFileHeader - }); - } - - const treatedSources = sources.map(function (source) { - const root = source.path ? REPO_ROOT_PATH.replace(/\\/g, '/') : ''; - const base = source.path ? root + `/${src}` : '.'; - const path = source.path ? root + '/' + source.path.replace(/\\/g, '/') : 'fake'; - const contents = source.path ? fileContentMapper(source.contents, path) : source.contents; - - return new VinylFile({ - path: path, - base: base, - contents: Buffer.from(contents) - }); - }); - - return es.readArray(treatedSources) - .pipe(useSourcemaps ? util.loadSourcemaps() : es.through()) - .pipe(concat(dest)) - .pipe(createStatsStream(dest)); -} - -function toBundleStream(src: string, bundledFileHeader: string, bundles: bundle.IConcatFile[], fileContentMapper: (contents: string, path: string) => string): NodeJS.ReadWriteStream { - return es.merge(bundles.map(function (bundle) { - return toConcatStream(src, bundledFileHeader, bundle.sources, bundle.dest, fileContentMapper); - })); -} - export interface IOptimizeAMDTaskOpts { /** * The folder to read files from. @@ -215,64 +159,6 @@ const DEFAULT_FILE_HEADER = [ ' *--------------------------------------------------------*/' ].join('\n'); -function optimizeAMDTask(opts: IOptimizeAMDTaskOpts): NodeJS.ReadWriteStream { - const src = opts.src; - const entryPoints = opts.entryPoints.filter(d => d.target !== 'esm'); - const resources = opts.resources; - const loaderConfig = opts.loaderConfig; - const bundledFileHeader = opts.header || DEFAULT_FILE_HEADER; - const fileContentMapper = opts.fileContentMapper || ((contents: string, _path: string) => contents); - - const bundlesStream = es.through(); // this stream will contain the bundled files - const resourcesStream = es.through(); // this stream will contain the resources - const bundleInfoStream = es.through(); // this stream will contain bundleInfo.json - - bundle.bundle(entryPoints, loaderConfig, function (err, result) { - if (err || !result) { return bundlesStream.emit('error', JSON.stringify(err)); } - - toBundleStream(src, bundledFileHeader, result.files, fileContentMapper).pipe(bundlesStream); - - // Remove css inlined resources - const filteredResources = resources.slice(); - result.cssInlinedResources.forEach(function (resource) { - if (process.env['VSCODE_BUILD_VERBOSE']) { - log('optimizer', 'excluding inlined: ' + resource); - } - filteredResources.push('!' + resource); - }); - gulp.src(filteredResources, { base: `${src}`, allowEmpty: true }).pipe(resourcesStream); - - const bundleInfoArray: VinylFile[] = []; - if (opts.bundleInfo) { - bundleInfoArray.push(new VinylFile({ - path: 'bundleInfo.json', - base: '.', - contents: Buffer.from(JSON.stringify(result.bundleData, null, '\t')) - })); - } - es.readArray(bundleInfoArray).pipe(bundleInfoStream); - }); - - const result = es.merge( - loader(src, bundledFileHeader, false, opts.externalLoaderInfo), - bundlesStream, - resourcesStream, - bundleInfoStream - ); - - return result - .pipe(sourcemaps.write('./', { - sourceRoot: undefined, - addComment: true, - includeContent: true - })) - .pipe(opts.languages && opts.languages.length ? processNlsFiles({ - out: opts.src, - fileHeader: bundledFileHeader, - languages: opts.languages - }) : es.through()); -} - function optimizeESMTask(opts: IOptimizeAMDTaskOpts, cjsOpts?: IOptimizeCommonJSTaskOpts): NodeJS.ReadWriteStream { const resourcesStream = es.through(); // this stream will contain the resources const bundlesStream = es.through(); // this stream will contain the bundled files @@ -444,27 +330,6 @@ export interface IOptimizeCommonJSTaskOpts { external: string[]; } -function optimizeCommonJSTask(opts: IOptimizeCommonJSTaskOpts): NodeJS.ReadWriteStream { - const src = opts.src; - const entryPoints = opts.entryPoints; - - return gulp.src(entryPoints, { base: `${src}`, allowEmpty: true }) - .pipe(es.map((f: any, cb) => { - esbuild.build({ - entryPoints: [f.path], - bundle: true, - platform: opts.platform, - write: false, - external: opts.external - }).then(res => { - const jsFile = res.outputFiles[0]; - f.contents = Buffer.from(jsFile.contents); - - cb(undefined, f); - }); - })); -} - export interface IOptimizeManualTaskOpts { /** * The paths to consider for concatenation. The entries @@ -513,15 +378,7 @@ export interface IOptimizeTaskOpts { export function optimizeTask(opts: IOptimizeTaskOpts): () => NodeJS.ReadWriteStream { return function () { const optimizers: NodeJS.ReadWriteStream[] = []; - if (!isAMD()) { - optimizers.push(optimizeESMTask(opts.amd, opts.commonJS)); - } else { - optimizers.push(optimizeAMDTask(opts.amd)); - - if (opts.commonJS) { - optimizers.push(optimizeCommonJSTask(opts.commonJS)); - } - } + optimizers.push(optimizeESMTask(opts.amd, opts.commonJS)); if (opts.manual) { optimizers.push(optimizeManualTask(opts.manual)); diff --git a/build/linux/dependencies-generator.js b/build/linux/dependencies-generator.js index 5d4bb828382..eec4bd790cd 100644 --- a/build/linux/dependencies-generator.js +++ b/build/linux/dependencies-generator.js @@ -15,7 +15,6 @@ const dep_lists_2 = require("./rpm/dep-lists"); const types_1 = require("./debian/types"); const types_2 = require("./rpm/types"); const product = require("../../product.json"); -const amd_1 = require("../lib/amd"); // A flag that can easily be toggled. // Make sure to compile the build directory after toggling the value. // If false, we warn about new dependencies if they show up @@ -44,7 +43,7 @@ async function getDependencies(packageType, buildDir, applicationName, arch) { throw new Error('Invalid RPM arch string ' + arch); } // Get the files for which we want to find dependencies. - const canAsar = (0, amd_1.isAMD)(); // TODO@esm ASAR disabled in ESM + const canAsar = false; // TODO@esm ASAR disabled in ESM const nativeModulesPath = path.join(buildDir, 'resources', 'app', canAsar ? 'node_modules.asar.unpacked' : 'node_modules'); const findResult = (0, child_process_1.spawnSync)('find', [nativeModulesPath, '-name', '*.node']); if (findResult.status) { diff --git a/build/linux/dependencies-generator.ts b/build/linux/dependencies-generator.ts index d390818dc54..7faae4ba104 100644 --- a/build/linux/dependencies-generator.ts +++ b/build/linux/dependencies-generator.ts @@ -15,7 +15,6 @@ import { referenceGeneratedDepsByArch as rpmGeneratedDeps } from './rpm/dep-list import { DebianArchString, isDebianArchString } from './debian/types'; import { isRpmArchString, RpmArchString } from './rpm/types'; import product = require('../../product.json'); -import { isAMD } from '../lib/amd'; // A flag that can easily be toggled. // Make sure to compile the build directory after toggling the value. @@ -48,7 +47,7 @@ export async function getDependencies(packageType: 'deb' | 'rpm', buildDir: stri } // Get the files for which we want to find dependencies. - const canAsar = isAMD(); // TODO@esm ASAR disabled in ESM + const canAsar = false; // TODO@esm ASAR disabled in ESM const nativeModulesPath = path.join(buildDir, 'resources', 'app', canAsar ? 'node_modules.asar.unpacked' : 'node_modules'); const findResult = spawnSync('find', [nativeModulesPath, '-name', '*.node']); if (findResult.status) { diff --git a/migrate.mjs b/migrate.mjs deleted file mode 100644 index ef8a8346169..00000000000 --- a/migrate.mjs +++ /dev/null @@ -1,364 +0,0 @@ -/*--------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. - *--------------------------------------------------------------------------------------------*/ - -//@ts-check - -// ***************************************************************** -// * * -// * AMD-TO-ESM MIGRATION SCRIPT * -// * * -// ***************************************************************** - -import { readFileSync, writeFileSync, unlinkSync } from 'node:fs'; -import { join, extname, dirname, relative } from 'node:path'; -import { preProcessFile } from 'typescript'; -import { existsSync, mkdirSync, readdirSync, statSync } from 'fs'; -import { fileURLToPath } from 'node:url'; - -// @ts-expect-error -import watch from './build/lib/watch/index.js'; - -const enableWatching = !process.argv.includes('--disable-watch'); -const enableInPlace = process.argv.includes('--enable-in-place'); -const esmToAmd = process.argv.includes('--enable-esm-to-amd'); -const amdToEsm = !esmToAmd; - -const srcFolder = fileURLToPath(new URL('src', import.meta.url)); -const dstFolder = fileURLToPath(new URL(enableInPlace ? 'src' : 'src2', import.meta.url)); - -const binaryFileExtensions = new Set([ - '.svg', '.ttf', '.png', '.sh', '.html', '.json', '.zsh', '.scpt', '.mp3', '.fish', '.ps1', '.psm1', '.md', '.txt', '.zip', '.pdf', '.qwoff', '.jxs', '.tst', '.wuff', '.less', '.utf16le', '.snap', '.actual', '.tsx', '.scm' -]); - -function migrate() { - console.log(`~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`); - console.log(`STARTING ${amdToEsm ? 'AMD->ESM' : 'ESM->AMD'} MIGRATION of ${enableInPlace ? 'src in-place' : 'src to src2'}.`); - - // installing watcher quickly to avoid missing early events - const watchSrc = enableWatching ? watch('src/**', { base: 'src', readDelay: 200 }) : undefined; - - /** @type {string[]} */ - const files = []; - readdir(srcFolder, files); - - for (const filePath of files) { - const fileContents = readFileSync(filePath); - migrateOne(filePath, fileContents); - } - - if (amdToEsm) { - writeFileSync(join(dstFolder, 'package.json'), `{"type": "module"}`); - } else { - unlinkSync(join(dstFolder, 'package.json')); - } - - if (!enableInPlace) { - writeFileSync(join(dstFolder, '.gitignore'), `*`); - } - - console.log(`~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`); - console.log(`COMPLETED ${amdToEsm ? 'AMD->ESM' : 'ESM->AMD'} MIGRATION of ${enableInPlace ? 'src in-place' : 'src to src2'}. You can now launch npm run watch-amd or npm run watch-client-amd`); - if (esmToAmd) { - console.log(`Make sure to set the environment variable VSCODE_BUILD_AMD to a string of value 'true' if you want to build VS Code as AMD`); - } - - if (watchSrc) { - console.log(`WATCHING src for changes...`); - - watchSrc.on('data', (e) => { - migrateOne(e.path, e.contents); - console.log(`Handled change event for ${e.path}.`); - }); - } -} - -/** - * @param filePath - * @param fileContents - */ -function migrateOne(filePath, fileContents) { - const fileExtension = extname(filePath); - - if (fileExtension === '.ts') { - migrateTS(filePath, fileContents.toString()); - } else if (filePath.endsWith('tsconfig.base.json')) { - const opts = JSON.parse(fileContents.toString()); - if (amdToEsm) { - opts.compilerOptions.module = 'es2022'; - opts.compilerOptions.allowSyntheticDefaultImports = true; - } else { - opts.compilerOptions.module = 'amd'; - delete opts.compilerOptions.allowSyntheticDefaultImports; - } - writeDestFile(filePath, JSON.stringify(opts, null, '\t')); - } else if (fileExtension === '.js' || fileExtension === '.cjs' || fileExtension === '.mjs' || fileExtension === '.css' || binaryFileExtensions.has(fileExtension)) { - writeDestFile(filePath, fileContents); - } else { - console.log(`ignoring ${filePath}`); - } -} - -/** - * @param fileContents - * @typedef {{pos:number;end:number;}} Import - * @return - */ -function discoverImports(fileContents) { - const info = preProcessFile(fileContents); - const search = /export .* from ['"]([^'"]+)['"]/g; - /** typedef {Import[]} */ - let result = []; - do { - const m = search.exec(fileContents); - if (!m) { - break; - } - const end = m.index + m[0].length - 2; - const pos = end - m[1].length; - result.push({ pos, end }); - } while (true); - - result = result.concat(info.importedFiles); - - result.sort((a, b) => { - return a.pos - b.pos; - }); - for (let i = 1; i < result.length; i++) { - const prev = result[i - 1]; - const curr = result[i]; - if (prev.pos === curr.pos) { - result.splice(i, 1); - i--; - } - } - return result; -} - -/** - * @param filePath - * @param fileContents - */ -function migrateTS(filePath, fileContents) { - if (filePath.endsWith('.d.ts')) { - return writeDestFile(filePath, fileContents); - } - - const imports = discoverImports(fileContents); - /** @type {Replacement[]} */ - const replacements = []; - for (let i = imports.length - 1; i >= 0; i--) { - const pos = imports[i].pos + 1; - const end = imports[i].end + 1; - const importedFilename = fileContents.substring(pos, end); - - /** @type {string|undefined} */ - let importedFilepath = undefined; - if (amdToEsm) { - if (/^vs\/css!/.test(importedFilename)) { - importedFilepath = importedFilename.substr('vs/css!'.length) + '.css'; - } else { - importedFilepath = importedFilename; - } - } else { - if (importedFilename.endsWith('.css')) { - importedFilepath = `vs/css!${importedFilename.substr(0, importedFilename.length - 4)}`; - } else if (importedFilename.endsWith('.js')) { - importedFilepath = importedFilename.substr(0, importedFilename.length - 3); - } - } - - if (typeof importedFilepath !== 'string') { - continue; - } - - /** @type {boolean} */ - let isRelativeImport; - if (amdToEsm) { - if (/(^\.\/)|(^\.\.\/)/.test(importedFilepath)) { - importedFilepath = join(dirname(filePath), importedFilepath); - isRelativeImport = true; - } else if (/^vs\//.test(importedFilepath)) { - importedFilepath = join(srcFolder, importedFilepath); - isRelativeImport = true; - } else { - importedFilepath = importedFilepath; - isRelativeImport = false; - } - } else { - importedFilepath = importedFilepath; - isRelativeImport = false; - } - - /** @type {string} */ - let replacementImport; - - if (isRelativeImport) { - replacementImport = generateRelativeImport(filePath, importedFilepath); - } else { - replacementImport = importedFilepath; - } - - replacements.push({ pos, end, text: replacementImport }); - } - - fileContents = applyReplacements(fileContents, replacements); - - writeDestFile(filePath, fileContents); -} - -/** - * @param filePath - * @param importedFilepath - */ -function generateRelativeImport(filePath, importedFilepath) { - /** @type {string} */ - let relativePath; - // See https://github.com/microsoft/TypeScript/issues/16577#issuecomment-754941937 - if (!importedFilepath.endsWith('.css') && !importedFilepath.endsWith('.cjs')) { - importedFilepath = `${importedFilepath}.js`; - } - relativePath = relative(dirname(filePath), `${importedFilepath}`); - relativePath = relativePath.replace(/\\/g, '/'); - if (!/(^\.\/)|(^\.\.\/)/.test(relativePath)) { - relativePath = './' + relativePath; - } - return relativePath; -} - -/** @typedef {{pos:number;end:number;text:string;}} Replacement */ - -/** - * @param str - * @param replacements - */ -function applyReplacements(str, replacements) { - replacements.sort((a, b) => { - return a.pos - b.pos; - }); - - /** @type {string[]} */ - const result = []; - let lastEnd = 0; - for (const replacement of replacements) { - const { pos, end, text } = replacement; - result.push(str.substring(lastEnd, pos)); - result.push(text); - lastEnd = end; - } - result.push(str.substring(lastEnd, str.length)); - return result.join(''); -} - -/** - * @param srcFilePath - * @param fileContents - */ -function writeDestFile(srcFilePath, fileContents) { - const destFilePath = srcFilePath.replace(srcFolder, dstFolder); - ensureDir(dirname(destFilePath)); - - if (/(\.ts$)|(\.js$)|(\.html$)/.test(destFilePath)) { - fileContents = toggleComments(fileContents); - } - - /** @type {Buffer | undefined} */ - let existingFileContents = undefined; - try { - existingFileContents = readFileSync(destFilePath); - } catch (err) { } - if (!buffersAreEqual(existingFileContents, fileContents)) { - writeFileSync(destFilePath, fileContents); - } - - /** - * @param fileContents - */ - function toggleComments(fileContents) { - const lines = String(fileContents).split(/\r\n|\r|\n/); - let mode = 0; - let didChange = false; - for (let i = 0; i < lines.length; i++) { - const line = lines[i]; - if (mode === 0) { - if (amdToEsm ? /\/\/ ESM-comment-begin/.test(line) : /\/\/ ESM-uncomment-begin/.test(line)) { - mode = 1; - continue; - } - if (amdToEsm ? /\/\/ ESM-uncomment-begin/.test(line) : /\/\/ ESM-comment-begin/.test(line)) { - mode = 2; - continue; - } - continue; - } - - if (mode === 1) { - if (amdToEsm ? /\/\/ ESM-comment-end/.test(line) : /\/\/ ESM-uncomment-end/.test(line)) { - mode = 0; - continue; - } - didChange = true; - lines[i] = line.replace(/^\s*/, (match) => match + '// '); - continue; - } - - if (mode === 2) { - if (amdToEsm ? /\/\/ ESM-uncomment-end/.test(line) : /\/\/ ESM-comment-end/.test(line)) { - mode = 0; - continue; - } - didChange = true; - lines[i] = line.replace(/^(\s*)\/\/ ?/, function (_, indent) { - return indent; - }); - } - } - - if (didChange) { - return lines.join('\n'); - } - return fileContents; - } -} - -/** - * @param existingFileContents - * @param fileContents - */ -function buffersAreEqual(existingFileContents, fileContents) { - if (!existingFileContents) { - return false; - } - if (typeof fileContents === 'string') { - fileContents = Buffer.from(fileContents); - } - return existingFileContents.equals(fileContents); -} - -const ensureDirCache = new Set(); -function ensureDir(dirPath) { - if (ensureDirCache.has(dirPath)) { - return; - } - ensureDirCache.add(dirPath); - ensureDir(dirname(dirPath)); - if (!existsSync(dirPath)) { - mkdirSync(dirPath); - } -} - -function readdir(dirPath, result) { - const entries = readdirSync(dirPath); - for (const entry of entries) { - const entryPath = join(dirPath, entry); - const stat = statSync(entryPath); - if (stat.isDirectory()) { - readdir(join(dirPath, entry), result); - } else { - result.push(entryPath); - } - } -} - -migrate(); diff --git a/package.json b/package.json index 1aea8bae9b2..abe31e186bf 100644 --- a/package.json +++ b/package.json @@ -11,17 +11,13 @@ "scripts": { "test": "echo Please run any of the test scripts from the scripts folder.", "test-browser": "npx playwright install && node test/unit/browser/index.js", - "test-browser-amd": "npx playwright install && node test/unit/browser/index.amd.js", "test-browser-no-install": "node test/unit/browser/index.js", - "test-browser-amd-no-install": "node test/unit/browser/index.amd.js", "test-node": "mocha test/unit/node/index.mjs --delay --ui=tdd --timeout=5000 --exit", - "test-node-amd": "mocha test/unit/node/index.amd.js --delay --ui=tdd --timeout=5000 --exit", "test-extension": "vscode-test", "preinstall": "node build/npm/preinstall.js", "postinstall": "node build/npm/postinstall.js", "compile": "node ./node_modules/gulp/bin/gulp.js compile", "watch": "npm-run-all -lp watch-client watch-extensions", - "watch-amd": "npm-run-all -lp watch-client-amd watch-extensions", "watchd": "deemon npm run watch", "watch-webd": "deemon npm run watch-web", "kill-watchd": "deemon --kill npm run watch", @@ -29,7 +25,6 @@ "restart-watchd": "deemon --restart npm run watch", "restart-watch-webd": "deemon --restart npm run watch-web", "watch-client": "node --max-old-space-size=8192 ./node_modules/gulp/bin/gulp.js watch-client", - "watch-client-amd": "node --max-old-space-size=8192 ./node_modules/gulp/bin/gulp.js watch-client-amd", "watch-clientd": "deemon npm run watch-client", "kill-watch-clientd": "deemon --kill npm run watch-client", "watch-extensions": "node --max-old-space-size=8192 ./node_modules/gulp/bin/gulp.js watch-extensions watch-extension-media", diff --git a/scripts/code-web.js b/scripts/code-web.js index f2dc1ff046b..f05c934cadf 100644 --- a/scripts/code-web.js +++ b/scripts/code-web.js @@ -74,10 +74,7 @@ async function main() { openSystemBrowser = true; } - if (!fs.existsSync(path.join(APP_ROOT, 'src2')) && !fs.existsSync(path.join(APP_ROOT, 'out-build', 'amd'))) { - serverArgs.push('--esm'); - } - + serverArgs.push('--esm'); // TODO@esm this should be the default serverArgs.push('--sourcesPath', APP_ROOT); serverArgs.push(...process.argv.slice(2).filter(v => !v.startsWith('--playground') && v !== '--no-playground')); diff --git a/scripts/test-amd.bat b/scripts/test-amd.bat deleted file mode 100644 index 4ecd8a43400..00000000000 --- a/scripts/test-amd.bat +++ /dev/null @@ -1,31 +0,0 @@ -@echo off -setlocal - -set ELECTRON_RUN_AS_NODE= - -pushd %~dp0\.. - -:: Get Code.exe location -for /f "tokens=2 delims=:," %%a in ('findstr /R /C:"\"nameShort\":.*" product.json') do set NAMESHORT=%%~a -set NAMESHORT=%NAMESHORT: "=% -set NAMESHORT=%NAMESHORT:"=%.exe -set CODE=".build\electron\%NAMESHORT%" - -:: Download Electron if needed -call node build\lib\electron.js -if %errorlevel% neq 0 node .\node_modules\gulp\bin\gulp.js electron - -:: Run tests -set ELECTRON_ENABLE_LOGGING=1 -%CODE% .\test\unit\electron\index.amd.js --crash-reporter-directory=%~dp0\..\.build\crashes %* - -popd - -endlocal - -:: app.exit(0) is exiting with code 255 in Electron 1.7.4. -:: See https://github.com/microsoft/vscode/issues/28582 -echo errorlevel: %errorlevel% -if %errorlevel% == 255 set errorlevel=0 - -exit /b %errorlevel% diff --git a/scripts/test-amd.sh b/scripts/test-amd.sh deleted file mode 100755 index be45e090348..00000000000 --- a/scripts/test-amd.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/env bash -set -e - -if [[ "$OSTYPE" == "darwin"* ]]; then - realpath() { [[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}"; } - ROOT=$(dirname $(dirname $(realpath "$0"))) -else - ROOT=$(dirname $(dirname $(readlink -f $0))) - # --disable-dev-shm-usage: when run on docker containers where size of /dev/shm - # partition < 64MB which causes OOM failure for chromium compositor that uses the partition for shared memory - LINUX_EXTRA_ARGS="--disable-dev-shm-usage" -fi - -cd $ROOT - -if [[ "$OSTYPE" == "darwin"* ]]; then - NAME=`node -p "require('./product.json').nameLong"` - CODE="./.build/electron/$NAME.app/Contents/MacOS/Electron" -else - NAME=`node -p "require('./product.json').applicationName"` - CODE=".build/electron/$NAME" -fi - -VSCODECRASHDIR=$ROOT/.build/crashes - -# Node modules -test -d node_modules || npm i - -# Get electron -npm run electron - -# Unit Tests -if [[ "$OSTYPE" == "darwin"* ]]; then - cd $ROOT ; ulimit -n 4096 ; \ - ELECTRON_ENABLE_LOGGING=1 \ - "$CODE" \ - test/unit/electron/index.amd.js --crash-reporter-directory=$VSCODECRASHDIR "$@" -else - cd $ROOT ; \ - ELECTRON_ENABLE_LOGGING=1 \ - "$CODE" \ - test/unit/electron/index.amd.js --crash-reporter-directory=$VSCODECRASHDIR $LINUX_EXTRA_ARGS "$@" -fi diff --git a/scripts/test-integration-amd.bat b/scripts/test-integration-amd.bat deleted file mode 100644 index 96231152b91..00000000000 --- a/scripts/test-integration-amd.bat +++ /dev/null @@ -1,119 +0,0 @@ -@echo off -setlocal - -pushd %~dp0\.. - -set VSCODEUSERDATADIR=%TEMP%\vscodeuserfolder-%RANDOM%-%TIME:~6,2% -set VSCODECRASHDIR=%~dp0\..\.build\crashes -set VSCODELOGSDIR=%~dp0\..\.build\logs\integration-tests - -:: Figure out which Electron to use for running tests -if "%INTEGRATION_TEST_ELECTRON_PATH%"=="" ( - chcp 65001 - set INTEGRATION_TEST_ELECTRON_PATH=.\scripts\code.bat - set VSCODE_BUILD_BUILTIN_EXTENSIONS_SILENCE_PLEASE=1 - - echo Running integration tests out of sources. -) else ( - set VSCODE_CLI=1 - set ELECTRON_ENABLE_LOGGING=1 - - echo Running integration tests with '%INTEGRATION_TEST_ELECTRON_PATH%' as build. -) - -echo Storing crash reports into '%VSCODECRASHDIR%'. -echo Storing log files into '%VSCODELOGSDIR%'. - - -:: Tests standalone (AMD) - -echo. -echo ### node.js integration tests -call .\scripts\test-amd.bat --runGlob **\*.integrationTest.js %* -if %errorlevel% neq 0 exit /b %errorlevel% - - -:: Tests in the extension host - -set API_TESTS_EXTRA_ARGS=--disable-telemetry --skip-welcome --skip-release-notes --crash-reporter-directory=%VSCODECRASHDIR% --logsPath=%VSCODELOGSDIR% --no-cached-data --disable-updates --use-inmemory-secretstorage --disable-extensions --disable-workspace-trust --user-data-dir=%VSCODEUSERDATADIR% - -echo. -echo ### API tests (folder) -call "%INTEGRATION_TEST_ELECTRON_PATH%" %~dp0\..\extensions\vscode-api-tests\testWorkspace --enable-proposed-api=vscode.vscode-api-tests --extensionDevelopmentPath=%~dp0\..\extensions\vscode-api-tests --extensionTestsPath=%~dp0\..\extensions\vscode-api-tests\out\singlefolder-tests %API_TESTS_EXTRA_ARGS% -if %errorlevel% neq 0 exit /b %errorlevel% - -echo. -echo ### API tests (workspace) -call "%INTEGRATION_TEST_ELECTRON_PATH%" %~dp0\..\extensions\vscode-api-tests\testworkspace.code-workspace --enable-proposed-api=vscode.vscode-api-tests --extensionDevelopmentPath=%~dp0\..\extensions\vscode-api-tests --extensionTestsPath=%~dp0\..\extensions\vscode-api-tests\out\workspace-tests %API_TESTS_EXTRA_ARGS% -if %errorlevel% neq 0 exit /b %errorlevel% - -echo. -echo ### Colorize tests -call npm run test-extension -l vscode-colorize-tests -if %errorlevel% neq 0 exit /b %errorlevel% - -echo. -echo ### TypeScript tests -call "%INTEGRATION_TEST_ELECTRON_PATH%" %~dp0\..\extensions\typescript-language-features\test-workspace --extensionDevelopmentPath=%~dp0\..\extensions\typescript-language-features --extensionTestsPath=%~dp0\..\extensions\typescript-language-features\out\test\unit %API_TESTS_EXTRA_ARGS% -if %errorlevel% neq 0 exit /b %errorlevel% - -echo. -echo ### Markdown tests -call npm run test-extension -l markdown-language-features -if %errorlevel% neq 0 exit /b %errorlevel% - -echo. -echo ### Emmet tests -call "%INTEGRATION_TEST_ELECTRON_PATH%" %~dp0\..\extensions\emmet\test-workspace --extensionDevelopmentPath=%~dp0\..\extensions\emmet --extensionTestsPath=%~dp0\..\extensions\emmet\out\test %API_TESTS_EXTRA_ARGS% -if %errorlevel% neq 0 exit /b %errorlevel% - -echo. -echo ### Git tests -for /f "delims=" %%i in ('node -p "require('fs').realpathSync.native(require('os').tmpdir())"') do set TEMPDIR=%%i -set GITWORKSPACE=%TEMPDIR%\git-%RANDOM% -mkdir %GITWORKSPACE% -call "%INTEGRATION_TEST_ELECTRON_PATH%" %GITWORKSPACE% --extensionDevelopmentPath=%~dp0\..\extensions\git --extensionTestsPath=%~dp0\..\extensions\git\out\test %API_TESTS_EXTRA_ARGS% -if %errorlevel% neq 0 exit /b %errorlevel% - -echo. -echo ### Ipynb tests -call npm run test-extension -l ipynb -if %errorlevel% neq 0 exit /b %errorlevel% - -echo. -echo ### Notebook Output tests -call npm run test-extension -l notebook-renderers -if %errorlevel% neq 0 exit /b %errorlevel% - -echo. -echo ### Configuration editing tests -set CFWORKSPACE=%TEMPDIR%\cf-%RANDOM% -mkdir %CFWORKSPACE% -call npm run test-extension -l configuration-editing -if %errorlevel% neq 0 exit /b %errorlevel% - -echo. -echo ### GitHub Authentication tests -call npm run test-extension -l github-authentication -if %errorlevel% neq 0 exit /b %errorlevel% - -:: Tests standalone (CommonJS) - -echo. -echo ### CSS tests -call %~dp0\node-electron.bat %~dp0\..\extensions\css-language-features/server/test/index.js -if %errorlevel% neq 0 exit /b %errorlevel% - -echo. -echo ### HTML tests -call %~dp0\node-electron.bat %~dp0\..\extensions\html-language-features/server/test/index.js -if %errorlevel% neq 0 exit /b %errorlevel% - - -:: Cleanup - -rmdir /s /q %VSCODEUSERDATADIR% - -popd - -endlocal diff --git a/scripts/test-integration-amd.sh b/scripts/test-integration-amd.sh deleted file mode 100755 index 70f50cc306e..00000000000 --- a/scripts/test-integration-amd.sh +++ /dev/null @@ -1,136 +0,0 @@ -#!/usr/bin/env bash -set -e - -if [[ "$OSTYPE" == "darwin"* ]]; then - realpath() { [[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}"; } - ROOT=$(dirname $(dirname $(realpath "$0"))) -else - ROOT=$(dirname $(dirname $(readlink -f $0))) - # --disable-dev-shm-usage: when run on docker containers where size of /dev/shm - # partition < 64MB which causes OOM failure for chromium compositor that uses the partition for shared memory - LINUX_EXTRA_ARGS="--disable-dev-shm-usage" -fi - -VSCODEUSERDATADIR=`mktemp -d 2>/dev/null` -VSCODECRASHDIR=$ROOT/.build/crashes -VSCODELOGSDIR=$ROOT/.build/logs/integration-tests - -cd $ROOT - -# Figure out which Electron to use for running tests -if [ -z "$INTEGRATION_TEST_ELECTRON_PATH" ] -then - INTEGRATION_TEST_ELECTRON_PATH="./scripts/code.sh" - - echo "Running integration tests out of sources." -else - export VSCODE_CLI=1 - export ELECTRON_ENABLE_LOGGING=1 - - echo "Running integration tests with '$INTEGRATION_TEST_ELECTRON_PATH' as build." -fi - -echo "Storing crash reports into '$VSCODECRASHDIR'." -echo "Storing log files into '$VSCODELOGSDIR'." - - -# Tests standalone (AMD) - -echo -echo "### node.js integration tests" -echo -./scripts/test-amd.sh --runGlob **/*.integrationTest.js "$@" - - -# Tests in the extension host - -API_TESTS_EXTRA_ARGS="--disable-telemetry --skip-welcome --skip-release-notes --crash-reporter-directory=$VSCODECRASHDIR --logsPath=$VSCODELOGSDIR --no-cached-data --disable-updates --use-inmemory-secretstorage --disable-extensions --disable-workspace-trust --user-data-dir=$VSCODEUSERDATADIR" - -if [ -z "$INTEGRATION_TEST_APP_NAME" ]; then - kill_app() { true; } -else - kill_app() { killall $INTEGRATION_TEST_APP_NAME || true; } -fi - -echo -echo "### API tests (folder)" -echo -"$INTEGRATION_TEST_ELECTRON_PATH" $LINUX_EXTRA_ARGS $ROOT/extensions/vscode-api-tests/testWorkspace --enable-proposed-api=vscode.vscode-api-tests --extensionDevelopmentPath=$ROOT/extensions/vscode-api-tests --extensionTestsPath=$ROOT/extensions/vscode-api-tests/out/singlefolder-tests $API_TESTS_EXTRA_ARGS -kill_app - -echo -echo "### API tests (workspace)" -echo -"$INTEGRATION_TEST_ELECTRON_PATH" $LINUX_EXTRA_ARGS $ROOT/extensions/vscode-api-tests/testworkspace.code-workspace --enable-proposed-api=vscode.vscode-api-tests --extensionDevelopmentPath=$ROOT/extensions/vscode-api-tests --extensionTestsPath=$ROOT/extensions/vscode-api-tests/out/workspace-tests $API_TESTS_EXTRA_ARGS -kill_app - -echo -echo "### Colorize tests" -echo -npm run test-extension -l vscode-colorize-tests -kill_app - -echo -echo "### TypeScript tests" -echo -"$INTEGRATION_TEST_ELECTRON_PATH" $LINUX_EXTRA_ARGS $ROOT/extensions/typescript-language-features/test-workspace --extensionDevelopmentPath=$ROOT/extensions/typescript-language-features --extensionTestsPath=$ROOT/extensions/typescript-language-features/out/test/unit $API_TESTS_EXTRA_ARGS -kill_app - -echo -echo "### Markdown tests" -echo -npm run test-extension -l markdown-language-features -kill_app - -echo -echo "### Emmet tests" -echo -"$INTEGRATION_TEST_ELECTRON_PATH" $LINUX_EXTRA_ARGS $ROOT/extensions/emmet/test-workspace --extensionDevelopmentPath=$ROOT/extensions/emmet --extensionTestsPath=$ROOT/extensions/emmet/out/test $API_TESTS_EXTRA_ARGS -kill_app - -echo -echo "### Git tests" -echo -"$INTEGRATION_TEST_ELECTRON_PATH" $LINUX_EXTRA_ARGS $(mktemp -d 2>/dev/null) --extensionDevelopmentPath=$ROOT/extensions/git --extensionTestsPath=$ROOT/extensions/git/out/test $API_TESTS_EXTRA_ARGS -kill_app - -echo -echo "### Ipynb tests" -echo -npm run test-extension -l ipynb -kill_app - -echo -echo "### Notebook Output tests" -echo -npm run test-extension -l notebook-renderers -kill_app - -echo -echo "### Configuration editing tests" -echo -npm run test-extension -l configuration-editing -kill_app - -echo -echo "### GitHub Authentication tests" -echo -npm run test-extension -l github-authentication -kill_app - -# Tests standalone (CommonJS) - -echo -echo "### CSS tests" -echo -cd $ROOT/extensions/css-language-features/server && $ROOT/scripts/node-electron.sh test/index.js - -echo -echo "### HTML tests" -echo -cd $ROOT/extensions/html-language-features/server && $ROOT/scripts/node-electron.sh test/index.js - - -# Cleanup - -rm -rf $VSCODEUSERDATADIR diff --git a/test/unit/browser/index.amd.js b/test/unit/browser/index.amd.js deleted file mode 100644 index 359a071b61e..00000000000 --- a/test/unit/browser/index.amd.js +++ /dev/null @@ -1,395 +0,0 @@ -/*--------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. - *--------------------------------------------------------------------------------------------*/ - -//@ts-check -'use strict'; - -const path = require('path'); -const glob = require('glob'); -const events = require('events'); -const mocha = require('mocha'); -const createStatsCollector = require('mocha/lib/stats-collector'); -const MochaJUnitReporter = require('mocha-junit-reporter'); -const url = require('url'); -const minimatch = require('minimatch'); -const fs = require('fs'); -const playwright = require('@playwright/test'); -const { applyReporter } = require('../reporter'); -const yaserver = require('yaserver'); -const http = require('http'); -const { randomBytes } = require('crypto'); -const minimist = require('minimist'); - -/** - * @type {{ - * run: string; - * grep: string; - * runGlob: string; - * browser: string; - * reporter: string; - * 'reporter-options': string; - * tfs: string; - * build: boolean; - * debug: boolean; - * sequential: boolean; - * help: boolean; - * }} -*/ -const args = minimist(process.argv.slice(2), { - boolean: ['build', 'debug', 'sequential', 'help'], - string: ['run', 'grep', 'runGlob', 'browser', 'reporter', 'reporter-options', 'tfs'], - default: { - build: false, - browser: ['chromium', 'firefox', 'webkit'], - reporter: process.platform === 'win32' ? 'list' : 'spec', - 'reporter-options': '' - }, - alias: { - grep: ['g', 'f'], - runGlob: ['glob', 'runGrep'], - debug: ['debug-browser'], - help: 'h' - }, - describe: { - build: 'run with build output (out-build)', - run: 'only run tests matching ', - grep: 'only run tests matching ', - debug: 'do not run browsers headless', - sequential: 'only run suites for a single browser at a time', - browser: 'browsers in which tests should run', - reporter: 'the mocha reporter', - 'reporter-options': 'the mocha reporter options', - tfs: 'tfs', - help: 'show the help' - } -}); - -if (args.help) { - console.log(`Usage: node ${process.argv[1]} [options] - -Options: ---build run with build output (out-build) ---run only run tests matching ---grep, -g, -f only run tests matching ---debug, --debug-browser do not run browsers headless ---sequential only run suites for a single browser at a time ---browser browsers in which tests should run ---reporter the mocha reporter ---reporter-options the mocha reporter options ---tfs tfs ---help, -h show the help`); - process.exit(0); -} - -const withReporter = (function () { - if (args.tfs) { - { - return (browserType, runner) => { - new mocha.reporters.Spec(runner); - new MochaJUnitReporter(runner, { - reporterOptions: { - testsuitesTitle: `${args.tfs} ${process.platform}`, - mochaFile: process.env.BUILD_ARTIFACTSTAGINGDIRECTORY ? path.join(process.env.BUILD_ARTIFACTSTAGINGDIRECTORY, `test-results/${process.platform}-${process.arch}-${browserType}-${args.tfs.toLowerCase().replace(/[^\w]/g, '-')}-results.xml`) : undefined - } - }); - }; - } - } else { - return (_, runner) => applyReporter(runner, args); - } -})(); - -const outdir = args.build ? 'out-build' : 'out'; -const rootDir = path.resolve(__dirname, '..', '..', '..'); -const out = path.join(rootDir, `${outdir}`); - -function ensureIsArray(a) { - return Array.isArray(a) ? a : [a]; -} - -const testModules = (async function () { - - const excludeGlob = '**/{node,electron-sandbox,electron-main,electron-utility}/**/*.test.js'; - let isDefaultModules = true; - let promise; - - if (args.run) { - // use file list (--run) - isDefaultModules = false; - promise = Promise.resolve(ensureIsArray(args.run).map(file => { - file = file.replace(/^src/, 'out'); - file = file.replace(/\.ts$/, '.js'); - return path.relative(out, file); - })); - - } else { - // glob patterns (--glob) - const defaultGlob = '**/*.test.js'; - const pattern = args.runGlob || defaultGlob; - isDefaultModules = pattern === defaultGlob; - - promise = new Promise((resolve, reject) => { - glob(pattern, { cwd: out }, (err, files) => { - if (err) { - reject(err); - } else { - resolve(files); - } - }); - }); - } - - return promise.then(files => { - const modules = []; - for (const file of files) { - if (!minimatch(file, excludeGlob)) { - modules.push(file.replace(/\.js$/, '')); - - } else if (!isDefaultModules) { - console.warn(`DROPPONG ${file} because it cannot be run inside a browser`); - } - } - return modules; - }); -})(); - -function consoleLogFn(msg) { - const type = msg.type(); - const candidate = console[type]; - if (candidate) { - return candidate; - } - - if (type === 'warning') { - return console.warn; - } - - return console.log; -} - -async function createServer() { - // Demand a prefix to avoid issues with other services on the - // machine being able to access the test server. - const prefix = '/' + randomBytes(16).toString('hex'); - const serveStatic = await yaserver.createServer({ rootDir }); - - /** Handles a request for a remote method call, invoking `fn` and returning the result */ - const remoteMethod = async (req, response, fn) => { - const params = await new Promise((resolve, reject) => { - const body = []; - req.on('data', chunk => body.push(chunk)); - req.on('end', () => resolve(JSON.parse(Buffer.concat(body).toString()))); - req.on('error', reject); - }); - - const result = await fn(...params); - response.writeHead(200, { 'Content-Type': 'application/json' }); - response.end(JSON.stringify(result)); - }; - - const server = http.createServer((request, response) => { - if (!request.url?.startsWith(prefix)) { - return response.writeHead(404).end(); - } - - // rewrite the URL so the static server can handle the request correctly - request.url = request.url.slice(prefix.length); - - switch (request.url) { - case '/remoteMethod/__readFileInTests': - return remoteMethod(request, response, p => fs.promises.readFile(p, 'utf-8')); - case '/remoteMethod/__writeFileInTests': - return remoteMethod(request, response, (p, contents) => fs.promises.writeFile(p, contents)); - case '/remoteMethod/__readDirInTests': - return remoteMethod(request, response, p => fs.promises.readdir(p)); - case '/remoteMethod/__unlinkInTests': - return remoteMethod(request, response, p => fs.promises.unlink(p)); - case '/remoteMethod/__mkdirPInTests': - return remoteMethod(request, response, p => fs.promises.mkdir(p, { recursive: true })); - default: - return serveStatic.handle(request, response); - } - }); - - return new Promise((resolve, reject) => { - server.listen(0, 'localhost', () => { - resolve({ - dispose: () => server.close(), - // @ts-ignore - url: `http://localhost:${server.address().port}${prefix}` - }); - }); - server.on('error', reject); - }); -} - -async function runTestsInBrowser(testModules, browserType) { - const server = await createServer(); - const browser = await playwright[browserType].launch({ headless: !Boolean(args.debug), devtools: Boolean(args.debug) }); - const context = await browser.newContext(); - const page = await context.newPage(); - const target = new URL(server.url + '/test/unit/browser/renderer.amd.html'); - target.searchParams.set('baseUrl', url.pathToFileURL(path.join(rootDir, 'src2')).toString()); - if (args.build) { - target.searchParams.set('build', 'true'); - } - if (process.env.BUILD_ARTIFACTSTAGINGDIRECTORY) { - target.searchParams.set('ci', 'true'); - } - - const emitter = new events.EventEmitter(); - await page.exposeFunction('mocha_report', (type, data1, data2) => { - emitter.emit(type, data1, data2); - }); - - await page.goto(target.href); - - if (args.build) { - const nlsMessages = await fs.promises.readFile(path.join(out, 'nls.messages.json'), 'utf8'); - await page.evaluate(value => { - // when running from `out-build`, ensure to load the default - // messages file, because all `nls.localize` calls have their - // english values removed and replaced by an index. - // @ts-ignore - globalThis._VSCODE_NLS_MESSAGES = JSON.parse(value); - }, nlsMessages); - } - - page.on('console', async msg => { - consoleLogFn(msg)(msg.text(), await Promise.all(msg.args().map(async arg => await arg.jsonValue()))); - }); - - withReporter(browserType, new EchoRunner(emitter, browserType.toUpperCase())); - - // collection failures for console printing - const failingModuleIds = []; - const failingTests = []; - emitter.on('fail', (test, err) => { - failingTests.push({ title: test.fullTitle, message: err.message }); - - if (err.stack) { - const regex = /(vs\/.*\.test)\.js/; - for (const line of String(err.stack).split('\n')) { - const match = regex.exec(line); - if (match) { - failingModuleIds.push(match[1]); - return; - } - } - } - }); - - try { - // @ts-expect-error - await page.evaluate(opts => loadAndRun(opts), { - modules: testModules, - grep: args.grep, - }); - } catch (err) { - console.error(err); - } - server.dispose(); - await browser.close(); - - if (failingTests.length > 0) { - let res = `The followings tests are failing:\n - ${failingTests.map(({ title, message }) => `${title} (reason: ${message})`).join('\n - ')}`; - - if (failingModuleIds.length > 0) { - res += `\n\nTo DEBUG, open ${browserType.toUpperCase()} and navigate to ${target.href}?${failingModuleIds.map(module => `m=${module}`).join('&')}`; - } - - return `${res}\n`; - } -} - -class EchoRunner extends events.EventEmitter { - - constructor(event, title = '') { - super(); - createStatsCollector(this); - event.on('start', () => this.emit('start')); - event.on('end', () => this.emit('end')); - event.on('suite', (suite) => this.emit('suite', EchoRunner.deserializeSuite(suite, title))); - event.on('suite end', (suite) => this.emit('suite end', EchoRunner.deserializeSuite(suite, title))); - event.on('test', (test) => this.emit('test', EchoRunner.deserializeRunnable(test))); - event.on('test end', (test) => this.emit('test end', EchoRunner.deserializeRunnable(test))); - event.on('hook', (hook) => this.emit('hook', EchoRunner.deserializeRunnable(hook))); - event.on('hook end', (hook) => this.emit('hook end', EchoRunner.deserializeRunnable(hook))); - event.on('pass', (test) => this.emit('pass', EchoRunner.deserializeRunnable(test))); - event.on('fail', (test, err) => this.emit('fail', EchoRunner.deserializeRunnable(test, title), EchoRunner.deserializeError(err))); - event.on('pending', (test) => this.emit('pending', EchoRunner.deserializeRunnable(test))); - } - - static deserializeSuite(suite, titleExtra) { - return { - root: suite.root, - suites: suite.suites, - tests: suite.tests, - title: titleExtra && suite.title ? `${suite.title} - /${titleExtra}/` : suite.title, - titlePath: () => suite.titlePath, - fullTitle: () => suite.fullTitle, - timeout: () => suite.timeout, - retries: () => suite.retries, - slow: () => suite.slow, - bail: () => suite.bail - }; - } - - static deserializeRunnable(runnable, titleExtra) { - return { - title: runnable.title, - fullTitle: () => titleExtra && runnable.fullTitle ? `${runnable.fullTitle} - /${titleExtra}/` : runnable.fullTitle, - titlePath: () => runnable.titlePath, - async: runnable.async, - slow: () => runnable.slow, - speed: runnable.speed, - duration: runnable.duration, - currentRetry: () => runnable.currentRetry, - }; - } - - static deserializeError(err) { - const inspect = err.inspect; - err.inspect = () => inspect; - return err; - } -} - -testModules.then(async modules => { - - // run tests in selected browsers - const browserTypes = Array.isArray(args.browser) - ? args.browser : [args.browser]; - - let messages = []; - let didFail = false; - - try { - if (args.sequential) { - for (const browserType of browserTypes) { - messages.push(await runTestsInBrowser(modules, browserType)); - } - } else { - messages = await Promise.all(browserTypes.map(async browserType => { - return await runTestsInBrowser(modules, browserType); - })); - } - } catch (err) { - console.error(err); - process.exit(1); - } - - // aftermath - for (const msg of messages) { - if (msg) { - didFail = true; - console.log(msg); - } - } - process.exit(didFail ? 1 : 0); - -}).catch(err => { - console.error(err); -}); diff --git a/test/unit/browser/renderer.amd.html b/test/unit/browser/renderer.amd.html deleted file mode 100644 index 28e6912fcad..00000000000 --- a/test/unit/browser/renderer.amd.html +++ /dev/null @@ -1,187 +0,0 @@ - - - - - VSCode Tests - - - - -
- - - - - - - - - - - - - diff --git a/test/unit/electron/index.amd.js b/test/unit/electron/index.amd.js deleted file mode 100644 index a02f5613e02..00000000000 --- a/test/unit/electron/index.amd.js +++ /dev/null @@ -1,350 +0,0 @@ -/*--------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. - *--------------------------------------------------------------------------------------------*/ - -//@ts-check -'use strict'; - -// mocha disables running through electron by default. Note that this must -// come before any mocha imports. -process.env.MOCHA_COLORS = '1'; - -const { app, BrowserWindow, ipcMain, crashReporter } = require('electron'); -const product = require('../../../product.json'); -const { tmpdir } = require('os'); -const { existsSync, mkdirSync } = require('fs'); -const path = require('path'); -const mocha = require('mocha'); -const events = require('events'); -const MochaJUnitReporter = require('mocha-junit-reporter'); -const url = require('url'); -const net = require('net'); -const createStatsCollector = require('mocha/lib/stats-collector'); -const { applyReporter, importMochaReporter } = require('../reporter'); - -const minimist = require('minimist'); - -/** - * @type {{ - * grep: string; - * run: string; - * runGlob: string; - * dev: boolean; - * reporter: string; - * 'reporter-options': string; - * 'waitServer': string; - * timeout: string; - * 'crash-reporter-directory': string; - * tfs: string; - * build: boolean; - * coverage: boolean; - * coveragePath: string; - * coverageFormats: string | string[]; - * 'per-test-coverage': boolean; - * help: boolean; - * }} - */ -const args = minimist(process.argv.slice(2), { - string: ['grep', 'run', 'runGlob', 'reporter', 'reporter-options', 'waitServer', 'timeout', 'crash-reporter-directory', 'tfs', 'coveragePath', 'coverageFormats'], - boolean: ['build', 'coverage', 'help', 'dev', 'per-test-coverage'], - alias: { - 'grep': ['g', 'f'], - 'runGlob': ['glob', 'runGrep'], - 'dev': ['dev-tools', 'devTools'], - 'help': 'h' - }, - default: { - 'reporter': 'spec', - 'reporter-options': '' - } -}); - -if (args.help) { - console.log(`Usage: node ${process.argv[1]} [options] - -Options: ---grep, -g, -f only run tests matching ---run only run tests from ---runGlob, --glob, --runGrep only run tests matching ---build run with build output (out-build) ---coverage generate coverage report ---per-test-coverage generate a per-test V8 coverage report, only valid with the full-json-stream reporter ---dev, --dev-tools, --devTools open dev tools, keep window open, reuse app data ---reporter the mocha reporter (default: "spec") ---reporter-options the mocha reporter options (default: "") ---waitServer port to connect to and wait before running tests ---timeout timeout for tests ---crash-reporter-directory crash reporter directory ---tfs TFS server URL ---help, -h show the help`); - process.exit(0); -} - -let crashReporterDirectory = args['crash-reporter-directory']; -if (crashReporterDirectory) { - crashReporterDirectory = path.normalize(crashReporterDirectory); - - if (!path.isAbsolute(crashReporterDirectory)) { - console.error(`The path '${crashReporterDirectory}' specified for --crash-reporter-directory must be absolute.`); - app.exit(1); - } - - if (!existsSync(crashReporterDirectory)) { - try { - mkdirSync(crashReporterDirectory); - } catch (error) { - console.error(`The path '${crashReporterDirectory}' specified for --crash-reporter-directory does not seem to exist or cannot be created.`); - app.exit(1); - } - } - - // Crashes are stored in the crashDumps directory by default, so we - // need to change that directory to the provided one - console.log(`Found --crash-reporter-directory argument. Setting crashDumps directory to be '${crashReporterDirectory}'`); - app.setPath('crashDumps', crashReporterDirectory); - - crashReporter.start({ - companyName: 'Microsoft', - productName: process.env['VSCODE_DEV'] ? `${product.nameShort} Dev` : product.nameShort, - uploadToServer: false, - compress: true - }); -} - -if (!args.dev) { - app.setPath('userData', path.join(tmpdir(), `vscode-tests-${Date.now()}`)); -} - -function deserializeSuite(suite) { - return { - root: suite.root, - suites: suite.suites, - tests: suite.tests, - title: suite.title, - titlePath: () => suite.titlePath, - fullTitle: () => suite.fullTitle, - timeout: () => suite.timeout, - retries: () => suite.retries, - slow: () => suite.slow, - bail: () => suite.bail - }; -} - -function deserializeRunnable(runnable) { - return { - title: runnable.title, - titlePath: () => runnable.titlePath, - fullTitle: () => runnable.fullTitle, - async: runnable.async, - slow: () => runnable.slow, - speed: runnable.speed, - duration: runnable.duration, - currentRetry: () => runnable.currentRetry - }; -} - -function deserializeError(err) { - const inspect = err.inspect; - err.inspect = () => inspect; - // Unfortunately, mocha rewrites and formats err.actual/err.expected. - // This formatting is hard to reverse, so err.*JSON includes the unformatted value. - if (err.actual) { - err.actual = JSON.parse(err.actual).value; - err.actualJSON = err.actual; - } - if (err.expected) { - err.expected = JSON.parse(err.expected).value; - err.expectedJSON = err.expected; - } - return err; -} - -class IPCRunner extends events.EventEmitter { - - constructor(win) { - super(); - - this.didFail = false; - this.didEnd = false; - - ipcMain.on('start', () => this.emit('start')); - ipcMain.on('end', () => { - this.didEnd = true; - this.emit('end'); - }); - ipcMain.on('suite', (e, suite) => this.emit('suite', deserializeSuite(suite))); - ipcMain.on('suite end', (e, suite) => this.emit('suite end', deserializeSuite(suite))); - ipcMain.on('test', (e, test) => this.emit('test', deserializeRunnable(test))); - ipcMain.on('test end', (e, test) => this.emit('test end', deserializeRunnable(test))); - ipcMain.on('hook', (e, hook) => this.emit('hook', deserializeRunnable(hook))); - ipcMain.on('hook end', (e, hook) => this.emit('hook end', deserializeRunnable(hook))); - ipcMain.on('pass', (e, test) => this.emit('pass', deserializeRunnable(test))); - ipcMain.on('fail', (e, test, err) => { - this.didFail = true; - this.emit('fail', deserializeRunnable(test), deserializeError(err)); - }); - ipcMain.on('pending', (e, test) => this.emit('pending', deserializeRunnable(test))); - - ipcMain.handle('startCoverage', async () => { - win.webContents.debugger.attach(); - await win.webContents.debugger.sendCommand('Debugger.enable'); - await win.webContents.debugger.sendCommand('Profiler.enable'); - await win.webContents.debugger.sendCommand('Profiler.startPreciseCoverage', { - detailed: true, - allowTriggeredUpdates: false, - }); - }); - - const coverageScriptsReported = new Set(); - ipcMain.handle('snapshotCoverage', async (_, test) => { - const coverage = await win.webContents.debugger.sendCommand('Profiler.takePreciseCoverage'); - await Promise.all(coverage.result.map(async (r) => { - if (!coverageScriptsReported.has(r.scriptId)) { - coverageScriptsReported.add(r.scriptId); - const src = await win.webContents.debugger.sendCommand('Debugger.getScriptSource', { scriptId: r.scriptId }); - r.source = src.scriptSource; - } - })); - - if (!test) { - this.emit('coverage init', coverage); - } else { - this.emit('coverage increment', test, coverage); - } - }); - } -} - -app.on('ready', () => { - - ipcMain.on('error', (_, err) => { - if (!args.dev) { - console.error(err); - app.exit(1); - } - }); - - // We need to provide a basic `ISandboxConfiguration` - // for our preload script to function properly because - // some of our types depend on it (e.g. product.ts). - ipcMain.handle('vscode:test-vscode-window-config', async () => { - return { - product: { - version: '1.x.y', - nameShort: 'Code - OSS Dev', - nameLong: 'Code - OSS Dev', - applicationName: 'code-oss', - dataFolderName: '.vscode-oss', - urlProtocol: 'code-oss', - } - }; - }); - - // No-op since invoke the IPC as part of IIFE in the preload. - ipcMain.handle('vscode:fetchShellEnv', event => { }); - - const win = new BrowserWindow({ - height: 600, - width: 800, - show: false, - webPreferences: { - preload: path.join(__dirname, 'preload.js'), // ensure similar environment as VSCode as tests may depend on this - additionalArguments: [`--vscode-window-config=vscode:test-vscode-window-config`], - nodeIntegration: true, - contextIsolation: false, - enableWebSQL: false, - spellcheck: false - } - }); - - win.webContents.on('did-finish-load', () => { - if (args.dev) { - win.show(); - win.webContents.openDevTools(); - } - - if (args.waitServer) { - waitForServer(Number(args.waitServer)).then(sendRun); - } else { - sendRun(); - } - }); - - async function waitForServer(port) { - let timeout; - let socket; - - return new Promise(resolve => { - socket = net.connect(port, '127.0.0.1'); - socket.on('error', e => { - console.error('error connecting to waitServer', e); - resolve(undefined); - }); - - socket.on('close', () => { - resolve(undefined); - }); - - timeout = setTimeout(() => { - console.error('timed out waiting for before starting tests debugger'); - resolve(undefined); - }, 15000); - }).finally(() => { - if (socket) { - socket.end(); - } - clearTimeout(timeout); - }); - } - - function sendRun() { - win.webContents.send('run', args); - } - - win.loadURL(url.format({ pathname: path.join(__dirname, 'renderer.amd.html'), protocol: 'file:', slashes: true })); - - const runner = new IPCRunner(win); - createStatsCollector(runner); - - // Handle renderer crashes, #117068 - win.webContents.on('render-process-gone', (evt, details) => { - if (!runner.didEnd) { - console.error(`Renderer process crashed with: ${JSON.stringify(details)}`); - app.exit(1); - } - }); - - const reporters = []; - - if (args.tfs) { - reporters.push( - new mocha.reporters.Spec(runner), - new MochaJUnitReporter(runner, { - reporterOptions: { - testsuitesTitle: `${args.tfs} ${process.platform}`, - mochaFile: process.env.BUILD_ARTIFACTSTAGINGDIRECTORY ? path.join(process.env.BUILD_ARTIFACTSTAGINGDIRECTORY, `test-results/${process.platform}-${process.arch}-${args.tfs.toLowerCase().replace(/[^\w]/g, '-')}-results.xml`) : undefined - } - }), - ); - } else { - // mocha patches symbols to use windows escape codes, but it seems like - // Electron mangles these in its output. - if (process.platform === 'win32') { - Object.assign(importMochaReporter('base').symbols, { - ok: '+', - err: 'X', - dot: '.', - }); - } - - reporters.push(applyReporter(runner, args)); - } - - if (!args.dev) { - ipcMain.on('all done', async () => { - await Promise.all(reporters.map(r => r.drain?.())); - app.exit(runner.didFail ? 1 : 0); - }); - } -}); diff --git a/test/unit/electron/renderer.amd.html b/test/unit/electron/renderer.amd.html deleted file mode 100644 index 3f022d009e0..00000000000 --- a/test/unit/electron/renderer.amd.html +++ /dev/null @@ -1,35 +0,0 @@ - - - - - VSCode Tests - - - - -
- - - - - - diff --git a/test/unit/electron/renderer.amd.js b/test/unit/electron/renderer.amd.js deleted file mode 100644 index 43afa46a4c5..00000000000 --- a/test/unit/electron/renderer.amd.js +++ /dev/null @@ -1,475 +0,0 @@ -/*--------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. - *--------------------------------------------------------------------------------------------*/ - -/*eslint-env mocha*/ - -const fs = require('fs'); -const inspector = require('inspector'); - -(function () { - const originals = {}; - let logging = false; - let withStacks = false; - - self.beginLoggingFS = (_withStacks) => { - logging = true; - withStacks = _withStacks || false; - }; - self.endLoggingFS = () => { - logging = false; - withStacks = false; - }; - - function createSpy(element, cnt) { - return function (...args) { - if (logging) { - console.log(`calling ${element}: ` + args.slice(0, cnt).join(',') + (withStacks ? (`\n` + new Error().stack.split('\n').slice(2).join('\n')) : '')); - } - return originals[element].call(this, ...args); - }; - } - - function intercept(element, cnt) { - originals[element] = fs[element]; - fs[element] = createSpy(element, cnt); - } - - [ - ['realpathSync', 1], - ['readFileSync', 1], - ['openSync', 3], - ['readSync', 1], - ['closeSync', 1], - ['readFile', 2], - ['mkdir', 1], - ['lstat', 1], - ['stat', 1], - ['watch', 1], - ['readdir', 1], - ['access', 2], - ['open', 2], - ['write', 1], - ['fdatasync', 1], - ['close', 1], - ['read', 1], - ['unlink', 1], - ['rmdir', 1], - ].forEach((element) => { - intercept(element[0], element[1]); - }); -})(); - -const { ipcRenderer } = require('electron'); -const assert = require('assert'); -const path = require('path'); -const glob = require('glob'); -const util = require('util'); -const coverage = require('../coverage'); -const { takeSnapshotAndCountClasses } = require('../analyzeSnapshot'); - -// Disabled custom inspect. See #38847 -if (util.inspect && util.inspect['defaultOptions']) { - util.inspect['defaultOptions'].customInspect = false; -} - -// VSCODE_GLOBALS: package/product.json -globalThis._VSCODE_PRODUCT_JSON = (require.__$__nodeRequire ?? require)('../../../product.json'); -globalThis._VSCODE_PACKAGE_JSON = (require.__$__nodeRequire ?? require)('../../../package.json'); - -// Test file operations that are common across platforms. Used for test infra, namely snapshot tests -Object.assign(globalThis, { - __analyzeSnapshotInTests: takeSnapshotAndCountClasses, - __readFileInTests: path => fs.promises.readFile(path, 'utf-8'), - __writeFileInTests: (path, contents) => fs.promises.writeFile(path, contents), - __readDirInTests: path => fs.promises.readdir(path), - __unlinkInTests: path => fs.promises.unlink(path), - __mkdirPInTests: path => fs.promises.mkdir(path, { recursive: true }), -}); - -const IS_CI = !!process.env.BUILD_ARTIFACTSTAGINGDIRECTORY; -const _tests_glob = '**/test/**/*.test.js'; -let loader; -let _out; - -function initNls(opts) { - if (opts.build) { - // when running from `out-build`, ensure to load the default - // messages file, because all `nls.localize` calls have their - // english values removed and replaced by an index. - globalThis._VSCODE_NLS_MESSAGES = (require.__$__nodeRequire ?? require)(`../../../out-build/nls.messages.json`); - } -} - -function initLoader(opts) { - const outdir = opts.build ? 'out-build' : 'out'; - _out = path.join(__dirname, `../../../${outdir}`); - - const bootstrapNode = require(`../../../${outdir}/bootstrap-node`); - - // setup loader - loader = require(`${_out}/vs/loader`); - const loaderConfig = { - nodeRequire: require, - catchError: true, - baseUrl: bootstrapNode.fileUriFromPath(path.join(__dirname, '../../../src2'), { isWindows: process.platform === 'win32' }), - paths: { - 'vs': `../${outdir}/vs`, - 'lib': `../${outdir}/lib`, - 'bootstrap-fork': `../${outdir}/bootstrap-fork` - } - }; - - if (opts.coverage) { - // initialize coverage if requested - coverage.initialize(loaderConfig); - } - - loader.require.config(loaderConfig); -} - -function createCoverageReport(opts) { - if (opts.coverage) { - return coverage.createReport(opts.run || opts.runGlob, opts.coveragePath, opts.coverageFormats); - } - return Promise.resolve(undefined); -} - -function loadWorkbenchTestingUtilsModule() { - return new Promise((resolve, reject) => { - loader.require(['vs/workbench/test/common/utils'], resolve, reject); - }); -} - -async function loadModules(modules) { - for (const file of modules) { - mocha.suite.emit(Mocha.Suite.constants.EVENT_FILE_PRE_REQUIRE, globalThis, file, mocha); - const m = await new Promise((resolve, reject) => loader.require([file], resolve, reject)); - mocha.suite.emit(Mocha.Suite.constants.EVENT_FILE_REQUIRE, m, file, mocha); - mocha.suite.emit(Mocha.Suite.constants.EVENT_FILE_POST_REQUIRE, globalThis, file, mocha); - } -} - -function loadTestModules(opts) { - - if (opts.run) { - const files = Array.isArray(opts.run) ? opts.run : [opts.run]; - const modules = files.map(file => { - file = file.replace(/^src[\\/]/, ''); - return file.replace(/\.[jt]s$/, ''); - }); - return loadModules(modules); - } - - const pattern = opts.runGlob || _tests_glob; - - return new Promise((resolve, reject) => { - glob(pattern, { cwd: _out }, (err, files) => { - if (err) { - reject(err); - return; - } - const modules = files.map(file => file.replace(/\.js$/, '')); - resolve(modules); - }); - }).then(loadModules); -} - -/** @type Mocha.Test */ -let currentTest; - -async function loadTests(opts) { - - //#region Unexpected Output - - const _allowedTestOutput = [ - /The vm module of Node\.js is deprecated in the renderer process and will be removed./, - ]; - - // allow snapshot mutation messages locally - if (!IS_CI) { - _allowedTestOutput.push(/Creating new snapshot in/); - _allowedTestOutput.push(/Deleting [0-9]+ old snapshots/); - } - - const perTestCoverage = opts['per-test-coverage'] ? await PerTestCoverage.init() : undefined; - - const _allowedTestsWithOutput = new Set([ - 'creates a snapshot', // self-testing - 'validates a snapshot', // self-testing - 'cleans up old snapshots', // self-testing - 'issue #149412: VS Code hangs when bad semantic token data is received', // https://github.com/microsoft/vscode/issues/192440 - 'issue #134973: invalid semantic tokens should be handled better', // https://github.com/microsoft/vscode/issues/192440 - 'issue #148651: VSCode UI process can hang if a semantic token with negative values is returned by language service', // https://github.com/microsoft/vscode/issues/192440 - 'issue #149130: vscode freezes because of Bracket Pair Colorization', // https://github.com/microsoft/vscode/issues/192440 - 'property limits', // https://github.com/microsoft/vscode/issues/192443 - 'Error events', // https://github.com/microsoft/vscode/issues/192443 - 'fetch returns keybinding with user first if title and id matches', // - 'throw ListenerLeakError' - ]); - - const _allowedSuitesWithOutput = new Set([ - 'InteractiveChatController' - ]); - - let _testsWithUnexpectedOutput = false; - - for (const consoleFn of [console.log, console.error, console.info, console.warn, console.trace, console.debug]) { - console[consoleFn.name] = function (msg) { - if (!currentTest) { - consoleFn.apply(console, arguments); - } else if (!_allowedTestOutput.some(a => a.test(msg)) && !_allowedTestsWithOutput.has(currentTest.title) && !_allowedSuitesWithOutput.has(currentTest.parent?.title)) { - _testsWithUnexpectedOutput = true; - consoleFn.apply(console, arguments); - } - }; - } - - //#endregion - - //#region Unexpected / Loader Errors - - const _unexpectedErrors = []; - const _loaderErrors = []; - - const _allowedTestsWithUnhandledRejections = new Set([ - // Lifecycle tests - 'onWillShutdown - join with error is handled', - 'onBeforeShutdown - veto with error is treated as veto', - 'onBeforeShutdown - final veto with error is treated as veto', - // Search tests - 'Search Model: Search reports timed telemetry on search when error is called' - ]); - - loader.require.config({ - onError(err) { - _loaderErrors.push(err); - console.error(err); - } - }); - - loader.require(['vs/base/common/errors'], function (errors) { - - const onUnexpectedError = function (err) { - if (err.name === 'Canceled') { - return; // ignore canceled errors that are common - } - - let stack = (err ? err.stack : null); - if (!stack) { - stack = new Error().stack; - } - - _unexpectedErrors.push((err && err.message ? err.message : err) + '\n' + stack); - }; - - process.on('uncaughtException', error => onUnexpectedError(error)); - process.on('unhandledRejection', (reason, promise) => { - onUnexpectedError(reason); - promise.catch(() => { }); - }); - window.addEventListener('unhandledrejection', event => { - event.preventDefault(); // Do not log to test output, we show an error later when test ends - event.stopPropagation(); - - if (!_allowedTestsWithUnhandledRejections.has(currentTest.title)) { - onUnexpectedError(event.reason); - } - }); - - errors.setUnexpectedErrorHandler(err => unexpectedErrorHandler(err)); - }); - - //#endregion - - return loadWorkbenchTestingUtilsModule().then((workbenchTestingModule) => { - const assertCleanState = workbenchTestingModule.assertCleanState; - - suite('Tests are using suiteSetup and setup correctly', () => { - test('assertCleanState - check that registries are clean at the start of test running', () => { - assertCleanState(); - }); - }); - - setup(async () => { - await perTestCoverage?.startTest(); - }); - - teardown(async () => { - await perTestCoverage?.finishTest(currentTest.file, currentTest.fullTitle()); - - // should not have unexpected output - // if (_testsWithUnexpectedOutput && !opts.dev) { - // assert.ok(false, 'Error: Unexpected console output in test run. Please ensure no console.[log|error|info|warn] usage in tests or runtime errors.'); - // } - - // should not have unexpected errors - const errors = _unexpectedErrors.concat(_loaderErrors); - if (errors.length) { - for (const error of errors) { - console.error(`Error: Test run should not have unexpected errors:\n${error}`); - } - assert.ok(false, 'Error: Test run should not have unexpected errors.'); - } - }); - - suiteTeardown(() => { // intentionally not in teardown because some tests only cleanup in suiteTeardown - - // should have cleaned up in registries - assertCleanState(); - }); - - return loadTestModules(opts); - }); -} - -function serializeSuite(suite) { - return { - root: suite.root, - suites: suite.suites.map(serializeSuite), - tests: suite.tests.map(serializeRunnable), - title: suite.title, - fullTitle: suite.fullTitle(), - titlePath: suite.titlePath(), - timeout: suite.timeout(), - retries: suite.retries(), - slow: suite.slow(), - bail: suite.bail() - }; -} - -function serializeRunnable(runnable) { - return { - title: runnable.title, - fullTitle: runnable.fullTitle(), - titlePath: runnable.titlePath(), - async: runnable.async, - slow: runnable.slow(), - speed: runnable.speed, - duration: runnable.duration - }; -} - -function serializeError(err) { - return { - message: err.message, - stack: err.stack, - snapshotPath: err.snapshotPath, - actual: safeStringify({ value: err.actual }), - expected: safeStringify({ value: err.expected }), - uncaught: err.uncaught, - showDiff: err.showDiff, - inspect: typeof err.inspect === 'function' ? err.inspect() : '' - }; -} - -function safeStringify(obj) { - const seen = new Set(); - return JSON.stringify(obj, (key, value) => { - if (value === undefined) { - return '[undefined]'; - } - - if (isObject(value) || Array.isArray(value)) { - if (seen.has(value)) { - return '[Circular]'; - } else { - seen.add(value); - } - } - return value; - }); -} - -function isObject(obj) { - // The method can't do a type cast since there are type (like strings) which - // are subclasses of any put not positvely matched by the function. Hence type - // narrowing results in wrong results. - return typeof obj === 'object' - && obj !== null - && !Array.isArray(obj) - && !(obj instanceof RegExp) - && !(obj instanceof Date); -} - -class IPCReporter { - - constructor(runner) { - runner.on('start', () => ipcRenderer.send('start')); - runner.on('end', () => ipcRenderer.send('end')); - runner.on('suite', suite => ipcRenderer.send('suite', serializeSuite(suite))); - runner.on('suite end', suite => ipcRenderer.send('suite end', serializeSuite(suite))); - runner.on('test', test => ipcRenderer.send('test', serializeRunnable(test))); - runner.on('test end', test => ipcRenderer.send('test end', serializeRunnable(test))); - runner.on('hook', hook => ipcRenderer.send('hook', serializeRunnable(hook))); - runner.on('hook end', hook => ipcRenderer.send('hook end', serializeRunnable(hook))); - runner.on('pass', test => ipcRenderer.send('pass', serializeRunnable(test))); - runner.on('fail', (test, err) => ipcRenderer.send('fail', serializeRunnable(test), serializeError(err))); - runner.on('pending', test => ipcRenderer.send('pending', serializeRunnable(test))); - } -} - -function runTests(opts) { - // this *must* come before loadTests, or it doesn't work. - if (opts.timeout !== undefined) { - mocha.timeout(opts.timeout); - } - - return loadTests(opts).then(() => { - - if (opts.grep) { - mocha.grep(opts.grep); - } - - if (!opts.dev) { - mocha.reporter(IPCReporter); - } - - const runner = mocha.run(() => { - createCoverageReport(opts).then(() => { - ipcRenderer.send('all done'); - }); - }); - - runner.on('test', test => currentTest = test); - - if (opts.dev) { - runner.on('fail', (test, err) => { - console.error(test.fullTitle()); - console.error(err.stack); - }); - } - }); -} - -ipcRenderer.on('run', (e, opts) => { - initNls(opts); - initLoader(opts); - runTests(opts).catch(err => { - if (typeof err !== 'string') { - err = JSON.stringify(err); - } - - console.error(err); - ipcRenderer.send('error', err); - }); -}); - -class PerTestCoverage { - static async init() { - await ipcRenderer.invoke('startCoverage'); - return new PerTestCoverage(); - } - - async startTest() { - if (!this.didInit) { - this.didInit = true; - await ipcRenderer.invoke('snapshotCoverage'); - } - } - - async finishTest(file, fullTitle) { - await ipcRenderer.invoke('snapshotCoverage', { file, fullTitle }); - } -} diff --git a/test/unit/node/index.amd.js b/test/unit/node/index.amd.js deleted file mode 100644 index f4ca72bde56..00000000000 --- a/test/unit/node/index.amd.js +++ /dev/null @@ -1,238 +0,0 @@ -/*--------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. - *--------------------------------------------------------------------------------------------*/ - -//@ts-check -'use strict'; - -process.env.MOCHA_COLORS = '1'; // Force colors (note that this must come before any mocha imports) - -const assert = require('assert'); -const Mocha = require('mocha'); -const path = require('path'); -const fs = require('fs'); -const glob = require('glob'); -const minimatch = require('minimatch'); -const coverage = require('../coverage'); -const minimist = require('minimist'); -const { takeSnapshotAndCountClasses } = require('../analyzeSnapshot'); - -/** - * @type {{ build: boolean; run: string; runGlob: string; coverage: boolean; help: boolean; coverageFormats: string | string[]; coveragePath: string; }} - */ -const args = minimist(process.argv.slice(2), { - boolean: ['build', 'coverage', 'help'], - string: ['run', 'coveragePath', 'coverageFormats'], - alias: { - h: 'help' - }, - default: { - build: false, - coverage: false, - help: false - }, - description: { - build: 'Run from out-build', - run: 'Run a single file', - coverage: 'Generate a coverage report', - coveragePath: 'Path to coverage report to generate', - coverageFormats: 'Coverage formats to generate', - help: 'Show help' - } -}); - -if (args.help) { - console.log(`Usage: node test/unit/node/index [options] - -Options: ---build Run from out-build ---run Run a single file ---coverage Generate a coverage report ---help Show help`); - process.exit(0); -} - -const TEST_GLOB = '**/test/**/*.test.js'; - -const excludeGlobs = [ - '**/{browser,electron-sandbox,electron-main,electron-utility}/**/*.test.js', - '**/vs/platform/environment/test/node/nativeModules.test.js', // native modules are compiled against Electron and this test would fail with node.js - '**/vs/base/parts/storage/test/node/storage.test.js', // same as above, due to direct dependency to sqlite native module - '**/vs/workbench/contrib/testing/test/**' // flaky (https://github.com/microsoft/vscode/issues/137853) -]; - -const REPO_ROOT = path.join(__dirname, '../../../'); -const out = args.build ? 'out-build' : 'out'; -const loader = require(`../../../${out}/vs/loader`); -const src = path.join(REPO_ROOT, out); - -//@ts-ignore -const majorRequiredNodeVersion = `v${/^target="(.*)"$/m.exec(fs.readFileSync(path.join(REPO_ROOT, 'remote', '.npmrc'), 'utf8'))[1]}`.substring(0, 3); -const currentMajorNodeVersion = process.version.substring(0, 3); -if (majorRequiredNodeVersion !== currentMajorNodeVersion) { - console.error(`node.js unit tests require a major node.js version of ${majorRequiredNodeVersion} (your version is: ${currentMajorNodeVersion})`); - process.exit(1); -} - -function main() { - - // VSCODE_GLOBALS: package/product.json - globalThis._VSCODE_PRODUCT_JSON = require(`${REPO_ROOT}/product.json`); - globalThis._VSCODE_PACKAGE_JSON = require(`${REPO_ROOT}/package.json`); - - if (args.build) { - // when running from `out-build`, ensure to load the default - // messages file, because all `nls.localize` calls have their - // english values removed and replaced by an index. - globalThis._VSCODE_NLS_MESSAGES = require(`../../../${out}/nls.messages.json`); - } - - // Test file operations that are common across platforms. Used for test infra, namely snapshot tests - Object.assign(globalThis, { - __analyzeSnapshotInTests: takeSnapshotAndCountClasses, - __readFileInTests: (/** @type {string} */ path) => fs.promises.readFile(path, 'utf-8'), - __writeFileInTests: (/** @type {string} */ path, /** @type {BufferEncoding} */ contents) => fs.promises.writeFile(path, contents), - __readDirInTests: (/** @type {string} */ path) => fs.promises.readdir(path), - __unlinkInTests: (/** @type {string} */ path) => fs.promises.unlink(path), - __mkdirPInTests: (/** @type {string} */ path) => fs.promises.mkdir(path, { recursive: true }), - }); - - process.on('uncaughtException', function (e) { - console.error(e.stack || e); - }); - - const bootstrapNode = require(`../../../${out}/bootstrap-node`); - - const loaderConfig = { - nodeRequire: require, - baseUrl: bootstrapNode.fileUriFromPath(src, { isWindows: process.platform === 'win32' }), - catchError: true - }; - - if (args.coverage) { - coverage.initialize(loaderConfig); - - process.on('exit', function (code) { - if (code !== 0) { - return; - } - coverage.createReport(args.run || args.runGlob, args.coveragePath, args.coverageFormats); - }); - } - - loader.config(loaderConfig); - - let didErr = false; - const write = process.stderr.write; - process.stderr.write = function (...args) { - didErr = didErr || !!args[0]; - return write.apply(process.stderr, args); - }; - - - const runner = new Mocha({ - ui: 'tdd' - }); - - /** - * @param {string[]} modules - */ - async function loadModules(modules) { - for (const file of modules) { - runner.suite.emit(Mocha.Suite.constants.EVENT_FILE_PRE_REQUIRE, globalThis, file, runner); - const m = await new Promise((resolve, reject) => loader([file], resolve, reject)); - runner.suite.emit(Mocha.Suite.constants.EVENT_FILE_REQUIRE, m, file, runner); - runner.suite.emit(Mocha.Suite.constants.EVENT_FILE_POST_REQUIRE, globalThis, file, runner); - } - } - - /** @type { null|((callback:(err:any)=>void)=>void) } */ - let loadFunc = null; - - if (args.runGlob) { - loadFunc = (cb) => { - const doRun = /** @param {string[]} tests */(tests) => { - const modulesToLoad = tests.map(test => { - if (path.isAbsolute(test)) { - test = path.relative(src, path.resolve(test)); - } - - return test.replace(/(\.js)|(\.d\.ts)|(\.js\.map)$/, ''); - }); - loadModules(modulesToLoad).then(() => cb(null), cb); - }; - - glob(args.runGlob, { cwd: src }, function (err, files) { doRun(files); }); - }; - } else if (args.run) { - const tests = (typeof args.run === 'string') ? [args.run] : args.run; - const modulesToLoad = tests.map(function (test) { - test = test.replace(/^src/, 'out'); - test = test.replace(/\.ts$/, '.js'); - return path.relative(src, path.resolve(test)).replace(/(\.js)|(\.js\.map)$/, '').replace(/\\/g, '/'); - }); - loadFunc = (cb) => { - loadModules(modulesToLoad).then(() => cb(null), cb); - }; - } else { - loadFunc = (cb) => { - glob(TEST_GLOB, { cwd: src }, function (err, files) { - /** @type {string[]} */ - const modules = []; - for (const file of files) { - if (!excludeGlobs.some(excludeGlob => minimatch(file, excludeGlob))) { - modules.push(file.replace(/\.js$/, '')); - } - } - loadModules(modules).then(() => cb(null), cb); - }); - }; - } - - loadFunc(function (err) { - if (err) { - console.error(err); - return process.exit(1); - } - - process.stderr.write = write; - - if (!args.run && !args.runGlob) { - // set up last test - Mocha.suite('Loader', function () { - test('should not explode while loading', function () { - assert.ok(!didErr, `should not explode while loading: ${didErr}`); - }); - }); - } - - // report failing test for every unexpected error during any of the tests - const unexpectedErrors = []; - Mocha.suite('Errors', function () { - test('should not have unexpected errors in tests', function () { - if (unexpectedErrors.length) { - unexpectedErrors.forEach(function (stack) { - console.error(''); - console.error(stack); - }); - - assert.ok(false); - } - }); - }); - - // replace the default unexpected error handler to be useful during tests - loader(['vs/base/common/errors'], function (errors) { - errors.setUnexpectedErrorHandler(function (err) { - const stack = (err && err.stack) || (new Error().stack); - unexpectedErrors.push((err && err.message ? err.message : err) + '\n' + stack); - }); - - // fire up mocha - runner.run(failures => process.exit(failures ? 1 : 0)); - }); - }); -} - -main();