@tamagui/cli 1.50.2 → 1.50.3
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/dist/dev.js +63 -58
- package/dist/dev.js.map +2 -2
- package/package.json +7 -7
- package/src/dev.ts +79 -72
- package/types/dev.d.ts.map +1 -1
package/dist/dev.js
CHANGED
|
@@ -33,6 +33,7 @@ __export(dev_exports, {
|
|
|
33
33
|
module.exports = __toCommonJS(dev_exports);
|
|
34
34
|
var import_promises = require("fs/promises");
|
|
35
35
|
var import_path = require("path");
|
|
36
|
+
var import_vite_plugin = require("@tamagui/vite-plugin");
|
|
36
37
|
var import_chalk = __toESM(require("chalk"));
|
|
37
38
|
var import_fs_extra = __toESM(require("fs-extra"));
|
|
38
39
|
var import_vite = require("vite");
|
|
@@ -42,69 +43,18 @@ const dev = async (options) => {
|
|
|
42
43
|
var _a;
|
|
43
44
|
const { root, mode, paths } = options;
|
|
44
45
|
process.chdir(process.cwd());
|
|
45
|
-
|
|
46
|
-
await nativePrebuild();
|
|
46
|
+
await (0, import_vite_plugin.nativePrebuild)();
|
|
47
47
|
const plugins = [
|
|
48
|
-
tamaguiPlugin({
|
|
49
|
-
components: ["tamagui"]
|
|
48
|
+
(0, import_vite_plugin.tamaguiPlugin)({
|
|
49
|
+
components: ["tamagui"],
|
|
50
|
+
target: "native"
|
|
50
51
|
}),
|
|
51
|
-
nativePlugin()
|
|
52
|
+
(0, import_vite_plugin.nativePlugin)()
|
|
52
53
|
];
|
|
53
|
-
async function getBundle() {
|
|
54
|
-
console.log("get bundle");
|
|
55
|
-
const outputJsPath = (0, import_path.join)(process.cwd(), ".tamagui", "bundle.js");
|
|
56
|
-
const outputCode = await getBundleCode();
|
|
57
|
-
import_fs_extra.default.writeFile(outputJsPath, outputCode);
|
|
58
|
-
return outputCode;
|
|
59
|
-
}
|
|
60
54
|
const rootFile = (0, import_path.join)(root, "src/test-tamagui-stack.tsx");
|
|
61
|
-
|
|
62
|
-
const buildOutput = await (0, import_vite.build)({
|
|
63
|
-
// @ts-ignore
|
|
64
|
-
plugins,
|
|
65
|
-
appType: "custom",
|
|
66
|
-
root,
|
|
67
|
-
build: {
|
|
68
|
-
ssr: true
|
|
69
|
-
},
|
|
70
|
-
ssr: {
|
|
71
|
-
format: "cjs",
|
|
72
|
-
target: "node"
|
|
73
|
-
},
|
|
74
|
-
mode: "development",
|
|
75
|
-
define: {
|
|
76
|
-
__DEV__: "true",
|
|
77
|
-
"process.env.NODE_ENV": `"development"`
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
const appCode = "output" in buildOutput ? buildOutput.output[0].code : null;
|
|
81
|
-
if (!appCode) {
|
|
82
|
-
throw `\u274C`;
|
|
83
|
-
}
|
|
84
|
-
const [react, reactJsxRuntime, reactNative] = await Promise.all([
|
|
85
|
-
(0, import_promises.readFile)((0, import_path.join)(process.cwd(), "testing-area", "react.js"), "utf-8"),
|
|
86
|
-
(0, import_promises.readFile)((0, import_path.join)(process.cwd(), "testing-area", "react-jsx-runtime.js"), "utf-8"),
|
|
87
|
-
(0, import_promises.readFile)((0, import_path.join)(process.cwd(), "testing-area", "react-native.js"), "utf-8")
|
|
88
|
-
]);
|
|
89
|
-
const reactCode = react.replace(
|
|
90
|
-
`module.exports = require_react_development();`,
|
|
91
|
-
`return require_react_development()`
|
|
92
|
-
);
|
|
93
|
-
const reactJSXRuntimeCode = reactJsxRuntime.replace(
|
|
94
|
-
`module.exports = require_react_jsx_runtime_production_min();`,
|
|
95
|
-
`return require_react_jsx_runtime_production_min()`
|
|
96
|
-
);
|
|
97
|
-
const reactNativeCode = reactNative.replace(
|
|
98
|
-
`module.exports = require_react_native();`,
|
|
99
|
-
`return require_react_native()`
|
|
100
|
-
).replace(
|
|
101
|
-
`renderable = /* @__PURE__ */ react(RootComponentWithMeaningfulName, null, renderable);`,
|
|
102
|
-
``
|
|
103
|
-
);
|
|
104
|
-
return (await (0, import_promises.readFile)("template.js", "utf-8")).replace(`// -- react --`, reactCode).replace(`// -- react-native --`, reactNativeCode).replace(`// -- react/jsx-runtime --`, reactJSXRuntimeCode).replace(`// -- app --`, appCode);
|
|
105
|
-
}
|
|
55
|
+
console.log("root", root, rootFile);
|
|
106
56
|
const server = await (0, import_vite.createServer)({
|
|
107
|
-
root,
|
|
57
|
+
root: rootFile,
|
|
108
58
|
mode: "development",
|
|
109
59
|
plugins,
|
|
110
60
|
server: {
|
|
@@ -179,6 +129,61 @@ const dev = async (options) => {
|
|
|
179
129
|
return (_a2 = server.httpServer) == null ? void 0 : _a2.on("close", res);
|
|
180
130
|
});
|
|
181
131
|
console.log("closed");
|
|
132
|
+
async function getBundle() {
|
|
133
|
+
console.log("get bundle");
|
|
134
|
+
const outputJsPath = (0, import_path.join)(process.cwd(), ".tamagui", "bundle.js");
|
|
135
|
+
const outputCode = await getBundleCode();
|
|
136
|
+
import_fs_extra.default.writeFile(outputJsPath, outputCode);
|
|
137
|
+
return outputCode;
|
|
138
|
+
}
|
|
139
|
+
async function getBundleCode() {
|
|
140
|
+
const buildOutput = await (0, import_vite.build)({
|
|
141
|
+
// @ts-ignore
|
|
142
|
+
plugins,
|
|
143
|
+
appType: "custom",
|
|
144
|
+
root,
|
|
145
|
+
build: {
|
|
146
|
+
ssr: true
|
|
147
|
+
},
|
|
148
|
+
ssr: {
|
|
149
|
+
format: "cjs",
|
|
150
|
+
target: "node"
|
|
151
|
+
},
|
|
152
|
+
mode: "development",
|
|
153
|
+
define: {
|
|
154
|
+
__DEV__: "true",
|
|
155
|
+
"process.env.NODE_ENV": `"development"`
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
const appCode = "output" in buildOutput ? buildOutput.output[0].code : null;
|
|
159
|
+
console.log("built", appCode);
|
|
160
|
+
if (!appCode) {
|
|
161
|
+
throw `\u274C`;
|
|
162
|
+
}
|
|
163
|
+
const [react, reactJsxRuntime, reactNative] = await Promise.all([
|
|
164
|
+
(0, import_promises.readFile)((0, import_path.join)(process.cwd(), "testing-area", "react.js"), "utf-8"),
|
|
165
|
+
(0, import_promises.readFile)((0, import_path.join)(process.cwd(), "testing-area", "react-jsx-runtime.js"), "utf-8"),
|
|
166
|
+
(0, import_promises.readFile)((0, import_path.join)(process.cwd(), "testing-area", "react-native.js"), "utf-8")
|
|
167
|
+
]);
|
|
168
|
+
const reactCode = react.replace(
|
|
169
|
+
`module.exports = require_react_development();`,
|
|
170
|
+
`return require_react_development()`
|
|
171
|
+
);
|
|
172
|
+
const reactJSXRuntimeCode = reactJsxRuntime.replace(
|
|
173
|
+
`module.exports = require_react_jsx_runtime_production_min();`,
|
|
174
|
+
`return require_react_jsx_runtime_production_min()`
|
|
175
|
+
);
|
|
176
|
+
const reactNativeCode = reactNative.replace(
|
|
177
|
+
`module.exports = require_react_native();`,
|
|
178
|
+
`return require_react_native()`
|
|
179
|
+
).replace(
|
|
180
|
+
`renderable = /* @__PURE__ */ react(RootComponentWithMeaningfulName, null, renderable);`,
|
|
181
|
+
``
|
|
182
|
+
);
|
|
183
|
+
const templateFile = (0, import_path.join)(__dirname, "..", "react-native-template.js");
|
|
184
|
+
console.log("reding template", templateFile);
|
|
185
|
+
return (await (0, import_promises.readFile)(templateFile, "utf-8")).replace(`// -- react --`, reactCode).replace(`// -- react-native --`, reactNativeCode).replace(`// -- react/jsx-runtime --`, reactJSXRuntimeCode).replace(`// -- app --`, appCode);
|
|
186
|
+
}
|
|
182
187
|
};
|
|
183
188
|
// Annotate the CommonJS export names for ESM import in node:
|
|
184
189
|
0 && (module.exports = {
|
package/dist/dev.js.map
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/dev.ts"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAyB;AAEzB,kBAAqB;
|
|
5
|
-
"names": ["
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;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Q,gBAAgB,OAAO;AAAA,EACpC;AACF;",
|
|
5
|
+
"names": ["chalk", "_a", "fs"]
|
|
6
6
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/cli",
|
|
3
|
-
"version": "1.50.
|
|
3
|
+
"version": "1.50.3",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"types": "./types/index.d.ts",
|
|
6
6
|
"main": "dist",
|
|
@@ -27,12 +27,12 @@
|
|
|
27
27
|
"@callstack/repack-debugger-app": "^1.0.0",
|
|
28
28
|
"@fastify/sensible": "^4.1.0",
|
|
29
29
|
"@fastify/static": "^5.0.2",
|
|
30
|
-
"@tamagui/build": "1.50.
|
|
31
|
-
"@tamagui/create-theme": "1.50.
|
|
32
|
-
"@tamagui/generate-themes": "1.50.
|
|
33
|
-
"@tamagui/static": "1.50.
|
|
34
|
-
"@tamagui/types": "1.50.
|
|
35
|
-
"@tamagui/vite-plugin": "1.50.
|
|
30
|
+
"@tamagui/build": "1.50.3",
|
|
31
|
+
"@tamagui/create-theme": "1.50.3",
|
|
32
|
+
"@tamagui/generate-themes": "1.50.3",
|
|
33
|
+
"@tamagui/static": "1.50.3",
|
|
34
|
+
"@tamagui/types": "1.50.3",
|
|
35
|
+
"@tamagui/vite-plugin": "1.50.3",
|
|
36
36
|
"@types/compression": "^1.7.2",
|
|
37
37
|
"@types/morgan": "^1.9.3",
|
|
38
38
|
"@vitejs/plugin-react-swc": "^3.3.2",
|
package/src/dev.ts
CHANGED
|
@@ -2,8 +2,8 @@ import { readFile } from 'fs/promises'
|
|
|
2
2
|
import { AddressInfo } from 'net'
|
|
3
3
|
import { join } from 'path'
|
|
4
4
|
|
|
5
|
-
import { watchTamaguiConfig } from '@tamagui/static'
|
|
6
5
|
import { CLIResolvedOptions } from '@tamagui/types'
|
|
6
|
+
import { nativePlugin, nativePrebuild, tamaguiPlugin } from '@tamagui/vite-plugin'
|
|
7
7
|
import chalk from 'chalk'
|
|
8
8
|
import fs, { ensureDir } from 'fs-extra'
|
|
9
9
|
import { build, createServer } from 'vite'
|
|
@@ -16,91 +16,23 @@ export const dev = async (options: CLIResolvedOptions) => {
|
|
|
16
16
|
|
|
17
17
|
process.chdir(process.cwd())
|
|
18
18
|
|
|
19
|
-
const { tamaguiPlugin, nativePlugin, nativePrebuild } = require('@tamagui/vite-plugin')
|
|
20
|
-
|
|
21
19
|
// build react-native
|
|
22
20
|
await nativePrebuild()
|
|
23
21
|
|
|
24
22
|
const plugins = [
|
|
25
23
|
tamaguiPlugin({
|
|
26
24
|
components: ['tamagui'],
|
|
25
|
+
target: 'native',
|
|
27
26
|
}),
|
|
28
27
|
nativePlugin(),
|
|
29
28
|
]
|
|
30
29
|
|
|
31
|
-
async function getBundle() {
|
|
32
|
-
console.log('get bundle')
|
|
33
|
-
const outputJsPath = join(process.cwd(), '.tamagui', 'bundle.js')
|
|
34
|
-
const outputCode = await getBundleCode()
|
|
35
|
-
// debug out each time
|
|
36
|
-
fs.writeFile(outputJsPath, outputCode)
|
|
37
|
-
return outputCode
|
|
38
|
-
}
|
|
39
|
-
|
|
40
30
|
const rootFile = join(root, 'src/test-tamagui-stack.tsx')
|
|
41
31
|
|
|
42
|
-
|
|
43
|
-
// build app
|
|
44
|
-
const buildOutput = await build({
|
|
45
|
-
// @ts-ignore
|
|
46
|
-
plugins,
|
|
47
|
-
appType: 'custom',
|
|
48
|
-
root,
|
|
49
|
-
build: {
|
|
50
|
-
ssr: true,
|
|
51
|
-
},
|
|
52
|
-
ssr: {
|
|
53
|
-
format: 'cjs',
|
|
54
|
-
target: 'node',
|
|
55
|
-
},
|
|
56
|
-
mode: 'development',
|
|
57
|
-
define: {
|
|
58
|
-
__DEV__: 'true',
|
|
59
|
-
'process.env.NODE_ENV': `"development"`,
|
|
60
|
-
},
|
|
61
|
-
})
|
|
62
|
-
|
|
63
|
-
const appCode = 'output' in buildOutput ? buildOutput.output[0].code : null
|
|
64
|
-
|
|
65
|
-
if (!appCode) {
|
|
66
|
-
throw `❌`
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
const [react, reactJsxRuntime, reactNative] = await Promise.all([
|
|
70
|
-
readFile(join(process.cwd(), 'testing-area', 'react.js'), 'utf-8'),
|
|
71
|
-
readFile(join(process.cwd(), 'testing-area', 'react-jsx-runtime.js'), 'utf-8'),
|
|
72
|
-
readFile(join(process.cwd(), 'testing-area', 'react-native.js'), 'utf-8'),
|
|
73
|
-
])
|
|
74
|
-
|
|
75
|
-
const reactCode = react.replace(
|
|
76
|
-
`module.exports = require_react_development();`,
|
|
77
|
-
`return require_react_development()`
|
|
78
|
-
)
|
|
79
|
-
|
|
80
|
-
const reactJSXRuntimeCode = reactJsxRuntime.replace(
|
|
81
|
-
`module.exports = require_react_jsx_runtime_production_min();`,
|
|
82
|
-
`return require_react_jsx_runtime_production_min()`
|
|
83
|
-
)
|
|
84
|
-
|
|
85
|
-
const reactNativeCode = reactNative
|
|
86
|
-
.replace(
|
|
87
|
-
`module.exports = require_react_native();`,
|
|
88
|
-
`return require_react_native()`
|
|
89
|
-
)
|
|
90
|
-
.replace(
|
|
91
|
-
`renderable = /* @__PURE__ */ react(RootComponentWithMeaningfulName, null, renderable);`,
|
|
92
|
-
``
|
|
93
|
-
)
|
|
94
|
-
|
|
95
|
-
return (await readFile('template.js', 'utf-8'))
|
|
96
|
-
.replace(`// -- react --`, reactCode)
|
|
97
|
-
.replace(`// -- react-native --`, reactNativeCode)
|
|
98
|
-
.replace(`// -- react/jsx-runtime --`, reactJSXRuntimeCode)
|
|
99
|
-
.replace(`// -- app --`, appCode)
|
|
100
|
-
}
|
|
32
|
+
console.log('root', root, rootFile)
|
|
101
33
|
|
|
102
34
|
const server = await createServer({
|
|
103
|
-
root,
|
|
35
|
+
root: rootFile,
|
|
104
36
|
mode: 'development',
|
|
105
37
|
plugins,
|
|
106
38
|
server: {
|
|
@@ -188,4 +120,79 @@ export const dev = async (options: CLIResolvedOptions) => {
|
|
|
188
120
|
// await res?.context.dispose()
|
|
189
121
|
|
|
190
122
|
console.log('closed')
|
|
123
|
+
|
|
124
|
+
async function getBundle() {
|
|
125
|
+
console.log('get bundle')
|
|
126
|
+
const outputJsPath = join(process.cwd(), '.tamagui', 'bundle.js')
|
|
127
|
+
const outputCode = await getBundleCode()
|
|
128
|
+
// debug out each time
|
|
129
|
+
fs.writeFile(outputJsPath, outputCode)
|
|
130
|
+
return outputCode
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
async function getBundleCode() {
|
|
134
|
+
// build app
|
|
135
|
+
const buildOutput = await build({
|
|
136
|
+
// @ts-ignore
|
|
137
|
+
plugins,
|
|
138
|
+
appType: 'custom',
|
|
139
|
+
root,
|
|
140
|
+
build: {
|
|
141
|
+
ssr: true,
|
|
142
|
+
},
|
|
143
|
+
ssr: {
|
|
144
|
+
format: 'cjs',
|
|
145
|
+
target: 'node',
|
|
146
|
+
},
|
|
147
|
+
mode: 'development',
|
|
148
|
+
define: {
|
|
149
|
+
__DEV__: 'true',
|
|
150
|
+
'process.env.NODE_ENV': `"development"`,
|
|
151
|
+
},
|
|
152
|
+
})
|
|
153
|
+
|
|
154
|
+
const appCode = 'output' in buildOutput ? buildOutput.output[0].code : null
|
|
155
|
+
|
|
156
|
+
console.log('built', appCode)
|
|
157
|
+
|
|
158
|
+
if (!appCode) {
|
|
159
|
+
throw `❌`
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const [react, reactJsxRuntime, reactNative] = await Promise.all([
|
|
163
|
+
readFile(join(process.cwd(), 'testing-area', 'react.js'), 'utf-8'),
|
|
164
|
+
readFile(join(process.cwd(), 'testing-area', 'react-jsx-runtime.js'), 'utf-8'),
|
|
165
|
+
readFile(join(process.cwd(), 'testing-area', 'react-native.js'), 'utf-8'),
|
|
166
|
+
])
|
|
167
|
+
|
|
168
|
+
const reactCode = react.replace(
|
|
169
|
+
`module.exports = require_react_development();`,
|
|
170
|
+
`return require_react_development()`
|
|
171
|
+
)
|
|
172
|
+
|
|
173
|
+
const reactJSXRuntimeCode = reactJsxRuntime.replace(
|
|
174
|
+
`module.exports = require_react_jsx_runtime_production_min();`,
|
|
175
|
+
`return require_react_jsx_runtime_production_min()`
|
|
176
|
+
)
|
|
177
|
+
|
|
178
|
+
const reactNativeCode = reactNative
|
|
179
|
+
.replace(
|
|
180
|
+
`module.exports = require_react_native();`,
|
|
181
|
+
`return require_react_native()`
|
|
182
|
+
)
|
|
183
|
+
.replace(
|
|
184
|
+
`renderable = /* @__PURE__ */ react(RootComponentWithMeaningfulName, null, renderable);`,
|
|
185
|
+
``
|
|
186
|
+
)
|
|
187
|
+
|
|
188
|
+
const templateFile = join(__dirname, '..', 'react-native-template.js')
|
|
189
|
+
|
|
190
|
+
console.log('reding template', templateFile)
|
|
191
|
+
|
|
192
|
+
return (await readFile(templateFile, 'utf-8'))
|
|
193
|
+
.replace(`// -- react --`, reactCode)
|
|
194
|
+
.replace(`// -- react-native --`, reactNativeCode)
|
|
195
|
+
.replace(`// -- react/jsx-runtime --`, reactJSXRuntimeCode)
|
|
196
|
+
.replace(`// -- app --`, appCode)
|
|
197
|
+
}
|
|
191
198
|
}
|
package/types/dev.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../src/dev.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../src/dev.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AASnD,eAAO,MAAM,GAAG,YAAmB,kBAAkB,kBAwLpD,CAAA"}
|