@tamagui/vite-plugin 1.0.1-beta.91 → 1.0.1-beta.94
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/cjs/plugin.js +5 -0
- package/dist/cjs/plugin.js.map +2 -2
- package/dist/esm/plugin.js +2 -0
- package/dist/esm/plugin.js.map +2 -2
- package/dist/jsx/plugin.js +2 -0
- package/dist/jsx/plugin.js.map +2 -2
- package/package.json +4 -5
- package/src/plugin.ts +5 -1
- package/types/plugin.d.ts.map +1 -1
package/dist/cjs/plugin.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
7
|
var __export = (target, all) => {
|
|
6
8
|
for (var name in all)
|
|
@@ -14,18 +16,21 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
14
16
|
}
|
|
15
17
|
return to;
|
|
16
18
|
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
17
20
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
21
|
var plugin_exports = {};
|
|
19
22
|
__export(plugin_exports, {
|
|
20
23
|
tamaguiPlugin: () => tamaguiPlugin
|
|
21
24
|
});
|
|
22
25
|
module.exports = __toCommonJS(plugin_exports);
|
|
26
|
+
var import_vite_plugin_environment = __toESM(require("vite-plugin-environment"));
|
|
23
27
|
function tamaguiPlugin(options) {
|
|
24
28
|
return {
|
|
25
29
|
name: "tamagui",
|
|
26
30
|
enforce: "pre",
|
|
27
31
|
config(userConfig, env) {
|
|
28
32
|
return {
|
|
33
|
+
plugins: [(0, import_vite_plugin_environment.default)(["NODE_ENV", "TAMAGUI_TARGET"])],
|
|
29
34
|
esbuild: {
|
|
30
35
|
loader: "tsx"
|
|
31
36
|
},
|
package/dist/cjs/plugin.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/plugin.ts"],
|
|
4
|
-
"sourcesContent": ["import type { TamaguiOptions } from '@tamagui/static'\nimport type { Plugin
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import type { TamaguiOptions } from '@tamagui/static'\nimport type { Plugin } from 'vite'\nimport envPlugin from 'vite-plugin-environment'\n\nexport function tamaguiPlugin(options?: TamaguiOptions): Plugin {\n return {\n name: 'tamagui',\n enforce: 'pre',\n\n config(userConfig, env) {\n return {\n plugins: [envPlugin(['NODE_ENV', 'TAMAGUI_TARGET'])],\n esbuild: {\n loader: 'tsx',\n },\n define: {\n global: {},\n _frameTimestamp: undefined,\n _WORKLET: false,\n process: {\n env: {\n TAMAGUI_TARGET: process.env.TAMAGUI_TARGET || 'web',\n NODE_ENV: process.env.NODE_ENV || env.mode,\n },\n },\n },\n optimizeDeps: {\n esbuildOptions: {\n resolveExtensions: [\n '.web.js',\n '.web.ts',\n '.web.tsx',\n '.js',\n '.jsx',\n '.json',\n '.ts',\n '.tsx',\n '.mjs',\n ],\n loader: {\n '.js': 'jsx',\n },\n },\n },\n resolve: {\n // for once it extracts\n // mainFields: ['module:jsx', 'module', 'jsnext:main', 'jsnext'],\n extensions: [\n '.web.js',\n '.web.ts',\n '.web.tsx',\n '.js',\n '.jsx',\n '.json',\n '.ts',\n '.tsx',\n '.mjs',\n ],\n alias: {\n 'react-native/Libraries/Renderer/shims/ReactFabric': '@tamagui/proxy-worm',\n 'react-native/Libraries/Utilities/codegenNativeComponent': '@tamagui/proxy-worm',\n 'react-native': 'react-native-web',\n },\n },\n }\n },\n }\n}\n\n// fork from https://github.com/seek-oss/vanilla-extract/blob/master/packages/vite-plugin/src/index.ts\n\n// import path from 'path'\n\n// import outdent from 'outdent'\n// import type { Plugin, ResolvedConfig, ViteDevServer } from 'vite'\n// import { normalizePath } from 'vite'\n\n// const styleUpdateEvent = (fileId: string) => `tamagui-style-update:${fileId}`\n\n// interface Options {\n// identifiers?: IdentifierOption\n// esbuildOptions?: CompileOptions['esbuildOptions']\n// }\n// export function vanillaExtractPlugin({ identifiers, esbuildOptions }: Options = {}): Plugin {\n// let config: ResolvedConfig\n// let server: ViteDevServer\n// let postCssConfig: PostCSSConfigResult | null\n// const cssMap = new Map<string, string>()\n\n// let virtualExt: string\n// let packageName: string\n\n// const getAbsoluteVirtualFileId = (source: string) => normalizePath(path.join(config.root, source))\n\n// return {\n// name: 'tamagui',\n// enforce: 'pre',\n// configureServer(_server) {\n// server = _server\n// },\n// config(_userConfig, env) {\n// const include = env.command === 'serve' ? ['@tamagui/css/injectStyles'] : []\n\n// return {\n// optimizeDeps: { include },\n// ssr: {\n// external: ['@tamagui/css', '@tamagui/css/fileScope', '@tamagui/css/adapter'],\n// },\n// }\n// },\n// async configResolved(resolvedConfig) {\n// config = resolvedConfig\n// packageName = getPackageInfo(config.root).name\n\n// if (config.command === 'serve') {\n// postCssConfig = await resolvePostcssConfig(config)\n// }\n\n// virtualExt = `.vanilla.${config.command === 'serve' ? 'js' : 'css'}`\n// },\n// resolveId(source) {\n// if (!source.endsWith(virtualExt)) {\n// return\n// }\n\n// // Absolute paths seem to occur often in monorepos, where files are\n// // imported from outside the config root.\n// const absoluteId = source.startsWith(config.root) ? source : getAbsoluteVirtualFileId(source)\n\n// // There should always be an entry in the `cssMap` here.\n// // The only valid scenario for a missing one is if someone had written\n// // a file in their app using the .vanilla.js/.vanilla.css extension\n// if (cssMap.has(absoluteId)) {\n// return absoluteId\n// }\n// },\n// load(id) {\n// if (!cssMap.has(id)) {\n// return\n// }\n\n// const css = cssMap.get(id)\n\n// if (typeof css !== 'string') {\n// return\n// }\n\n// if (!server || server.config.isProduction) {\n// return css\n// }\n\n// return outdent`\n// import { injectStyles } from '@tamagui/css/injectStyles';\n\n// const inject = (css) => injectStyles({\n// fileScope: ${JSON.stringify({ filePath: id })},\n// css\n// });\n\n// inject(${JSON.stringify(css)});\n\n// import.meta.hot.on('${styleUpdateEvent(id)}', (css) => {\n// inject(css);\n// });\n// `\n// },\n// async transform(code, id, ssrParam) {\n// if (!cssFileFilter.test(id)) {\n// return null\n// }\n\n// let ssr: boolean | undefined\n\n// if (typeof ssrParam === 'boolean') {\n// ssr = ssrParam\n// } else {\n// ssr = ssrParam?.ssr\n// }\n\n// const index = id.indexOf('?')\n// const validId = index === -1 ? id : id.substring(0, index)\n\n// if (ssr) {\n// return addFileScope({\n// source: code,\n// filePath: normalizePath(validId),\n// rootPath: config.root,\n// packageName,\n// })\n// }\n\n// const { source, watchFiles } = await compile({\n// filePath: validId,\n// cwd: config.root,\n// esbuildOptions,\n// })\n\n// for (const file of watchFiles) {\n// // In start mode, we need to prevent the file from rewatching itself.\n// // If it's a `build --watch`, it needs to watch everything.\n// if (config.command === 'build' || file !== id) {\n// this.addWatchFile(file)\n// }\n// }\n\n// const output = await processVanillaFile({\n// source,\n// filePath: validId,\n// identOption: identifiers ?? (config.mode === 'production' ? 'short' : 'debug'),\n// serializeVirtualCssPath: async ({ fileScope, source }) => {\n// const rootRelativeId = `${fileScope.filePath}${virtualExt}`\n// const absoluteId = getAbsoluteVirtualFileId(rootRelativeId)\n\n// let cssSource = source\n\n// if (postCssConfig) {\n// const postCssResult = await (await import('postcss'))\n// .default(postCssConfig.plugins)\n// .process(source, {\n// ...postCssConfig.options,\n// from: undefined,\n// map: false,\n// })\n\n// cssSource = postCssResult.css\n// }\n\n// if (server && cssMap.has(absoluteId) && cssMap.get(absoluteId) !== source) {\n// const { moduleGraph } = server\n// const module = moduleGraph.getModuleById(absoluteId)\n\n// if (module) {\n// moduleGraph.invalidateModule(module)\n// }\n\n// server.ws.send({\n// type: 'custom',\n// event: styleUpdateEvent(absoluteId),\n// data: cssSource,\n// })\n// }\n\n// cssMap.set(absoluteId, cssSource)\n\n// // We use the root relative id here to ensure file contents (content-hashes)\n// // are consistent across build machines\n// return `import \"${rootRelativeId}\";`\n// },\n// })\n\n// return {\n// code: output,\n// map: { mappings: '' },\n// }\n// },\n// }\n// }\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,qCAAsB;AAEf,uBAAuB,SAAkC;AAC9D,SAAO;AAAA,IACL,MAAM;AAAA,IACN,SAAS;AAAA,IAET,OAAO,YAAY,KAAK;AACtB,aAAO;AAAA,QACL,SAAS,CAAC,4CAAU,CAAC,YAAY,gBAAgB,CAAC,CAAC;AAAA,QACnD,SAAS;AAAA,UACP,QAAQ;AAAA,QACV;AAAA,QACA,QAAQ;AAAA,UACN,QAAQ,CAAC;AAAA,UACT,iBAAiB;AAAA,UACjB,UAAU;AAAA,UACV,SAAS;AAAA,YACP,KAAK;AAAA,cACH,gBAAgB,QAAQ,IAAI,kBAAkB;AAAA,cAC9C,UAAU,QAAQ,IAAI,YAAY,IAAI;AAAA,YACxC;AAAA,UACF;AAAA,QACF;AAAA,QACA,cAAc;AAAA,UACZ,gBAAgB;AAAA,YACd,mBAAmB;AAAA,cACjB;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,YACF;AAAA,YACA,QAAQ;AAAA,cACN,OAAO;AAAA,YACT;AAAA,UACF;AAAA,QACF;AAAA,QACA,SAAS;AAAA,UAGP,YAAY;AAAA,YACV;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,UACF;AAAA,UACA,OAAO;AAAA,YACL,qDAAqD;AAAA,YACrD,2DAA2D;AAAA,YAC3D,gBAAgB;AAAA,UAClB;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/plugin.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import envPlugin from "vite-plugin-environment";
|
|
1
2
|
function tamaguiPlugin(options) {
|
|
2
3
|
return {
|
|
3
4
|
name: "tamagui",
|
|
4
5
|
enforce: "pre",
|
|
5
6
|
config(userConfig, env) {
|
|
6
7
|
return {
|
|
8
|
+
plugins: [envPlugin(["NODE_ENV", "TAMAGUI_TARGET"])],
|
|
7
9
|
esbuild: {
|
|
8
10
|
loader: "tsx"
|
|
9
11
|
},
|
package/dist/esm/plugin.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/plugin.ts"],
|
|
4
|
-
"sourcesContent": ["import type { TamaguiOptions } from '@tamagui/static'\nimport type { Plugin
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import type { TamaguiOptions } from '@tamagui/static'\nimport type { Plugin } from 'vite'\nimport envPlugin from 'vite-plugin-environment'\n\nexport function tamaguiPlugin(options?: TamaguiOptions): Plugin {\n return {\n name: 'tamagui',\n enforce: 'pre',\n\n config(userConfig, env) {\n return {\n plugins: [envPlugin(['NODE_ENV', 'TAMAGUI_TARGET'])],\n esbuild: {\n loader: 'tsx',\n },\n define: {\n global: {},\n _frameTimestamp: undefined,\n _WORKLET: false,\n process: {\n env: {\n TAMAGUI_TARGET: process.env.TAMAGUI_TARGET || 'web',\n NODE_ENV: process.env.NODE_ENV || env.mode,\n },\n },\n },\n optimizeDeps: {\n esbuildOptions: {\n resolveExtensions: [\n '.web.js',\n '.web.ts',\n '.web.tsx',\n '.js',\n '.jsx',\n '.json',\n '.ts',\n '.tsx',\n '.mjs',\n ],\n loader: {\n '.js': 'jsx',\n },\n },\n },\n resolve: {\n // for once it extracts\n // mainFields: ['module:jsx', 'module', 'jsnext:main', 'jsnext'],\n extensions: [\n '.web.js',\n '.web.ts',\n '.web.tsx',\n '.js',\n '.jsx',\n '.json',\n '.ts',\n '.tsx',\n '.mjs',\n ],\n alias: {\n 'react-native/Libraries/Renderer/shims/ReactFabric': '@tamagui/proxy-worm',\n 'react-native/Libraries/Utilities/codegenNativeComponent': '@tamagui/proxy-worm',\n 'react-native': 'react-native-web',\n },\n },\n }\n },\n }\n}\n\n// fork from https://github.com/seek-oss/vanilla-extract/blob/master/packages/vite-plugin/src/index.ts\n\n// import path from 'path'\n\n// import outdent from 'outdent'\n// import type { Plugin, ResolvedConfig, ViteDevServer } from 'vite'\n// import { normalizePath } from 'vite'\n\n// const styleUpdateEvent = (fileId: string) => `tamagui-style-update:${fileId}`\n\n// interface Options {\n// identifiers?: IdentifierOption\n// esbuildOptions?: CompileOptions['esbuildOptions']\n// }\n// export function vanillaExtractPlugin({ identifiers, esbuildOptions }: Options = {}): Plugin {\n// let config: ResolvedConfig\n// let server: ViteDevServer\n// let postCssConfig: PostCSSConfigResult | null\n// const cssMap = new Map<string, string>()\n\n// let virtualExt: string\n// let packageName: string\n\n// const getAbsoluteVirtualFileId = (source: string) => normalizePath(path.join(config.root, source))\n\n// return {\n// name: 'tamagui',\n// enforce: 'pre',\n// configureServer(_server) {\n// server = _server\n// },\n// config(_userConfig, env) {\n// const include = env.command === 'serve' ? ['@tamagui/css/injectStyles'] : []\n\n// return {\n// optimizeDeps: { include },\n// ssr: {\n// external: ['@tamagui/css', '@tamagui/css/fileScope', '@tamagui/css/adapter'],\n// },\n// }\n// },\n// async configResolved(resolvedConfig) {\n// config = resolvedConfig\n// packageName = getPackageInfo(config.root).name\n\n// if (config.command === 'serve') {\n// postCssConfig = await resolvePostcssConfig(config)\n// }\n\n// virtualExt = `.vanilla.${config.command === 'serve' ? 'js' : 'css'}`\n// },\n// resolveId(source) {\n// if (!source.endsWith(virtualExt)) {\n// return\n// }\n\n// // Absolute paths seem to occur often in monorepos, where files are\n// // imported from outside the config root.\n// const absoluteId = source.startsWith(config.root) ? source : getAbsoluteVirtualFileId(source)\n\n// // There should always be an entry in the `cssMap` here.\n// // The only valid scenario for a missing one is if someone had written\n// // a file in their app using the .vanilla.js/.vanilla.css extension\n// if (cssMap.has(absoluteId)) {\n// return absoluteId\n// }\n// },\n// load(id) {\n// if (!cssMap.has(id)) {\n// return\n// }\n\n// const css = cssMap.get(id)\n\n// if (typeof css !== 'string') {\n// return\n// }\n\n// if (!server || server.config.isProduction) {\n// return css\n// }\n\n// return outdent`\n// import { injectStyles } from '@tamagui/css/injectStyles';\n\n// const inject = (css) => injectStyles({\n// fileScope: ${JSON.stringify({ filePath: id })},\n// css\n// });\n\n// inject(${JSON.stringify(css)});\n\n// import.meta.hot.on('${styleUpdateEvent(id)}', (css) => {\n// inject(css);\n// });\n// `\n// },\n// async transform(code, id, ssrParam) {\n// if (!cssFileFilter.test(id)) {\n// return null\n// }\n\n// let ssr: boolean | undefined\n\n// if (typeof ssrParam === 'boolean') {\n// ssr = ssrParam\n// } else {\n// ssr = ssrParam?.ssr\n// }\n\n// const index = id.indexOf('?')\n// const validId = index === -1 ? id : id.substring(0, index)\n\n// if (ssr) {\n// return addFileScope({\n// source: code,\n// filePath: normalizePath(validId),\n// rootPath: config.root,\n// packageName,\n// })\n// }\n\n// const { source, watchFiles } = await compile({\n// filePath: validId,\n// cwd: config.root,\n// esbuildOptions,\n// })\n\n// for (const file of watchFiles) {\n// // In start mode, we need to prevent the file from rewatching itself.\n// // If it's a `build --watch`, it needs to watch everything.\n// if (config.command === 'build' || file !== id) {\n// this.addWatchFile(file)\n// }\n// }\n\n// const output = await processVanillaFile({\n// source,\n// filePath: validId,\n// identOption: identifiers ?? (config.mode === 'production' ? 'short' : 'debug'),\n// serializeVirtualCssPath: async ({ fileScope, source }) => {\n// const rootRelativeId = `${fileScope.filePath}${virtualExt}`\n// const absoluteId = getAbsoluteVirtualFileId(rootRelativeId)\n\n// let cssSource = source\n\n// if (postCssConfig) {\n// const postCssResult = await (await import('postcss'))\n// .default(postCssConfig.plugins)\n// .process(source, {\n// ...postCssConfig.options,\n// from: undefined,\n// map: false,\n// })\n\n// cssSource = postCssResult.css\n// }\n\n// if (server && cssMap.has(absoluteId) && cssMap.get(absoluteId) !== source) {\n// const { moduleGraph } = server\n// const module = moduleGraph.getModuleById(absoluteId)\n\n// if (module) {\n// moduleGraph.invalidateModule(module)\n// }\n\n// server.ws.send({\n// type: 'custom',\n// event: styleUpdateEvent(absoluteId),\n// data: cssSource,\n// })\n// }\n\n// cssMap.set(absoluteId, cssSource)\n\n// // We use the root relative id here to ensure file contents (content-hashes)\n// // are consistent across build machines\n// return `import \"${rootRelativeId}\";`\n// },\n// })\n\n// return {\n// code: output,\n// map: { mappings: '' },\n// }\n// },\n// }\n// }\n"],
|
|
5
|
+
"mappings": "AAEA;AAEO,uBAAuB,SAAkC;AAC9D,SAAO;AAAA,IACL,MAAM;AAAA,IACN,SAAS;AAAA,IAET,OAAO,YAAY,KAAK;AACtB,aAAO;AAAA,QACL,SAAS,CAAC,UAAU,CAAC,YAAY,gBAAgB,CAAC,CAAC;AAAA,QACnD,SAAS;AAAA,UACP,QAAQ;AAAA,QACV;AAAA,QACA,QAAQ;AAAA,UACN,QAAQ,CAAC;AAAA,UACT,iBAAiB;AAAA,UACjB,UAAU;AAAA,UACV,SAAS;AAAA,YACP,KAAK;AAAA,cACH,gBAAgB,QAAQ,IAAI,kBAAkB;AAAA,cAC9C,UAAU,QAAQ,IAAI,YAAY,IAAI;AAAA,YACxC;AAAA,UACF;AAAA,QACF;AAAA,QACA,cAAc;AAAA,UACZ,gBAAgB;AAAA,YACd,mBAAmB;AAAA,cACjB;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,YACF;AAAA,YACA,QAAQ;AAAA,cACN,OAAO;AAAA,YACT;AAAA,UACF;AAAA,QACF;AAAA,QACA,SAAS;AAAA,UAGP,YAAY;AAAA,YACV;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,UACF;AAAA,UACA,OAAO;AAAA,YACL,qDAAqD;AAAA,YACrD,2DAA2D;AAAA,YAC3D,gBAAgB;AAAA,UAClB;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/jsx/plugin.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import envPlugin from "vite-plugin-environment";
|
|
1
2
|
function tamaguiPlugin(options) {
|
|
2
3
|
return {
|
|
3
4
|
name: "tamagui",
|
|
4
5
|
enforce: "pre",
|
|
5
6
|
config(userConfig, env) {
|
|
6
7
|
return {
|
|
8
|
+
plugins: [envPlugin(["NODE_ENV", "TAMAGUI_TARGET"])],
|
|
7
9
|
esbuild: {
|
|
8
10
|
loader: "tsx"
|
|
9
11
|
},
|
package/dist/jsx/plugin.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/plugin.ts"],
|
|
4
|
-
"sourcesContent": ["import type { TamaguiOptions } from '@tamagui/static'\nimport type { Plugin
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import type { TamaguiOptions } from '@tamagui/static'\nimport type { Plugin } from 'vite'\nimport envPlugin from 'vite-plugin-environment'\n\nexport function tamaguiPlugin(options?: TamaguiOptions): Plugin {\n return {\n name: 'tamagui',\n enforce: 'pre',\n\n config(userConfig, env) {\n return {\n plugins: [envPlugin(['NODE_ENV', 'TAMAGUI_TARGET'])],\n esbuild: {\n loader: 'tsx',\n },\n define: {\n global: {},\n _frameTimestamp: undefined,\n _WORKLET: false,\n process: {\n env: {\n TAMAGUI_TARGET: process.env.TAMAGUI_TARGET || 'web',\n NODE_ENV: process.env.NODE_ENV || env.mode,\n },\n },\n },\n optimizeDeps: {\n esbuildOptions: {\n resolveExtensions: [\n '.web.js',\n '.web.ts',\n '.web.tsx',\n '.js',\n '.jsx',\n '.json',\n '.ts',\n '.tsx',\n '.mjs',\n ],\n loader: {\n '.js': 'jsx',\n },\n },\n },\n resolve: {\n // for once it extracts\n // mainFields: ['module:jsx', 'module', 'jsnext:main', 'jsnext'],\n extensions: [\n '.web.js',\n '.web.ts',\n '.web.tsx',\n '.js',\n '.jsx',\n '.json',\n '.ts',\n '.tsx',\n '.mjs',\n ],\n alias: {\n 'react-native/Libraries/Renderer/shims/ReactFabric': '@tamagui/proxy-worm',\n 'react-native/Libraries/Utilities/codegenNativeComponent': '@tamagui/proxy-worm',\n 'react-native': 'react-native-web',\n },\n },\n }\n },\n }\n}\n\n// fork from https://github.com/seek-oss/vanilla-extract/blob/master/packages/vite-plugin/src/index.ts\n\n// import path from 'path'\n\n// import outdent from 'outdent'\n// import type { Plugin, ResolvedConfig, ViteDevServer } from 'vite'\n// import { normalizePath } from 'vite'\n\n// const styleUpdateEvent = (fileId: string) => `tamagui-style-update:${fileId}`\n\n// interface Options {\n// identifiers?: IdentifierOption\n// esbuildOptions?: CompileOptions['esbuildOptions']\n// }\n// export function vanillaExtractPlugin({ identifiers, esbuildOptions }: Options = {}): Plugin {\n// let config: ResolvedConfig\n// let server: ViteDevServer\n// let postCssConfig: PostCSSConfigResult | null\n// const cssMap = new Map<string, string>()\n\n// let virtualExt: string\n// let packageName: string\n\n// const getAbsoluteVirtualFileId = (source: string) => normalizePath(path.join(config.root, source))\n\n// return {\n// name: 'tamagui',\n// enforce: 'pre',\n// configureServer(_server) {\n// server = _server\n// },\n// config(_userConfig, env) {\n// const include = env.command === 'serve' ? ['@tamagui/css/injectStyles'] : []\n\n// return {\n// optimizeDeps: { include },\n// ssr: {\n// external: ['@tamagui/css', '@tamagui/css/fileScope', '@tamagui/css/adapter'],\n// },\n// }\n// },\n// async configResolved(resolvedConfig) {\n// config = resolvedConfig\n// packageName = getPackageInfo(config.root).name\n\n// if (config.command === 'serve') {\n// postCssConfig = await resolvePostcssConfig(config)\n// }\n\n// virtualExt = `.vanilla.${config.command === 'serve' ? 'js' : 'css'}`\n// },\n// resolveId(source) {\n// if (!source.endsWith(virtualExt)) {\n// return\n// }\n\n// // Absolute paths seem to occur often in monorepos, where files are\n// // imported from outside the config root.\n// const absoluteId = source.startsWith(config.root) ? source : getAbsoluteVirtualFileId(source)\n\n// // There should always be an entry in the `cssMap` here.\n// // The only valid scenario for a missing one is if someone had written\n// // a file in their app using the .vanilla.js/.vanilla.css extension\n// if (cssMap.has(absoluteId)) {\n// return absoluteId\n// }\n// },\n// load(id) {\n// if (!cssMap.has(id)) {\n// return\n// }\n\n// const css = cssMap.get(id)\n\n// if (typeof css !== 'string') {\n// return\n// }\n\n// if (!server || server.config.isProduction) {\n// return css\n// }\n\n// return outdent`\n// import { injectStyles } from '@tamagui/css/injectStyles';\n\n// const inject = (css) => injectStyles({\n// fileScope: ${JSON.stringify({ filePath: id })},\n// css\n// });\n\n// inject(${JSON.stringify(css)});\n\n// import.meta.hot.on('${styleUpdateEvent(id)}', (css) => {\n// inject(css);\n// });\n// `\n// },\n// async transform(code, id, ssrParam) {\n// if (!cssFileFilter.test(id)) {\n// return null\n// }\n\n// let ssr: boolean | undefined\n\n// if (typeof ssrParam === 'boolean') {\n// ssr = ssrParam\n// } else {\n// ssr = ssrParam?.ssr\n// }\n\n// const index = id.indexOf('?')\n// const validId = index === -1 ? id : id.substring(0, index)\n\n// if (ssr) {\n// return addFileScope({\n// source: code,\n// filePath: normalizePath(validId),\n// rootPath: config.root,\n// packageName,\n// })\n// }\n\n// const { source, watchFiles } = await compile({\n// filePath: validId,\n// cwd: config.root,\n// esbuildOptions,\n// })\n\n// for (const file of watchFiles) {\n// // In start mode, we need to prevent the file from rewatching itself.\n// // If it's a `build --watch`, it needs to watch everything.\n// if (config.command === 'build' || file !== id) {\n// this.addWatchFile(file)\n// }\n// }\n\n// const output = await processVanillaFile({\n// source,\n// filePath: validId,\n// identOption: identifiers ?? (config.mode === 'production' ? 'short' : 'debug'),\n// serializeVirtualCssPath: async ({ fileScope, source }) => {\n// const rootRelativeId = `${fileScope.filePath}${virtualExt}`\n// const absoluteId = getAbsoluteVirtualFileId(rootRelativeId)\n\n// let cssSource = source\n\n// if (postCssConfig) {\n// const postCssResult = await (await import('postcss'))\n// .default(postCssConfig.plugins)\n// .process(source, {\n// ...postCssConfig.options,\n// from: undefined,\n// map: false,\n// })\n\n// cssSource = postCssResult.css\n// }\n\n// if (server && cssMap.has(absoluteId) && cssMap.get(absoluteId) !== source) {\n// const { moduleGraph } = server\n// const module = moduleGraph.getModuleById(absoluteId)\n\n// if (module) {\n// moduleGraph.invalidateModule(module)\n// }\n\n// server.ws.send({\n// type: 'custom',\n// event: styleUpdateEvent(absoluteId),\n// data: cssSource,\n// })\n// }\n\n// cssMap.set(absoluteId, cssSource)\n\n// // We use the root relative id here to ensure file contents (content-hashes)\n// // are consistent across build machines\n// return `import \"${rootRelativeId}\";`\n// },\n// })\n\n// return {\n// code: output,\n// map: { mappings: '' },\n// }\n// },\n// }\n// }\n"],
|
|
5
|
+
"mappings": "AAEA;AAEO,uBAAuB,SAAkC;AAC9D,SAAO;AAAA,IACL,MAAM;AAAA,IACN,SAAS;AAAA,IAET,OAAO,YAAY,KAAK;AACtB,aAAO;AAAA,QACL,SAAS,CAAC,UAAU,CAAC,YAAY,gBAAgB,CAAC,CAAC;AAAA,QACnD,SAAS;AAAA,UACP,QAAQ;AAAA,QACV;AAAA,QACA,QAAQ;AAAA,UACN,QAAQ,CAAC;AAAA,UACT,iBAAiB;AAAA,UACjB,UAAU;AAAA,UACV,SAAS;AAAA,YACP,KAAK;AAAA,cACH,gBAAgB,QAAQ,IAAI,kBAAkB;AAAA,cAC9C,UAAU,QAAQ,IAAI,YAAY,IAAI;AAAA,YACxC;AAAA,UACF;AAAA,QACF;AAAA,QACA,cAAc;AAAA,UACZ,gBAAgB;AAAA,YACd,mBAAmB;AAAA,cACjB;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,YACF;AAAA,YACA,QAAQ;AAAA,cACN,OAAO;AAAA,YACT;AAAA,UACF;AAAA,QACF;AAAA,QACA,SAAS;AAAA,UAGP,YAAY;AAAA,YACV;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,UACF;AAAA,UACA,OAAO;AAAA,YACL,qDAAqD;AAAA,YACrD,2DAA2D;AAAA,YAC3D,gBAAgB;AAAA,UAClB;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/vite-plugin",
|
|
3
|
-
"version": "1.0.1-beta.
|
|
3
|
+
"version": "1.0.1-beta.94",
|
|
4
4
|
"types": "./types/index.d.ts",
|
|
5
5
|
"main": "dist/cjs",
|
|
6
6
|
"module": "dist/esm",
|
|
@@ -18,14 +18,13 @@
|
|
|
18
18
|
"clean:build": "tamagui-build clean:build"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@tamagui/
|
|
22
|
-
"@tamagui/proxy-worm": "^1.0.1-beta.91",
|
|
23
|
-
"@tamagui/static": "^1.0.1-beta.91",
|
|
21
|
+
"@tamagui/proxy-worm": "^1.0.1-beta.94",
|
|
24
22
|
"fs-extra": "^10.1.0",
|
|
25
23
|
"lodash": "^4.17.21"
|
|
26
24
|
},
|
|
27
25
|
"devDependencies": {
|
|
28
|
-
"@tamagui/build": "^1.0.1-beta.
|
|
26
|
+
"@tamagui/build": "^1.0.1-beta.94",
|
|
27
|
+
"vite-plugin-environment": "^1.1.1"
|
|
29
28
|
},
|
|
30
29
|
"publishConfig": {
|
|
31
30
|
"access": "public"
|
package/src/plugin.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { TamaguiOptions } from '@tamagui/static'
|
|
2
|
-
import type { Plugin
|
|
2
|
+
import type { Plugin } from 'vite'
|
|
3
|
+
import envPlugin from 'vite-plugin-environment'
|
|
3
4
|
|
|
4
5
|
export function tamaguiPlugin(options?: TamaguiOptions): Plugin {
|
|
5
6
|
return {
|
|
@@ -8,6 +9,7 @@ export function tamaguiPlugin(options?: TamaguiOptions): Plugin {
|
|
|
8
9
|
|
|
9
10
|
config(userConfig, env) {
|
|
10
11
|
return {
|
|
12
|
+
plugins: [envPlugin(['NODE_ENV', 'TAMAGUI_TARGET'])],
|
|
11
13
|
esbuild: {
|
|
12
14
|
loader: 'tsx',
|
|
13
15
|
},
|
|
@@ -41,6 +43,8 @@ export function tamaguiPlugin(options?: TamaguiOptions): Plugin {
|
|
|
41
43
|
},
|
|
42
44
|
},
|
|
43
45
|
resolve: {
|
|
46
|
+
// for once it extracts
|
|
47
|
+
// mainFields: ['module:jsx', 'module', 'jsnext:main', 'jsnext'],
|
|
44
48
|
extensions: [
|
|
45
49
|
'.web.js',
|
|
46
50
|
'.web.ts',
|
package/types/plugin.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AACrD,OAAO,KAAK,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AACrD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAGlC,wBAAgB,aAAa,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,MAAM,CA+D9D"}
|