@multiplatform.one/vite-plugin-vscode 10.0.0 → 10.1.1
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/lib/index.cjs +35 -16
- package/lib/index.mjs +36 -17
- package/package.json +2 -2
- package/src/index.ts +38 -15
- package/types/index.d.ts.map +1 -1
package/lib/index.cjs
CHANGED
|
@@ -64,6 +64,35 @@ function resolveSeamOneAdapter(workspaceRoot) {
|
|
|
64
64
|
if (node_fs.default.existsSync(source)) return source;
|
|
65
65
|
return "@multiplatform.one/router/seam";
|
|
66
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* Points every "react", "react-dom" and jsx-runtime import in the webview
|
|
69
|
+
* bundle at the workspace copy. Without it, transitive imports from `one`
|
|
70
|
+
* resolve to its vendored React 18 (one/vendor/react/...), whose internals
|
|
71
|
+
* (ReactCurrentOwner) React 19 removed, and the webview crashes at first
|
|
72
|
+
* render.
|
|
73
|
+
*
|
|
74
|
+
* Client environment only. As a `resolve.alias` this also reached Tamagui 3's
|
|
75
|
+
* evaluation environment, which runs in Node: an absolute path is not a bare
|
|
76
|
+
* package, so the module runner inlined React's CommonJS entry and threw
|
|
77
|
+
* "module is not defined" (FZ-11747).
|
|
78
|
+
*/
|
|
79
|
+
function workspaceReactPlugin(workspaceRoot) {
|
|
80
|
+
const targets = {
|
|
81
|
+
react: node_path.default.join(workspaceRoot, "node_modules/react"),
|
|
82
|
+
"react-dom": node_path.default.join(workspaceRoot, "node_modules/react-dom"),
|
|
83
|
+
"react/jsx-runtime": node_path.default.join(workspaceRoot, "node_modules/react/jsx-runtime.js"),
|
|
84
|
+
"react/jsx-dev-runtime": node_path.default.join(workspaceRoot, "node_modules/react/jsx-dev-runtime.js")
|
|
85
|
+
};
|
|
86
|
+
return {
|
|
87
|
+
name: "vscode-workspace-react",
|
|
88
|
+
enforce: "pre",
|
|
89
|
+
applyToEnvironment: (environment) => environment.name === "client",
|
|
90
|
+
resolveId(id, importer) {
|
|
91
|
+
const target = targets[id];
|
|
92
|
+
return target ? this.resolve(target, importer, { skipSelf: true }) : null;
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
}
|
|
67
96
|
async function createVscodeConfig(options) {
|
|
68
97
|
const workspaceRoot = options.workspaceRoot ?? (0, _multiplatform_one_utils_dev.lookupProjectRoot)();
|
|
69
98
|
const isDev = options.isDev ?? process.env.NODE_ENV !== "production";
|
|
@@ -88,7 +117,9 @@ async function createVscodeConfig(options) {
|
|
|
88
117
|
},
|
|
89
118
|
plugins: [
|
|
90
119
|
(0, _multiplatform_one_utils_dev.stubExpoTypeDeclarations)(),
|
|
120
|
+
(0, _multiplatform_one_utils_dev.nativeOnlyDepStubPlugin)(workspaceRoot),
|
|
91
121
|
(0, _multiplatform_one_utils_dev.oneServerOnlyBrowserStub)(workspaceRoot),
|
|
122
|
+
workspaceReactPlugin(workspaceRoot),
|
|
92
123
|
(0, _vitejs_plugin_react.default)({ jsxRuntime: "automatic" }),
|
|
93
124
|
(0, _rolldown_plugin_babel.default)({ presets: [(0, _vitejs_plugin_react.reactCompilerPreset)()] }),
|
|
94
125
|
tamaguiPlugin({
|
|
@@ -116,26 +147,14 @@ async function createVscodeConfig(options) {
|
|
|
116
147
|
find: "@",
|
|
117
148
|
replacement: node_path.default.join(options.targetDir, "webview")
|
|
118
149
|
},
|
|
150
|
+
...Object.entries((0, _multiplatform_one_utils_dev.movedDepAliases)(workspaceRoot)).map(([find, replacement]) => ({
|
|
151
|
+
find,
|
|
152
|
+
replacement
|
|
153
|
+
})),
|
|
119
154
|
{
|
|
120
155
|
find: "react-native",
|
|
121
156
|
replacement: "react-native-web"
|
|
122
157
|
},
|
|
123
|
-
{
|
|
124
|
-
find: /^react$/,
|
|
125
|
-
replacement: node_path.default.join(workspaceRoot, "node_modules/react")
|
|
126
|
-
},
|
|
127
|
-
{
|
|
128
|
-
find: /^react-dom$/,
|
|
129
|
-
replacement: node_path.default.join(workspaceRoot, "node_modules/react-dom")
|
|
130
|
-
},
|
|
131
|
-
{
|
|
132
|
-
find: "react/jsx-runtime",
|
|
133
|
-
replacement: node_path.default.join(workspaceRoot, "node_modules/react/jsx-runtime.js")
|
|
134
|
-
},
|
|
135
|
-
{
|
|
136
|
-
find: "react/jsx-dev-runtime",
|
|
137
|
-
replacement: node_path.default.join(workspaceRoot, "node_modules/react/jsx-dev-runtime.js")
|
|
138
|
-
},
|
|
139
158
|
...options.aliases ?? []
|
|
140
159
|
],
|
|
141
160
|
dedupe: ["react", "react-dom"],
|
package/lib/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import { lookupProjectRoot, lookupTamaguiModules, oneServerOnlyBrowserStub, stubExpoTypeDeclarations, workspaceSourceAliases } from "@multiplatform.one/utils/dev";
|
|
3
|
+
import { lookupProjectRoot, lookupTamaguiModules, movedDepAliases, nativeOnlyDepStubPlugin, oneServerOnlyBrowserStub, stubExpoTypeDeclarations, workspaceSourceAliases } from "@multiplatform.one/utils/dev";
|
|
4
4
|
import babel from "@rolldown/plugin-babel";
|
|
5
5
|
import vscode from "@tomjs/vite-plugin-vscode";
|
|
6
6
|
import react, { reactCompilerPreset } from "@vitejs/plugin-react";
|
|
@@ -31,6 +31,35 @@ function resolveSeamOneAdapter(workspaceRoot) {
|
|
|
31
31
|
if (fs.existsSync(source)) return source;
|
|
32
32
|
return "@multiplatform.one/router/seam";
|
|
33
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Points every "react", "react-dom" and jsx-runtime import in the webview
|
|
36
|
+
* bundle at the workspace copy. Without it, transitive imports from `one`
|
|
37
|
+
* resolve to its vendored React 18 (one/vendor/react/...), whose internals
|
|
38
|
+
* (ReactCurrentOwner) React 19 removed, and the webview crashes at first
|
|
39
|
+
* render.
|
|
40
|
+
*
|
|
41
|
+
* Client environment only. As a `resolve.alias` this also reached Tamagui 3's
|
|
42
|
+
* evaluation environment, which runs in Node: an absolute path is not a bare
|
|
43
|
+
* package, so the module runner inlined React's CommonJS entry and threw
|
|
44
|
+
* "module is not defined" (FZ-11747).
|
|
45
|
+
*/
|
|
46
|
+
function workspaceReactPlugin(workspaceRoot) {
|
|
47
|
+
const targets = {
|
|
48
|
+
react: path.join(workspaceRoot, "node_modules/react"),
|
|
49
|
+
"react-dom": path.join(workspaceRoot, "node_modules/react-dom"),
|
|
50
|
+
"react/jsx-runtime": path.join(workspaceRoot, "node_modules/react/jsx-runtime.js"),
|
|
51
|
+
"react/jsx-dev-runtime": path.join(workspaceRoot, "node_modules/react/jsx-dev-runtime.js")
|
|
52
|
+
};
|
|
53
|
+
return {
|
|
54
|
+
name: "vscode-workspace-react",
|
|
55
|
+
enforce: "pre",
|
|
56
|
+
applyToEnvironment: (environment) => environment.name === "client",
|
|
57
|
+
resolveId(id, importer) {
|
|
58
|
+
const target = targets[id];
|
|
59
|
+
return target ? this.resolve(target, importer, { skipSelf: true }) : null;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
}
|
|
34
63
|
async function createVscodeConfig(options) {
|
|
35
64
|
const workspaceRoot = options.workspaceRoot ?? lookupProjectRoot();
|
|
36
65
|
const isDev = options.isDev ?? process.env.NODE_ENV !== "production";
|
|
@@ -55,7 +84,9 @@ async function createVscodeConfig(options) {
|
|
|
55
84
|
},
|
|
56
85
|
plugins: [
|
|
57
86
|
stubExpoTypeDeclarations(),
|
|
87
|
+
nativeOnlyDepStubPlugin(workspaceRoot),
|
|
58
88
|
oneServerOnlyBrowserStub(workspaceRoot),
|
|
89
|
+
workspaceReactPlugin(workspaceRoot),
|
|
59
90
|
react({ jsxRuntime: "automatic" }),
|
|
60
91
|
babel({ presets: [reactCompilerPreset()] }),
|
|
61
92
|
tamaguiPlugin({
|
|
@@ -83,26 +114,14 @@ async function createVscodeConfig(options) {
|
|
|
83
114
|
find: "@",
|
|
84
115
|
replacement: path.join(options.targetDir, "webview")
|
|
85
116
|
},
|
|
117
|
+
...Object.entries(movedDepAliases(workspaceRoot)).map(([find, replacement]) => ({
|
|
118
|
+
find,
|
|
119
|
+
replacement
|
|
120
|
+
})),
|
|
86
121
|
{
|
|
87
122
|
find: "react-native",
|
|
88
123
|
replacement: "react-native-web"
|
|
89
124
|
},
|
|
90
|
-
{
|
|
91
|
-
find: /^react$/,
|
|
92
|
-
replacement: path.join(workspaceRoot, "node_modules/react")
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
find: /^react-dom$/,
|
|
96
|
-
replacement: path.join(workspaceRoot, "node_modules/react-dom")
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
find: "react/jsx-runtime",
|
|
100
|
-
replacement: path.join(workspaceRoot, "node_modules/react/jsx-runtime.js")
|
|
101
|
-
},
|
|
102
|
-
{
|
|
103
|
-
find: "react/jsx-dev-runtime",
|
|
104
|
-
replacement: path.join(workspaceRoot, "node_modules/react/jsx-dev-runtime.js")
|
|
105
|
-
},
|
|
106
125
|
...options.aliases ?? []
|
|
107
126
|
],
|
|
108
127
|
dedupe: ["react", "react-dom"],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@multiplatform.one/vite-plugin-vscode",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.1.1",
|
|
4
4
|
"description": "Vite config factory for building a VS Code extension (extension host + Tamagui webview) as a target of a multiplatform.one One app — wraps @tomjs/vite-plugin-vscode with the workspace source aliases, the one-router seam alias, React dedupe against one's vendored copy, and a vsce staging-manifest writer.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"multiplatform.one",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"@babel/core": "^7.26.0",
|
|
50
|
-
"@multiplatform.one/utils": "^10.
|
|
50
|
+
"@multiplatform.one/utils": "^10.1.1",
|
|
51
51
|
"@rolldown/plugin-babel": "^0.2.4",
|
|
52
52
|
"babel-plugin-react-compiler": "^1.0.0"
|
|
53
53
|
},
|
package/src/index.ts
CHANGED
|
@@ -24,6 +24,8 @@ import fs from "node:fs";
|
|
|
24
24
|
import path from "node:path";
|
|
25
25
|
import {
|
|
26
26
|
lookupTamaguiModules,
|
|
27
|
+
movedDepAliases,
|
|
28
|
+
nativeOnlyDepStubPlugin,
|
|
27
29
|
lookupProjectRoot,
|
|
28
30
|
oneServerOnlyBrowserStub,
|
|
29
31
|
stubExpoTypeDeclarations,
|
|
@@ -82,6 +84,36 @@ export function resolveSeamOneAdapter(workspaceRoot: string): string {
|
|
|
82
84
|
return "@multiplatform.one/router/seam";
|
|
83
85
|
}
|
|
84
86
|
|
|
87
|
+
/**
|
|
88
|
+
* Points every "react", "react-dom" and jsx-runtime import in the webview
|
|
89
|
+
* bundle at the workspace copy. Without it, transitive imports from `one`
|
|
90
|
+
* resolve to its vendored React 18 (one/vendor/react/...), whose internals
|
|
91
|
+
* (ReactCurrentOwner) React 19 removed, and the webview crashes at first
|
|
92
|
+
* render.
|
|
93
|
+
*
|
|
94
|
+
* Client environment only. As a `resolve.alias` this also reached Tamagui 3's
|
|
95
|
+
* evaluation environment, which runs in Node: an absolute path is not a bare
|
|
96
|
+
* package, so the module runner inlined React's CommonJS entry and threw
|
|
97
|
+
* "module is not defined" (FZ-11747).
|
|
98
|
+
*/
|
|
99
|
+
function workspaceReactPlugin(workspaceRoot: string): Plugin {
|
|
100
|
+
const targets: Record<string, string> = {
|
|
101
|
+
react: path.join(workspaceRoot, "node_modules/react"),
|
|
102
|
+
"react-dom": path.join(workspaceRoot, "node_modules/react-dom"),
|
|
103
|
+
"react/jsx-runtime": path.join(workspaceRoot, "node_modules/react/jsx-runtime.js"),
|
|
104
|
+
"react/jsx-dev-runtime": path.join(workspaceRoot, "node_modules/react/jsx-dev-runtime.js"),
|
|
105
|
+
};
|
|
106
|
+
return {
|
|
107
|
+
name: "vscode-workspace-react",
|
|
108
|
+
enforce: "pre",
|
|
109
|
+
applyToEnvironment: (environment) => environment.name === "client",
|
|
110
|
+
resolveId(id, importer) {
|
|
111
|
+
const target = targets[id];
|
|
112
|
+
return target ? this.resolve(target, importer, { skipSelf: true }) : null;
|
|
113
|
+
},
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
|
|
85
117
|
export async function createVscodeConfig(options: VscodeTargetOptions): Promise<UserConfig> {
|
|
86
118
|
const workspaceRoot = options.workspaceRoot ?? lookupProjectRoot();
|
|
87
119
|
const isDev = options.isDev ?? process.env.NODE_ENV !== "production";
|
|
@@ -116,7 +148,9 @@ export async function createVscodeConfig(options: VscodeTargetOptions): Promise<
|
|
|
116
148
|
},
|
|
117
149
|
plugins: [
|
|
118
150
|
stubExpoTypeDeclarations(),
|
|
151
|
+
nativeOnlyDepStubPlugin(workspaceRoot),
|
|
119
152
|
oneServerOnlyBrowserStub(workspaceRoot),
|
|
153
|
+
workspaceReactPlugin(workspaceRoot),
|
|
120
154
|
react({ jsxRuntime: "automatic" }),
|
|
121
155
|
// Same React Compiler pass the One app runs — the webview gets the
|
|
122
156
|
// memoization for free (react 19 built-in runtime).
|
|
@@ -147,22 +181,11 @@ export async function createVscodeConfig(options: VscodeTargetOptions): Promise<
|
|
|
147
181
|
// One routing layer: `one` rides the stack-navigation seam.
|
|
148
182
|
{ find: /^one$/, replacement: resolveSeamOneAdapter(workspaceRoot) },
|
|
149
183
|
{ find: "@", replacement: path.join(options.targetDir, "webview") },
|
|
184
|
+
...Object.entries(movedDepAliases(workspaceRoot)).map(([find, replacement]) => ({
|
|
185
|
+
find,
|
|
186
|
+
replacement,
|
|
187
|
+
})),
|
|
150
188
|
{ find: "react-native", replacement: "react-native-web" },
|
|
151
|
-
// Force every "react", "react-dom", and jsx-runtime import to the
|
|
152
|
-
// workspace copy. Without this, transitive imports from `one` resolve
|
|
153
|
-
// to its vendored React 18 (one/vendor/react/...), which uses internal
|
|
154
|
-
// APIs (ReactCurrentOwner) that React 19 has removed — crashing the
|
|
155
|
-
// webview at first render.
|
|
156
|
-
{ find: /^react$/, replacement: path.join(workspaceRoot, "node_modules/react") },
|
|
157
|
-
{ find: /^react-dom$/, replacement: path.join(workspaceRoot, "node_modules/react-dom") },
|
|
158
|
-
{
|
|
159
|
-
find: "react/jsx-runtime",
|
|
160
|
-
replacement: path.join(workspaceRoot, "node_modules/react/jsx-runtime.js"),
|
|
161
|
-
},
|
|
162
|
-
{
|
|
163
|
-
find: "react/jsx-dev-runtime",
|
|
164
|
-
replacement: path.join(workspaceRoot, "node_modules/react/jsx-dev-runtime.js"),
|
|
165
|
-
},
|
|
166
189
|
...(options.aliases ?? []),
|
|
167
190
|
],
|
|
168
191
|
dedupe: ["react", "react-dom"],
|
package/types/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAoCA,OAAO,KAAK,EAAE,KAAK,EAAU,UAAU,EAAE,MAAM,MAAM,CAAC;AAEtD;;;0CAG0C;AAC1C,eAAO,MAAM,mBAAmB,yRAAqR,CAAC;AAEtT,MAAM,WAAW,mBAAmB;IAClC;kCAC8B;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB;kEAC8D;IAC9D,MAAM,EAAE,MAAM,CAAC;IACf,qEAAqE;IACrE,aAAa,EAAE,MAAM,CAAC;IACtB,qDAAqD;IACrD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,0DAA0D;IAC1D,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,sDAAsD;IACtD,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,0DAA0D;IAC1D,OAAO,CAAC,EAAE,KAAK,EAAE,CAAC;CACnB;AAgBD;kEACkE;AAClE,wBAAgB,qBAAqB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CAInE;AAgCD,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,UAAU,CAAC,CAiH1F;AAID,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,sEAAsE;IACtE,IAAI,CAAC,EAAE,QAAQ,GAAG,UAAU,CAAC;IAC7B,2CAA2C;IAC3C,OAAO,CAAC,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IACpD,6DAA6D;IAC7D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACtC,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC5B,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;;;;;;kEAckE;AAClE,wBAAsB,yBAAyB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAoBpF;AAED;;;;;+DAK+D;AAC/D,wBAAsB,iBAAiB,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAcjG"}
|