-
Notifications
You must be signed in to change notification settings - Fork 202
Bundle extension files using esbuild #1483
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
662e05b
Bundle extension files using esbuild
koesie10 fc0d002
Don't bundle test node_modules
koesie10 ccf687a
Merge remote-tracking branch 'origin/main' into koesie10/bundle-files
koesie10 f2c9ef5
Update app insights Gulp task for bundled extension
koesie10 de509b5
Setup testing setup
koesie10 44c37c5
Use separate test setup
koesie10 28bf46d
Merge remote-tracking branch 'origin/main' into koesie10/bundle-files
koesie10 359ef0d
Add back sourcemaps for test build
koesie10 724cc8e
Use correct path for cli-integration test
koesie10 4c22e31
Copy all data- directories for cli-integration tests
koesie10 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
|
||
# Generated files | ||
/dist/ | ||
/dist-test/ | ||
out/ | ||
build/ | ||
server/ | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,38 @@ | ||
import * as gulp from 'gulp'; | ||
import { compileTypeScript, watchTypeScript, cleanOutput } from './typescript'; | ||
import { compileEsbuild, watchEsbuild, cleanOutput, checkTypeScript, watchCheckTypeScript, compileTypeScriptTests, watchTypeScriptTests } from './typescript'; | ||
import { compileTextMateGrammar } from './textmate'; | ||
import { copyTestData } from './tests'; | ||
import { copyTestData, copyTests, watchCopyTests } from './tests'; | ||
import { compileView, watchView } from './webpack'; | ||
import { packageExtension } from './package'; | ||
import { injectAppInsightsKey } from './appInsights'; | ||
|
||
export const buildWithoutPackage = | ||
gulp.series( | ||
cleanOutput, | ||
gulp.parallel( | ||
compileTypeScript, compileTextMateGrammar, compileView, copyTestData | ||
) | ||
gulp.parallel(compileEsbuild, compileTextMateGrammar, compileView, copyTestData, checkTypeScript, compileTypeScriptTests) | ||
); | ||
|
||
export const watch = gulp.parallel( | ||
watchEsbuild, watchTypeScriptTests, watchCheckTypeScript, watchView, watchCopyTests | ||
); | ||
|
||
export const buildTests = gulp.series( | ||
buildWithoutPackage, | ||
copyTests | ||
); | ||
|
||
export { | ||
cleanOutput, | ||
compileTextMateGrammar, | ||
watchTypeScript, | ||
watchEsbuild, | ||
watchView, | ||
compileTypeScript, | ||
compileEsbuild, | ||
copyTestData, | ||
injectAppInsightsKey, | ||
compileView, | ||
checkTypeScript, | ||
watchCheckTypeScript, | ||
compileTypeScriptTests, | ||
watchTypeScriptTests, | ||
}; | ||
export default gulp.series(buildWithoutPackage, injectAppInsightsKey, packageExtension); | ||
export default gulp.series(buildWithoutPackage, injectAppInsightsKey, packageExtension, copyTests); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,9 @@ | ||
import * as gulp from 'gulp'; | ||
import * as path from 'path'; | ||
import del from 'del'; | ||
import { copyTestPackageToDist } from './deploy'; | ||
|
||
const testDistDir = path.join(__dirname, '../../../dist-test'); | ||
|
||
export function copyTestData() { | ||
copyNoWorkspaceData(); | ||
|
@@ -8,10 +13,29 @@ export function copyTestData() { | |
|
||
function copyNoWorkspaceData() { | ||
return gulp.src('src/vscode-tests/no-workspace/data/**/*') | ||
.pipe(gulp.dest('out/vscode-tests/no-workspace/data')); | ||
.pipe(gulp.dest('out/test-run/vscode-tests/no-workspace/data')); | ||
} | ||
|
||
function copyCliIntegrationData() { | ||
return gulp.src('src/vscode-tests/cli-integration/data/**/*') | ||
.pipe(gulp.dest('out/vscode-tests/cli-integration/data')); | ||
return gulp.src('src/vscode-tests/cli-integration/data*/**/*') | ||
.pipe(gulp.dest('out/test-run/vscode-tests/cli-integration')); | ||
} | ||
|
||
function cleanTestsOutput() { | ||
// The path to the test dist dir is outside of the working directory, so we need to force it | ||
return del(testDistDir, { force: true }); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is |
||
} | ||
|
||
async function copyToTests(): Promise<void> { | ||
await copyTestPackageToDist(testDistDir, path.resolve('package.json')); | ||
} | ||
|
||
async function copyTestsWithoutNodeModules(): Promise<void> { | ||
await copyTestPackageToDist(testDistDir, path.resolve('package.json'), false); | ||
} | ||
|
||
export const copyTests = gulp.series(cleanTestsOutput, copyToTests); | ||
|
||
export function watchCopyTests() { | ||
gulp.watch('out/**/*', copyTestsWithoutNodeModules); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
import * as colors from 'ansi-colors'; | ||
import * as gulp from 'gulp'; | ||
import * as sourcemaps from 'gulp-sourcemaps'; | ||
import * as ts from 'gulp-typescript'; | ||
import * as del from 'del'; | ||
import esbuild from 'gulp-esbuild'; | ||
import ts from 'gulp-typescript'; | ||
import sourcemaps from 'gulp-sourcemaps'; | ||
import del from 'del'; | ||
|
||
function goodReporter(): ts.reporter.Reporter { | ||
return { | ||
|
@@ -20,22 +21,57 @@ function goodReporter(): ts.reporter.Reporter { | |
} | ||
|
||
const tsProject = ts.createProject('tsconfig.json'); | ||
const testsTsProject = ts.createProject('tsconfig.json', { | ||
esModuleInterop: false, | ||
}); | ||
|
||
export function cleanOutput() { | ||
return tsProject.projectDirectory ? del(tsProject.projectDirectory + '/out/*') : Promise.resolve(); | ||
} | ||
|
||
export function compileTypeScript() { | ||
return tsProject.src() | ||
export function compileEsbuild() { | ||
return gulp.src('./src/extension.ts') | ||
.pipe(esbuild({ | ||
outfile: 'extension.js', | ||
bundle: true, | ||
external: ['vscode'], | ||
format: 'cjs', | ||
platform: 'node', | ||
target: 'es2020', | ||
sourcemap: 'linked', | ||
})) | ||
.pipe(gulp.dest('out')); | ||
} | ||
|
||
export function compileTypeScriptTests() { | ||
// Unfortunately we cannot use ESBuild for the test compilation because it compiles | ||
// to ES6 modules which have additional restrictions compared to the code generated | ||
// by the TypeScript compiler. | ||
return testsTsProject.src() | ||
.pipe(sourcemaps.init()) | ||
.pipe(tsProject(goodReporter())) | ||
.pipe(testsTsProject(goodReporter())) | ||
.pipe(sourcemaps.write('.', { | ||
includeContent: false, | ||
sourceRoot: '.', | ||
})) | ||
.pipe(gulp.dest('out')); | ||
.pipe(gulp.dest('out/test-run')); | ||
} | ||
|
||
export function watchEsbuild() { | ||
gulp.watch('src/**/*.ts', compileEsbuild); | ||
} | ||
|
||
export function watchTypeScriptTests() { | ||
gulp.watch('src/**/*.ts', compileTypeScriptTests); | ||
} | ||
|
||
export function checkTypeScript() { | ||
// This doesn't actually output the TypeScript files, it just | ||
// runs the TypeScript compiler and reports any errors. | ||
return tsProject.src(); | ||
// .pipe(tsProject(goodReporter())); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. delete? |
||
} | ||
|
||
export function watchTypeScript() { | ||
gulp.watch('src/**/*.ts', compileTypeScript); | ||
export function watchCheckTypeScript() { | ||
gulp.watch('src/**/*.ts', checkTypeScript); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't tested this myself. I would just like to make sure that you have verified that the
APP_INSIGHTS_KEY
env var is injected into theextension.js
file appropriately.