Skip to content

Commit

Permalink
Move all bundling into vscode-lit-plugin (#249)
Browse files Browse the repository at this point in the history
* Move all bundling into vscode-lit-plugin

This way downstream users of ts-lit-plugin are free to bundle it with their preferred settings.
  • Loading branch information
rictic authored Apr 20, 2022
1 parent 8360bef commit e59b235
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 64 deletions.
14 changes: 0 additions & 14 deletions packages/ts-lit-plugin/esbuild.script.js

This file was deleted.

2 changes: 1 addition & 1 deletion packages/ts-lit-plugin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
// we can't express that in proper ESM, so this hand-written JS
// file bridges the difference.

module.exports = require("./lib/bundle-esbuild").init;
module.exports = require("./lib/index").init;
31 changes: 2 additions & 29 deletions packages/ts-lit-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,6 @@
},
"wireit": {
"build": {
"dependencies": [
"compile",
"bundle-esbuild"
]
},
"test": {
"dependencies": [
"build"
]
},
"compile": {
"dependencies": [
"../lit-analyzer:build"
],
Expand All @@ -56,26 +45,10 @@
],
"clean": "if-file-deleted"
},
"bundle-esbuild": {
"test": {
"dependencies": [
"../lit-analyzer:build"
],
"command": "node esbuild.script.js",
"files": [
"src/**/*",
"esbuild.script.js"
],
"output": [
"lib/bundle-esbuild.js"
"build"
]
},
"report-bundle-size": {
"dependencies": [
"bundle-esbuild"
],
"files": [],
"output": [],
"command": "ls -a -l -h -S lib/bundle-esbuild.js"
}
},
"main": "index.js",
Expand Down
3 changes: 1 addition & 2 deletions packages/vscode-lit-plugin/copy-to-built.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,13 @@ async function main() {

// For the TS compiler plugin, it must be in node modules because that's
// hard coded by the TS compiler's custom module resolution logic.
await mkdirp("./built/node_modules/ts-lit-plugin/lib");
await mkdirp("./built/node_modules/ts-lit-plugin");
const tsPluginPackageJson = require("../ts-lit-plugin/package.json");
// We're only using the bundled version, so the plugin doesn't need any
// dependencies.
tsPluginPackageJson.dependencies = {};
await writeFile("./built/node_modules/ts-lit-plugin/package.json", JSON.stringify(tsPluginPackageJson, null, 2));
await copy("../ts-lit-plugin/index.js", "./built/node_modules/ts-lit-plugin/index.js");
await copy("../ts-lit-plugin/lib/bundle-esbuild.js", "./built/node_modules/ts-lit-plugin/lib/bundle-esbuild.js");

const pluginPackageJson = require("./package.json");
// vsce is _very_ picky about the directories in node_modules matching the
Expand Down
14 changes: 0 additions & 14 deletions packages/vscode-lit-plugin/esbuild.script.js

This file was deleted.

27 changes: 27 additions & 0 deletions packages/vscode-lit-plugin/esbuild.script.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import * as esbuild from "esbuild";

await esbuild.build({
entryPoints: ["src/extension.ts"],
bundle: true,
outfile: "built/bundle.js",
platform: "node",
minify: true,
target: "es2017",
format: "cjs",
color: true,
external: ["vscode", "typescript"],
mainFields: ["module", "main"]
});

await esbuild.build({
entryPoints: ["../ts-lit-plugin/src/index.ts"],
bundle: true,
outfile: "built/node_modules/ts-lit-plugin/lib/index.js",
platform: "node",
external: ["typescript"],
minify: true,
target: "es2017",
format: "cjs",
color: true,
mainFields: ["module", "main"]
});
13 changes: 9 additions & 4 deletions packages/vscode-lit-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,16 @@
"dependencies": [
"../lit-analyzer:build"
],
"command": "node esbuild.script.js",
"command": "node esbuild.script.mjs",
"files": [
"src/**/*",
"esbuild.script.js"
"../ts-lit-plugin/src/**/*",
"../ts-lit-plugin/index.js",
"esbuild.script.mjs"
],
"output": [
"built/bundle.js"
"built/bundle.js",
"built/node_modules/ts-lit-plugin/index.js"
]
},
"make-built-dir": {
Expand All @@ -148,7 +151,9 @@
],
"output": [
"built/docs",
"built/node_modules",
"built/node_modules/typescript",
"built/node_modules/ts-lit-plugin/package.json",
"built/node_modules/ts-lit-plugin/index.js",
"built/schemas",
"built/syntaxes",
"built/LICENSE.md",
Expand Down

0 comments on commit e59b235

Please sign in to comment.