@tomjs/vite-plugin-vscode 4.0.0 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -13,11 +13,16 @@ In development mode, inject the same code of [@tomjs/vscode-extension-webview](h
13
13
  - Use [tsup](https://github.com/egoist/tsup) to quickly build `extension code`
14
14
  - Simple configuration, focus on business
15
15
  - Support `esm` and `cjs`
16
+ - Support ESM extension (vscode `v1.100.0+`)
16
17
  - Support webview `HMR`
17
18
  - Support `acquireVsCodeApi` of [@types/vscode-webview](https://www.npmjs.com/package/@types/vscode-webview)
18
19
  - Support [Multi-Page App](https://vitejs.dev/guide/build.html#multi-page-app)
19
20
  - Supports `vue` and `react` and other [frameworks](https://cn.vitejs.dev/guide/#trying-vite-online) supported by `vite`
20
21
 
22
+ ### ESM extension
23
+
24
+ The NodeJS extension host now (`v1.100.0+`) supports extensions that use JavaScript-modules (ESM). All it needs is the `"type": "module"` entry in your extension's `package.json` file. With that, the JavaScript code can use `import` and `export` statements, including the special module `import('vscode')`.
25
+
21
26
  ## Install
22
27
 
23
28
  ```bash
@@ -427,6 +432,7 @@ Open the [examples](./examples) directory, there are `vue` and `react` examples.
427
432
 
428
433
  - [react](./examples/react): Simple react example.
429
434
  - [vue](./examples/vue): Simple vue example.
435
+ - [vue-esm](./examples/vue-esm): Simple vue (ESM Extension) example.
430
436
  - [vue-import](./examples/vue-import): Dynamic import() and multi-page examples.
431
437
 
432
438
  ## Related
package/README.zh_CN.md CHANGED
@@ -13,11 +13,16 @@
13
13
  - 使用 [tsup](https://github.com/egoist/tsup) 快速构建 `扩展代码`
14
14
  - 配置简单,专注业务
15
15
  - 支持 `esm`和 `cjs`
16
+ - 支持 ESM 扩展(vscode `v1.100.0+`)
16
17
  - 支持 webview `HMR`
17
18
  - 支持 [@types/vscode-webview](https://www.npmjs.com/package/@types/vscode-webview) 的 `acquireVsCodeApi`
18
19
  - 支持[多页面应用](https://cn.vitejs.dev/guide/build.html#multi-page-app)
19
20
  - 支持 `vue` 、`react` 等其他 `vite` 支持的[框架](https://cn.vitejs.dev/guide/#trying-vite-online)
20
21
 
22
+ ### ESM 扩展
23
+
24
+ NodeJS 扩展现在(`v1.100.0+`)支持使用 JavaScript 模块 (ESM) 的扩展。它只需要在扩展的 `package.json` 文件中添加 `"type": "module"` 条目即可。这样,JavaScript 代码就可以使用 `import` 和 `export` 语句,包括特殊的模块 `import('vscode')`
25
+
21
26
  ## 安装
22
27
 
23
28
  ```bash
@@ -431,6 +436,7 @@ pnpm build
431
436
 
432
437
  - [react](./examples/react):简单的 react 示例。
433
438
  - [vue](./examples/vue):简单的 vue 示例。
439
+ - [vue-esm](./examples/vue-esm):简单的 vue(ESM 扩展)示例。
434
440
  - [vue-import](./examples/vue-import):动态 import() 和多页面示例。
435
441
 
436
442
  ## 关联
package/dist/index.js CHANGED
@@ -97,6 +97,7 @@ function getPkg() {
97
97
  }
98
98
  function preMergeOptions(options) {
99
99
  const pkg = getPkg();
100
+ const format = pkg.type === "module" ? "esm" : "cjs";
100
101
  const opts = _lodashmerge2.default.call(void 0,
101
102
  {
102
103
  webview: true,
@@ -105,8 +106,8 @@ function preMergeOptions(options) {
105
106
  extension: {
106
107
  entry: "extension/index.ts",
107
108
  outDir: "dist-extension",
108
- target: ["es2019", "node14"],
109
- format: "cjs",
109
+ target: format === "esm" ? ["node18"] : ["es2019", "node14"],
110
+ format,
110
111
  shims: true,
111
112
  clean: true,
112
113
  dts: false,
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- // node_modules/.pnpm/tsup@7.2.0_@swc+core@1.7.26_postcss@8.4.49_typescript@5.3.3/node_modules/tsup/assets/esm_shims.js
1
+ // node_modules/.pnpm/tsup@7.2.0_@swc+core@1.11.24_postcss@8.4.49_typescript@5.3.3/node_modules/tsup/assets/esm_shims.js
2
2
  import { fileURLToPath } from "url";
3
3
  import path from "path";
4
4
  var getFilename = () => fileURLToPath(import.meta.url);
@@ -104,6 +104,7 @@ function getPkg() {
104
104
  }
105
105
  function preMergeOptions(options) {
106
106
  const pkg = getPkg();
107
+ const format = pkg.type === "module" ? "esm" : "cjs";
107
108
  const opts = merge(
108
109
  {
109
110
  webview: true,
@@ -112,8 +113,8 @@ function preMergeOptions(options) {
112
113
  extension: {
113
114
  entry: "extension/index.ts",
114
115
  outDir: "dist-extension",
115
- target: ["es2019", "node14"],
116
- format: "cjs",
116
+ target: format === "esm" ? ["node18"] : ["es2019", "node14"],
117
+ format,
117
118
  shims: true,
118
119
  clean: true,
119
120
  dts: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tomjs/vite-plugin-vscode",
3
- "version": "4.0.0",
3
+ "version": "4.1.0",
4
4
  "description": "Use vue/react to develop 'vscode extension webview', supporting esm/cjs",
5
5
  "keywords": [
6
6
  "vite",
@@ -68,7 +68,7 @@
68
68
  "@types/lodash.clonedeep": "^4.5.9",
69
69
  "@types/lodash.merge": "^4.6.9",
70
70
  "@types/node": "18.19.67",
71
- "@vitejs/plugin-vue": "^5.1.4",
71
+ "@vitejs/plugin-vue": "^5.2.4",
72
72
  "cross-env": "^7.0.3",
73
73
  "eslint": "^9.16.0",
74
74
  "globals": "^15.13.0",
@@ -80,7 +80,7 @@
80
80
  "stylelint": "^16.11.0",
81
81
  "tsx": "^4.19.2",
82
82
  "typescript": "~5.3.3",
83
- "vite": "^5.4.11",
83
+ "vite": "^6.3.5",
84
84
  "vue-tsc": "^2.1.10"
85
85
  },
86
86
  "peerDependencies": {