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

Support scaffdog@v3 #27

Merged
merged 2 commits into from
Jul 30, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
10 changes: 10 additions & 0 deletions .changeset/metal-insects-thank.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
'scaffdog-vscode': minor
---

Support for scaffdog v3 has been added.

scaffdog v3 is migrating to Native ESM. This version includes changes for both ESM and CommonJS.
Please feel free to update to work with both v2 and v3.

ref: https://github.com/prettier/prettier-vscode/pull/3016
5 changes: 5 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": ["dbaeumer.vscode-eslint", "amodio.tsl-problem-matcher"]
}
31 changes: 31 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// A launch configuration that compiles the extension and then opens it inside a new window
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
{
"version": "0.2.0",
"configurations": [
{
"name": "Run Extension",
"type": "extensionHost",
"request": "launch",
"args": ["--extensionDevelopmentPath=${workspaceFolder}"],
"outFiles": ["${workspaceFolder}/dist/**/*.js"],
"preLaunchTask": "${defaultBuildTask}"
},
{
"name": "Extension Tests",
"type": "extensionHost",
"request": "launch",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/out/test/suite/index"
],
"outFiles": [
"${workspaceFolder}/out/**/*.js",
"${workspaceFolder}/dist/**/*.js"
],
"preLaunchTask": "tasks: watch-tests"
}
]
}
13 changes: 13 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Place your settings in this file to overwrite default and user settings.
{
"files.exclude": {
"out": false, // set this to true to hide the "out" folder with the compiled JS files
"dist": false // set this to true to hide the "dist" folder with the compiled JS files
},
"search.exclude": {
"out": true, // set this to false to include "out" folder in search results
"dist": true // set this to false to include "dist" folder in search results
},
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
"typescript.tsc.autoDetect": "off"
}
37 changes: 37 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
{
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "watch",
"problemMatcher": "$esbuild-watch",
"isBackground": true,
"presentation": {
"reveal": "never",
"group": "watchers"
},
"group": {
"kind": "build",
"isDefault": true
}
},
{
"type": "npm",
"script": "watch-tests",
"problemMatcher": "$tsc-watch",
"isBackground": true,
"presentation": {
"reveal": "never",
"group": "watchers"
},
"group": "build"
},
{
"label": "tasks: watch-tests",
"dependsOn": ["npm: watch", "npm: watch-tests"],
"problemMatcher": []
}
]
}
56 changes: 56 additions & 0 deletions build.worker.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import * as esbuild from 'esbuild';

const argv = new Set(process.argv.slice(2));

const identifier = (length = 9) =>
`i${Math.random().toString(36).substring(2, length)}`;

const createRequireAlias = identifier();

/**
* @type {import('esbuild').BuildOptions}
*/
const options = {
entryPoints: ['./src/worker/index.ts'],
outfile: './dist/worker.mjs',
format: 'esm',
platform: 'node',
bundle: true,
sourcemap: true,
minify: argv.has('--minify'),
banner: {
js: `
import { createRequire as ${createRequireAlias} } from 'module';
const require = ${createRequireAlias}(import.meta.url);
`,
},
};

if (argv.has('--watch')) {
const ctx = await esbuild.context({
...options,
plugins: [
{
name: 'rebuild',
setup(build) {
build.onEnd((result) => {
console.log('[watch] build started');
if (result.errors.length > 0) {
result.errors.forEach((error) =>
console.error(
`> ${error.location.file}:${error.location.line}:${error.location.column}: error: ${error.text}`,
),
);
} else {
console.log('[watch] build finished, watching for changes...');
}
});
},
},
],
});

await ctx.watch();
} else {
await esbuild.build(options);
}
46 changes: 26 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,19 @@
"publisher": "scaffdog",
"main": "./dist/extension.js",
"scripts": {
"vscode:prepublish": "pnpm build:base --minify",
"watch": "webpack --watch",
"vscode:prepublish": "pnpm prod",
"watch": "run-p watch:*",
"watch:main": "pnpm build:main --watch",
"watch:worker": "pnpm build:worker --watch",
"clean": "rimraf dist",
"package": "vsce package --no-dependencies",
"typecheck": "tsc",
"build": "pnpm build:base --sourcemap",
"build:base": "esbuild ./src/extension.ts --bundle --outfile=dist/extension.js --external:vscode --format=cjs --platform=node",
"build:watch": "pnpm build:base --sourcemap --watch",
"build": "run-p build:*",
"build:main": "esbuild ./src/main/index.ts --bundle --sourcemap --outfile=dist/extension.js --external:vscode --format=cjs --platform=node",
"build:worker": "node build.worker.mjs",
"prod": "run-p prod:*",
"prod:main": "pnpm build:main --minify",
"prod:worker": "pnpm build:worker --minify",
"lint": "run-s lint:*",
"lint:prettier": "prettier --check .",
"lint:script": "eslint src --ext ts",
Expand Down Expand Up @@ -122,40 +128,40 @@
"trailingComma": "all"
},
"dependencies": {
"@scaffdog/engine": "2.5.0",
"@scaffdog/engine": "3.0.0-canary.1",
"find-up": "^6.3.0",
"globby": "^13.1.3",
"plur": "^5.1.0",
"resolve": "^1.22.1",
"scaffdog": "2.5.0",
"semver": "^7.3.8"
"resolve": "^1.22.2",
"scaffdog": "3.0.0-canary.1",
"semver": "^7.5.4",
"zod": "^3.21.4"
},
"devDependencies": {
"@changesets/changelog-github": "0.4.8",
"@changesets/cli": "2.26.0",
"@changesets/cli": "2.26.2",
"@types/glob": "8.1.0",
"@types/mocha": "10.0.1",
"@types/node": "18.14.1",
"@types/resolve": "1.20.2",
"@types/semver": "7.3.13",
"@types/semver": "7.5.0",
"@types/vscode": "1.60.0",
"@typescript-eslint/eslint-plugin": "5.53.0",
"@typescript-eslint/parser": "5.53.0",
"@vscode/test-electron": "2.2.3",
"@vscode/vsce": "2.18.0",
"esbuild": "0.17.10",
"eslint": "8.34.0",
"@vscode/test-electron": "2.3.3",
"@vscode/vsce": "2.19.0",
"esbuild": "0.18.15",
"eslint": "8.45.0",
"glob": "8.1.0",
"husky": "8.0.3",
"lint-staged": "13.1.2",
"lint-staged": "13.2.3",
"mocha": "10.2.0",
"npm-run-all": "4.1.5",
"prettier": "2.8.4",
"prettier-plugin-packagejson": "2.4.3",
"prettier-plugin-packagejson": "2.4.5",
"rimraf": "^5.0.1",
"ts-loader": "9.4.2",
"typescript": "4.9.5",
"webpack": "5.75.0",
"webpack-cli": "5.0.1"
"typescript": "5.1.6"
},
"packageManager": "pnpm@7.28.0",
"engines": {
Expand Down
Loading