Skip to content

Bundle extension using esbuild#335

Open
TwitchBronBron wants to merge 18 commits into
masterfrom
esbuild
Open

Bundle extension using esbuild#335
TwitchBronBron wants to merge 18 commits into
masterfrom
esbuild

Conversation

@TwitchBronBron

@TwitchBronBron TwitchBronBron commented Nov 5, 2021

Copy link
Copy Markdown
Member

This uses esbuild to bundle the application.

  • esbuild is extremely fast. The entire build takes like ~200ms.
  • bundling tree shakes all unused modules so we get a super small build

Here are some rough metrics of how this improves the process:

  • original vsix: 18.6MB
  • esbuild vsix: 1.5MB

This replaces #200 because webpack is too slow. :P

Outstanding issues:

  • fix language server not working
  • figure out npm symlinked debugging workflows for language server and debugger
  • lots of testing to verify everything still works
  • figure out how to properly test this flow since the unit tests don't use the esbuild version

@TwitchBronBron TwitchBronBron added the create-vsix PRs with this tag will trigger a vsix build on vscode-brightscript-language for every push label Nov 5, 2021
@rokucommunity-bot

Copy link
Copy Markdown
Contributor

Hey there! I just built a new version of the vscode extension based on 63cca47. You can downloaded the .vsix here and then follow these installation instructions.

@rokucommunity-bot

Copy link
Copy Markdown
Contributor

Hey there! I just built a new version of the vscode extension based on 3e0cc58. You can downloaded the .vsix here and then follow these installation instructions.

@rokucommunity-bot

Copy link
Copy Markdown
Contributor

Hey there! I just built a new version of the vscode extension based on acedc1b. You can downloaded the .vsix here and then follow these installation instructions.

@rokucommunity-bot

Copy link
Copy Markdown
Contributor

Hey there! I just built a new version of the vscode extension based on f12d5cf. You can downloaded the .vsix here and then follow these installation instructions.

@rokucommunity-bot

Copy link
Copy Markdown
Contributor

Hey there! I just built a new version of the vscode extension based on 31752ae. You can downloaded the .vsix here and then follow these installation instructions.

chrisdp and others added 6 commits April 16, 2026 16:32
- Remove unused `cwd` variable in LanguageServerManager.spec.ts
- Remove unused `glob` import in autoIndent.spec.ts (already staged in merge commit)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ded version

When dist/brighterscript.js exists (packaged or post-build), use it as the embedded
packageDir instead of the node_modules path. This means the packaged extension doesn't
need to ship node_modules/brighterscript.

- esbuild injects BSC_EMBEDDED_VERSION at build time so the version string is always
  available even when require.resolve('brighterscript') isn't callable
- Constructor wraps require.resolve in try/catch for safety in the bundled context
- init() overrides embeddedBscInfo.packageDir to the bundled path when present
- User-selected versions still go through localPackageManager as before

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace `import * as X from 'X'` with `import X = require('X')` for
dayjs, md5, minimatch, get-port, and jszip. All five use `export =` in
their type declarations, making this the correct TypeScript idiom. It
compiles to a plain require() call, which esbuild handles as a direct
module reference rather than a namespace object, eliminating all 7
call-import-namespace warnings without needing esModuleInterop.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Three issues prevented the bundled LSP from starting:

1. dayjs.extend(relativeTime) crashed because `import * as relativeTime`
   produces a namespace object that dayjs tries to call as a function.
   Changed to `import relativeTime = require(...)`.

2. roku-test-automation uses __dirname-relative paths to locate its
   JSON schema files; bundling broke __dirname resolution. Marked it
   external so Node's module resolution handles it at runtime.

3. brighterscript spawns a worker thread from `${__dirname}/run.js`.
   Added a `run` entry point so the worker script ends up at
   `dist/run.js` next to the bundled brighterscript.js.

4. `ensureBscVersionInstalled` treated the bundled .js path as a
   directory and looked for package.json inside it. Short-circuit the
   lookup when versionInfo matches the embedded packageDir.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Bundle roku-test-automation into dist/ via a plugin that rewrites its
three __dirname-based paths to dist/rta/..., and copy the schema files
and on-device component bundle there post-build. This lets .vscodeignore
exclude all of node_modules/, dropping the vsix from 18.6 MB to 3.99 MB.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@rokucommunity-bot

Copy link
Copy Markdown
Contributor

Hey there! I just built a new version of the vscode extension based on cecb51d. You can downloaded the .vsix here and then follow these installation instructions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

create-vsix PRs with this tag will trigger a vsix build on vscode-brightscript-language for every push

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants