Skip to content

Commit

Permalink
Make extension packaging work (#8730)
Browse files Browse the repository at this point in the history
  • Loading branch information
mischnic authored Jan 6, 2023
1 parent c97cf38 commit e21af59
Show file tree
Hide file tree
Showing 12 changed files with 353 additions and 1,590 deletions.
3 changes: 3 additions & 0 deletions packages/examples/simple/.parcelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "@parcel/config-default"
}
6 changes: 1 addition & 5 deletions packages/utils/parcel-lsp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,10 @@
"vscode-languageserver-textdocument": "^1.0.0"
},
"devDependencies": {
"@types/glob": "^7.1.3",
"@types/mocha": "^8.0.4",
"@types/node": "^12.11.7",
"@types/vscode": "^1.67.0",
"@types/node": "^15.12.4",
"@typescript-eslint/eslint-plugin": "^4.14.1",
"@typescript-eslint/parser": "^4.14.1",
"eslint": "^7.19.0",
"glob": "^7.1.6",
"typescript": ">=3.0.0"
}
}
1 change: 1 addition & 0 deletions packages/utils/parcelforvscode/.vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ vsc-extension-quickstart.md
**/.eslintrc.json
**/*.map
**/*.ts
.parcel-cache/
21 changes: 21 additions & 0 deletions packages/utils/parcelforvscode/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2017-present Devon Govett

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
14 changes: 6 additions & 8 deletions packages/utils/parcelforvscode/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
# parcelforvscode README
# Parcel

## How to run the extension locally
This extension shows errors, warnings and other diagnostics inline in VS Code.

- Run `yarn watch` in the `parcel-lsp` dir
- Run Parcel in a project with --reporter @parcel/reporter-lsp
- Press F5 in VS Code from the `parcelforvscode` dir
- A debug window should open up
- Progress build phase reports should show up at the bottom
- Diagnostics should show up in the `Problems` tab
## Usage

1. Install this extension
2. In your project, install `@parcel/reporter-lsp` and run Parcel with that reporter, e.g. `parcel src/index.html --reporter @parcel/reporter-lsp`.
Binary file added packages/utils/parcelforvscode/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
52 changes: 45 additions & 7 deletions packages/utils/parcelforvscode/package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
{
"name": "parcelforvscode",
"name": "parcel-for-vscode",
"version": "2.8.2",
"license": "MIT",
"publisher": "parcel",
"icon": "logo.png",
"displayName": "Parcel for VS Code",
"parcel-lsp.trace.server": "verbose",
"description": "",
"version": "2.8.2",
"private": true,
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/parcel"
},
"repository": {
"type": "git",
"url": "https://github.com/parcel-bundler/parcel.git",
"directory": "packages/utils/parcelforvscode"
},
"engines": {
"vscode": "^1.46.0"
"vscode": "^1.67.0"
},
"categories": [
"Other"
Expand All @@ -15,28 +27,54 @@
"onStartupFinished"
],
"main": "./out/extension.js",
"server": "./out/server.js",
"targets": {
"main": {
"source": "src/extension.ts",
"outputFormat": "commonjs",
"isLibrary": false,
"optimize": false,
"includeNodeModules": {
"vscode": false
},
"context": "node"
},
"server": {
"source": "src/server.ts",
"outputFormat": "commonjs",
"isLibrary": false,
"optimize": false,
"includeNodeModules": {
"@parcel/watcher": false
},
"context": "node"
}
},
"scripts": {
"vscode:prepublish": "yarn run compile",
"vscode:prepublish": "rm -rf out; parcel build --no-cache",
"package": "vsce package --yarn",
"compile": "tsc -p ./",
"watch": "tsc -watch -p ./",
"pretest": "yarn run compile && yarn run lint",
"lint": "eslint src --ext ts"
},
"devDependencies": {
"@parcel/lsp": "2.8.2",
"@types/glob": "^7.1.3",
"@types/mocha": "^8.0.4",
"@types/node": "^12.11.7",
"@types/node": "^15.12.4",
"@types/vscode": "^1.67.0",
"@typescript-eslint/eslint-plugin": "^4.14.1",
"@typescript-eslint/parser": "^4.14.1",
"eslint": "^7.19.0",
"glob": "^7.1.6",
"mocha": "^8.2.1",
"typescript": ">=3.0.0",
"vsce-yarn-patch": "^1.66.2",
"vscode-languageclient": "^8.0.2",
"vscode-test": "^1.5.0"
},
"dependencies": {
"@parcel/lsp": "2.8.2",
"vscode-languageclient": "^8.0.2"
"@parcel/watcher": "^2.0.7"
}
}
6 changes: 3 additions & 3 deletions packages/utils/parcelforvscode/src/extension.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as path from 'path';
import {workspace, ExtensionContext} from 'vscode';
import type {ExtensionContext} from 'vscode';

import * as path from 'path';
import {
LanguageClient,
LanguageClientOptions,
Expand All @@ -12,7 +12,7 @@ let client: LanguageClient;

export function activate(context: ExtensionContext) {
// The server is implemented in node
let serverModule = require.resolve('@parcel/lsp');
let serverModule = path.join(context.extensionPath, 'out', 'server.js');
// The debug options for the server
// --inspect=6009: runs the server in Node's Inspector mode so VS Code can attach to the server for debugging
let debugOptions = {execArgv: ['--nolazy', '--inspect=6009']};
Expand Down
1 change: 1 addition & 0 deletions packages/utils/parcelforvscode/src/server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import '@parcel/lsp';
11 changes: 1 addition & 10 deletions packages/utils/parcelforvscode/vsc-extension-quickstart.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,11 @@
# Welcome to your VS Code Extension

## What's in the folder

- This folder contains all of the files necessary for your extension.
- `package.json` - this is the manifest file in which you declare your extension and command.
- The sample plugin registers a command and defines its title and command name. With this information VS Code can show the command in the command palette. It doesn’t yet need to load the plugin.
- `src/extension.ts` - this is the main file where you will provide the implementation of your command.
- The file exports one function, `activate`, which is called the very first time your extension is activated (in this case by executing the command). Inside the `activate` function we call `registerCommand`.
- We pass the function containing the implementation of the command as the second parameter to `registerCommand`.

## Get up and running straight away

- Press `F5` to open a new window with your extension loaded.
- Run your command from the command palette by pressing (`Ctrl+Shift+P` or `Cmd+Shift+P` on Mac) and typing `Hello World`.
- Set breakpoints in your code inside `src/extension.ts` to debug your extension.
- Find output from your extension in the debug console.
- Run Parcel in a project with `--reporter @parcel/reporter-lsp`

## Make changes

Expand Down
Loading

0 comments on commit e21af59

Please sign in to comment.