Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extension bundling with ESBuild documentation does not work #136831

Closed
samuela opened this issue Nov 10, 2021 · 2 comments
Closed

Extension bundling with ESBuild documentation does not work #136831

samuela opened this issue Nov 10, 2021 · 2 comments
Assignees

Comments

@samuela
Copy link

samuela commented Nov 10, 2021

Does this issue occur when all extensions are disabled?: Yes

  • VS Code Version: 1.62.1
  • OS Version: macOS 11.6

Steps to Reproduce:

  1. Read the documentation at https://code.visualstudio.com/api/working-with-extensions/bundling-extension#run-esbuild and attempt to follow it.
  2. Run vsce package.
  3. Observe that vsce warns that the package is still not bundled:
❯ vsce package
 INFO  Detected presence of yarn.lock. Using 'yarn' instead of 'npm' (to override this pass '--no-yarn' on the command line).
Executing prepublish script 'yarn run vscode:prepublish'...
yarn run v1.22.17
$ yarn run esbuild-base --minify
$ esbuild ./src/extension.ts --bundle --outfile=out/main.js --external:vscode --format=cjs --platform=node --minify

  out/main.js  815.9kb

✨  Done in 1.51s.
 INFO  Detected presence of yarn.lock. Using 'yarn' instead of 'npm' (to override this pass '--no-yarn' on the command line).
This extension consists of 1046 files, out of which 571 are JavaScript files. For performance reasons, you should bundle your extension: https://aka.ms/vscode-bundle-extension . You should also exclude unnecessary files by adding them to your .vscodeignore: https://aka.ms/vscode-vscodeignore
 DONE  Packaged: /Users/skainswo/dev/cuddlefish/vscode-extension/cuddlefish-comments-0.0.0.vsix (1046 files, 1.63MB)

Following the docs, I have the following in my package.json:

	"scripts": {
		"vscode:prepublish": "yarn run esbuild-base --minify",
		"esbuild-base": "esbuild ./src/extension.ts --bundle --outfile=out/main.js --external:vscode --format=cjs --platform=node",
		"esbuild": "yarn run esbuild-base --sourcemap",
		"esbuild-watch": "yarn run esbuild-base --sourcemap --watch",
		"test-compile": "tsc -p ./",
		"watch": "tsc -watch -p ./",
		"pretest": "yarn run test-compile && yarn run lint",
		"lint": "eslint src --ext ts",
		"test": "node ./out/test/runTest.js",
		"gql:codegen": "graphql-codegen"
	},

A complete reproduction of this issue can be found on this commit in the vscode-extension/ directory. I'm running vsce v2.2.0.

It seems that esbuild is getting run and is working correctly, but for whatever reason the bundled file is not being properly picked up by vsce.

How can I bundle my extension with esbuild?

@samuela
Copy link
Author

samuela commented Nov 12, 2021

Solution turned out to be adding out/ and node_modules/ to .vscodeignore. Docs are just a little confusing in terms of what steps are for webpack and which steps are for esbuild.

@connor4312
Copy link
Member

Thanks for the issue, I added a callout for this: microsoft/vscode-docs@e6ba642

@github-actions github-actions bot locked and limited conversation to collaborators Jan 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants