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

Bundling via esbuild. #30

Merged
merged 8 commits into from
Jun 29, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ node_modules
coverage/
.nyc_output/
.DS_Store
extension
7 changes: 6 additions & 1 deletion .vscodeignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
.vscode/**
.vscode-test/**
src/**/*.ts
src/**
.gitignore
.yarnrc
vsc-extension-quickstart.md
**/tsconfig.json
**/.eslintrc.json
**/*.map
**/*.ts
CODEOWNERS
RELEASE.md
coverage/
.nyc_output/
.github
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to do this with folders like out/ and node_modules/ too. There should be a very lightweight, file-count-wise, package at the end of the line, because everything is meant to be bundled into one file.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I remove node_modules, the generated extension does not work. Also, the out is needed because that is where our extension is compiled to, which is our entrypoint. I dont think we can discard these two dirs.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did some more testing just to validate what I recalled from last week ;) :

  • If I remove out/, then the package wont be generated because it complains of a missing entry point (main in package.json defines it as /out/extension.js
  • If I remove node_modules/, then the generated package is only 20k, but fails to launch at runtime because:
2023-06-26 11:19:33.659 [error] Error: Cannot find module '@salesforce/lwc-dev-mobile-core/lib/common/CommonUtils'
Require stack:
- /Users/dbreese/.vscode/extensions/salesforce.salesforcedx-vscode-mobile-0.0.1/out/extension.js
- /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/loader.js
- /Applications/Visual Studio Code.app/Contents/Resources/app/out/bootstrap-amd.js
- /Applications/Visual Studio Code.app/Contents/Resources/app/out/bootstrap-fork.js

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I'm basically fiddling around in my environment, seeing similar things.

There's a gap of documentation about some of the entries in your standard package.json file vs. what esbuild is / might be expecting. For example, I switched locally to have esbuild use an --outfile value of dist/main.js just to see how it went. And while it generates an all-in-one dist/main.js, it still complains at runtime about trying to use out/extension.js, which is the main entry point in package.json.

The dearth of comprehensive documentation is...frustrating. I'm going to keep poking around.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you just change --outfile to out/extension.js it should work though so that it matches package.json's main value?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah but I didn't like that because that's where we compile everything out too, and so you have to do a bunch of filtering to not include a swathe of JS files down there.

Locally, I ended up specifying --outfile as dist/main.js, and made that my main target in package.json too, and that got past that particular hurdle (and onto another one, but that's another story).

25 changes: 25 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Instructions to package this as an extension (*.vsix) file:

1. Install vsce

```
npm install -g @vscode/vsce
```

2. Install dependencies

NOTE: The packaging steps prunes the node_modules tree, so running `npm install` will reinstall dev dependencies.

```
npm install
```

3. Create package

```
vsce package
```

4. Manually install the generated .vsix file and smoke test.

TODO: Eventually we can sign and publish it directly to marketplace.
Loading
Loading