@tamagui/vite-plugin 1.1.11 → 1.1.13

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.
@@ -0,0 +1,134 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var nativePrebuild_exports = {};
30
+ __export(nativePrebuild_exports, {
31
+ nativePrebuild: () => nativePrebuild
32
+ });
33
+ module.exports = __toCommonJS(nativePrebuild_exports);
34
+ var import_promises = require("fs/promises");
35
+ var import_esbuild = require("esbuild");
36
+ var import_flow_remove_types = __toESM(require("flow-remove-types"), 1);
37
+ var import_extensions = require("./extensions.js");
38
+ async function nativePrebuild() {
39
+ console.log(`Prebuilding React Native (one time cost...)`);
40
+ await Promise.all([
41
+ // react
42
+ (0, import_esbuild.build)({
43
+ bundle: true,
44
+ entryPoints: ["react"],
45
+ outfile: "react.js",
46
+ format: "cjs",
47
+ target: "node14",
48
+ jsx: "transform",
49
+ jsxFactory: "react",
50
+ allowOverwrite: true,
51
+ platform: "node",
52
+ define: {
53
+ __DEV__: "true",
54
+ "process.env.NODE_ENV": `"development"`
55
+ },
56
+ logLevel: "warning",
57
+ resolveExtensions: import_extensions.extensions
58
+ }),
59
+ // react-jsx-runtime
60
+ (0, import_esbuild.build)({
61
+ bundle: true,
62
+ entryPoints: ["react/jsx-runtime"],
63
+ outfile: "react-jsx-runtime.js",
64
+ format: "cjs",
65
+ target: "node14",
66
+ jsx: "transform",
67
+ jsxFactory: "react",
68
+ external: ["react"],
69
+ allowOverwrite: true,
70
+ platform: "node",
71
+ define: {
72
+ // metro serves this in production mode
73
+ __DEV__: "false",
74
+ "process.env.NODE_ENV": `"production"`
75
+ },
76
+ logLevel: "warning",
77
+ resolveExtensions: import_extensions.extensions
78
+ }),
79
+ // react native
80
+ (0, import_esbuild.build)({
81
+ bundle: true,
82
+ entryPoints: ["/Users/n8/tamagui/node_modules/react-native/index.js"],
83
+ outfile: "react-native.js",
84
+ format: "cjs",
85
+ target: "node14",
86
+ jsx: "transform",
87
+ jsxFactory: "react",
88
+ allowOverwrite: true,
89
+ platform: "node",
90
+ loader: {
91
+ ".png": "dataurl",
92
+ ".jpg": "dataurl",
93
+ ".jpeg": "dataurl",
94
+ ".gif": "dataurl"
95
+ },
96
+ define: {
97
+ __DEV__: "true",
98
+ "process.env.NODE_ENV": `"development"`
99
+ },
100
+ logLevel: "warning",
101
+ resolveExtensions: import_extensions.extensions,
102
+ external: ["react", "react/jsx-runtime.js", "react/jsx-runtime"],
103
+ plugins: [
104
+ {
105
+ name: "remove-flow",
106
+ setup(build2) {
107
+ build2.onLoad(
108
+ {
109
+ filter: /.*.js/
110
+ },
111
+ async (input) => {
112
+ if (!input.path.includes("react-native")) {
113
+ return;
114
+ }
115
+ const code = await (0, import_promises.readFile)(input.path, "utf-8");
116
+ const output = (0, import_flow_remove_types.default)(code, { pretty: true });
117
+ const contents = output.toString().replace(/static\s+\+/g, "static ");
118
+ return {
119
+ contents,
120
+ loader: "jsx"
121
+ };
122
+ }
123
+ );
124
+ }
125
+ }
126
+ ]
127
+ })
128
+ ]);
129
+ }
130
+ // Annotate the CommonJS export names for ESM import in node:
131
+ 0 && (module.exports = {
132
+ nativePrebuild
133
+ });
134
+ //# sourceMappingURL=nativePrebuild.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/nativePrebuild.ts"],
4
+ "sourcesContent": ["import { readFile } from 'fs/promises'\n\nimport { build } from 'esbuild'\nimport flowRemoveTypes from 'flow-remove-types'\n\nimport { extensions } from './extensions.js'\n\nexport async function nativePrebuild() {\n console.log(`Prebuilding React Native (one time cost...)`)\n await Promise.all([\n // react\n build({\n bundle: true,\n entryPoints: ['react'],\n outfile: 'react.js',\n format: 'cjs',\n target: 'node14',\n jsx: 'transform',\n jsxFactory: 'react',\n allowOverwrite: true,\n platform: 'node',\n define: {\n __DEV__: 'true',\n 'process.env.NODE_ENV': `\"development\"`,\n },\n logLevel: 'warning',\n resolveExtensions: extensions,\n }),\n // react-jsx-runtime\n build({\n bundle: true,\n entryPoints: ['react/jsx-runtime'],\n outfile: 'react-jsx-runtime.js',\n format: 'cjs',\n target: 'node14',\n jsx: 'transform',\n jsxFactory: 'react',\n external: ['react'],\n allowOverwrite: true,\n platform: 'node',\n define: {\n // metro serves this in production mode\n __DEV__: 'false',\n 'process.env.NODE_ENV': `\"production\"`,\n },\n logLevel: 'warning',\n resolveExtensions: extensions,\n }),\n // react native\n build({\n bundle: true,\n entryPoints: ['/Users/n8/tamagui/node_modules/react-native/index.js'],\n outfile: 'react-native.js',\n format: 'cjs',\n target: 'node14',\n jsx: 'transform',\n jsxFactory: 'react',\n allowOverwrite: true,\n platform: 'node',\n loader: {\n '.png': 'dataurl',\n '.jpg': 'dataurl',\n '.jpeg': 'dataurl',\n '.gif': 'dataurl',\n },\n define: {\n __DEV__: 'true',\n 'process.env.NODE_ENV': `\"development\"`,\n },\n logLevel: 'warning',\n resolveExtensions: extensions,\n external: ['react', 'react/jsx-runtime.js', 'react/jsx-runtime'],\n plugins: [\n {\n name: 'remove-flow',\n setup(build) {\n build.onLoad(\n {\n filter: /.*.js/,\n },\n async (input) => {\n if (!input.path.includes('react-native')) {\n return\n }\n const code = await readFile(input.path, 'utf-8')\n const output = flowRemoveTypes(code, { pretty: true })\n const contents = output.toString().replace(/static\\s+\\+/g, 'static ')\n return {\n contents,\n loader: 'jsx',\n }\n }\n )\n },\n },\n ],\n }),\n ])\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAyB;AAEzB,qBAAsB;AACtB,+BAA4B;AAE5B,wBAA2B;AAE3B,eAAsB,iBAAiB;AACrC,UAAQ,IAAI,6CAA6C;AACzD,QAAM,QAAQ,IAAI;AAAA;AAAA,QAEhB,sBAAM;AAAA,MACJ,QAAQ;AAAA,MACR,aAAa,CAAC,OAAO;AAAA,MACrB,SAAS;AAAA,MACT,QAAQ;AAAA,MACR,QAAQ;AAAA,MACR,KAAK;AAAA,MACL,YAAY;AAAA,MACZ,gBAAgB;AAAA,MAChB,UAAU;AAAA,MACV,QAAQ;AAAA,QACN,SAAS;AAAA,QACT,wBAAwB;AAAA,MAC1B;AAAA,MACA,UAAU;AAAA,MACV,mBAAmB;AAAA,IACrB,CAAC;AAAA;AAAA,QAED,sBAAM;AAAA,MACJ,QAAQ;AAAA,MACR,aAAa,CAAC,mBAAmB;AAAA,MACjC,SAAS;AAAA,MACT,QAAQ;AAAA,MACR,QAAQ;AAAA,MACR,KAAK;AAAA,MACL,YAAY;AAAA,MACZ,UAAU,CAAC,OAAO;AAAA,MAClB,gBAAgB;AAAA,M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+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var plugin_exports = {};
20
+ __export(plugin_exports, {
21
+ tamaguiPlugin: () => tamaguiPlugin
22
+ });
23
+ module.exports = __toCommonJS(plugin_exports);
24
+ function tamaguiPlugin(options) {
25
+ const components = [.../* @__PURE__ */ new Set([...options.components, "tamagui", "@tamagui/core"])];
26
+ const noExternalSSR = new RegExp(
27
+ `${components.join("|")}|react-native|expo-linear-gradient`,
28
+ "ig"
29
+ );
30
+ const plugin = {
31
+ name: "tamagui-base",
32
+ enforce: "pre",
33
+ config(userConfig, env) {
34
+ return {
35
+ plugins: [
36
+ //
37
+ // envPlugin(['NODE_ENV', 'TAMAGUI_TARGET', 'ENABLE_RSC']),
38
+ // viteCommonjs(),
39
+ ],
40
+ define: {
41
+ // reanimated support
42
+ "global.__x": {},
43
+ _frameTimestamp: void 0,
44
+ _WORKLET: false,
45
+ ...process.env.NODE_ENV !== "test" && {
46
+ "process.env.TAMAGUI_TARGET": JSON.stringify(
47
+ process.env.TAMAGUI_TARGET || "web"
48
+ ),
49
+ "process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV || env.mode),
50
+ "process.env.ENABLE_RSC": JSON.stringify(process.env.ENABLE_RSC || ""),
51
+ "process.env.ENABLE_STEPS": JSON.stringify(process.env.ENABLE_STEPS || ""),
52
+ "process.env.IS_STATIC": JSON.stringify(false)
53
+ }
54
+ },
55
+ // build: {
56
+ // commonjsOptions: {
57
+ // transformMixedEsModules: true,
58
+ // },
59
+ // },
60
+ ssr: {
61
+ noExternal: noExternalSSR
62
+ },
63
+ optimizeDeps: {
64
+ // disabled: false,
65
+ include: ["styleq", "react-native-reanimated"],
66
+ esbuildOptions: {
67
+ jsx: "transform",
68
+ // plugins: [
69
+ // esbuildCommonjs([
70
+ // 'styleq',
71
+ // 'inline-style-prefixer',
72
+ // 'create-react-class',
73
+ // 'copy-to-clipboard',
74
+ // ]),
75
+ // ],
76
+ resolveExtensions: [
77
+ ".web.js",
78
+ ".web.ts",
79
+ ".web.tsx",
80
+ ".js",
81
+ ".jsx",
82
+ ".json",
83
+ ".ts",
84
+ ".tsx",
85
+ ".mjs"
86
+ ],
87
+ loader: {
88
+ ".js": "jsx"
89
+ }
90
+ }
91
+ },
92
+ resolve: {
93
+ // for once it extracts
94
+ // mainFields: ['module:jsx', 'module', 'jsnext:main', 'jsnext', 'main'],
95
+ extensions: [
96
+ ".web.js",
97
+ ".web.ts",
98
+ ".web.tsx",
99
+ ".js",
100
+ ".jsx",
101
+ ".json",
102
+ ".ts",
103
+ ".tsx",
104
+ ".mjs"
105
+ ],
106
+ alias: {
107
+ "react-native/Libraries/Renderer/shims/ReactFabric": "@tamagui/proxy-worm",
108
+ "react-native/Libraries/Utilities/codegenNativeComponent": "@tamagui/proxy-worm",
109
+ "react-native-svg": "@tamagui/react-native-svg",
110
+ "react-native": "react-native-web",
111
+ ...options.useReactNativeWebLite && {
112
+ "react-native": "react-native-web-lite",
113
+ "react-native-web": "react-native-web-lite"
114
+ }
115
+ }
116
+ }
117
+ };
118
+ }
119
+ };
120
+ return plugin;
121
+ }
122
+ // Annotate the CommonJS export names for ESM import in node:
123
+ 0 && (module.exports = {
124
+ tamaguiPlugin
125
+ });
126
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/plugin.ts"],
4
+ "sourcesContent": ["import type { TamaguiOptions } from '@tamagui/static'\nimport type { Plugin } from 'vite'\n\n/**\n * For some reason envPlugin doesnt work for vitest, but process: { env: {} } breaks vitest\n */\n\nexport function tamaguiPlugin(\n options: TamaguiOptions & {\n useReactNativeWebLite?: boolean\n }\n): Plugin {\n const components = [...new Set([...options.components, 'tamagui', '@tamagui/core'])]\n const noExternalSSR = new RegExp(\n `${components.join('|')}|react-native|expo-linear-gradient`,\n 'ig'\n )\n\n const plugin: Plugin = {\n name: 'tamagui-base',\n enforce: 'pre',\n\n config(userConfig, env) {\n return {\n plugins: [\n //\n // envPlugin(['NODE_ENV', 'TAMAGUI_TARGET', 'ENABLE_RSC']),\n // viteCommonjs(),\n ],\n define: {\n // reanimated support\n 'global.__x': {},\n _frameTimestamp: undefined,\n _WORKLET: false,\n ...(process.env.NODE_ENV !== 'test' && {\n 'process.env.TAMAGUI_TARGET': JSON.stringify(\n process.env.TAMAGUI_TARGET || 'web'\n ),\n 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || env.mode),\n 'process.env.ENABLE_RSC': JSON.stringify(process.env.ENABLE_RSC || ''),\n 'process.env.ENABLE_STEPS': JSON.stringify(process.env.ENABLE_STEPS || ''),\n 'process.env.IS_STATIC': JSON.stringify(false),\n }),\n },\n // build: {\n // commonjsOptions: {\n // transformMixedEsModules: true,\n // },\n // },\n ssr: {\n noExternal: noExternalSSR,\n },\n optimizeDeps: {\n // disabled: false,\n include: ['styleq', 'react-native-reanimated'],\n esbuildOptions: {\n jsx: 'transform',\n // plugins: [\n // esbuildCommonjs([\n // 'styleq',\n // 'inline-style-prefixer',\n // 'create-react-class',\n // 'copy-to-clipboard',\n // ]),\n // ],\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', 'main'],\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':\n '@tamagui/proxy-worm',\n 'react-native-svg': '@tamagui/react-native-svg',\n 'react-native': 'react-native-web',\n ...(options.useReactNativeWebLite && {\n 'react-native': 'react-native-web-lite',\n 'react-native-web': 'react-native-web-lite',\n }),\n },\n },\n }\n },\n }\n\n return plugin\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOO,SAAS,cACd,SAGQ;AACR,QAAM,aAAa,CAAC,GAAG,oBAAI,IAAI,CAAC,GAAG,QAAQ,YAAY,WAAW,eAAe,CAAC,CAAC;AACnF,QAAM,gBAAgB,IAAI;AAAA,IACxB,GAAG,WAAW,KAAK,GAAG;AAAA,IACtB;AAAA,EACF;AAEA,QAAM,SAAiB;AAAA,IACrB,MAAM;AAAA,IACN,SAAS;AAAA,IAET,OAAO,YAAY,KAAK;AACtB,aAAO;AAAA,QACL,SAAS;AAAA;AAAA;AAAA;AAAA,QAIT;AAAA,QACA,QAAQ;AAAA;AAAA,UAEN,cAAc,CAAC;AAAA,UACf,iBAAiB;AAAA,UACjB,UAAU;AAAA,UACV,GAAI,QAAQ,IAAI,aAAa,UAAU;AAAA,YACrC,8BAA8B,KAAK;AAAA,cACjC,QAAQ,IAAI,kBAAkB;AAAA,YAChC;AAAA,YACA,wBAAwB,KAAK,UAAU,QAAQ,IAAI,YAAY,IAAI,IAAI;AAAA,YACvE,0BAA0B,KAAK,UAAU,QAAQ,IAAI,cAAc,EAAE;AAAA,YACrE,4BAA4B,KAAK,UAAU,QAAQ,IAAI,gBAAgB,EAAE;AAAA,YACzE,yBAAyB,KAAK,UAAU,KAAK;AAAA,UAC/C;AAAA,QACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAMA,KAAK;AAAA,UACH,YAAY;AAAA,QACd;AAAA,QACA,cAAc;AAAA;AAAA,UAEZ,SAAS,CAAC,UAAU,yBAAyB;AAAA,UAC7C,gBAAgB;AAAA,YACd,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,YASL,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;AAAA;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,2DACE;AAAA,YACF,oBAAoB;AAAA,YACpB,gBAAgB;AAAA,YAChB,GAAI,QAAQ,yBAAyB;AAAA,cACnC,gBAAgB;AAAA,cAChB,oBAAoB;AAAA,YACtB;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;",
6
+ "names": []
7
+ }
@@ -0,0 +1,16 @@
1
+ const extensions = [
2
+ ".ios.js",
3
+ ".native.js",
4
+ ".native.ts",
5
+ ".native.tsx",
6
+ ".js",
7
+ ".jsx",
8
+ ".json",
9
+ ".ts",
10
+ ".tsx",
11
+ ".mjs"
12
+ ];
13
+ export {
14
+ extensions
15
+ };
16
+ //# sourceMappingURL=extensions.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/extensions.ts"],
4
+ "sourcesContent": ["export const extensions = [\n '.ios.js',\n '.native.js',\n '.native.ts',\n '.native.tsx',\n '.js',\n '.jsx',\n '.json',\n '.ts',\n '.tsx',\n '.mjs',\n]\n"],
5
+ "mappings": "AAAO,MAAM,aAAa;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,163 @@
1
+ import path from "path";
2
+ import * as Static from "@tamagui/static";
3
+ import outdent from "outdent";
4
+ import { normalizePath } from "vite";
5
+ const { createExtractor, extractToClassNames, getPragmaOptions } = Static["default"];
6
+ const styleUpdateEvent = (fileId) => `tamagui-style-update:${fileId}`;
7
+ const GLOBAL_CSS_VIRTUAL_PATH = "__tamagui_global_css__.css";
8
+ function tamaguiExtractPlugin(options) {
9
+ const disableStatic = options.disable || options.disableDebugAttr && options.disableExtraction;
10
+ if (disableStatic) {
11
+ return {
12
+ name: "tamagui-extract"
13
+ };
14
+ }
15
+ let extractor = null;
16
+ const cssMap = /* @__PURE__ */ new Map();
17
+ let config;
18
+ let server;
19
+ let shouldReturnCSS = true;
20
+ let virtualExt;
21
+ const getAbsoluteVirtualFileId = (filePath) => {
22
+ if (filePath.startsWith(config.root)) {
23
+ return filePath;
24
+ }
25
+ return normalizePath(path.join(config.root, filePath));
26
+ };
27
+ return {
28
+ name: "tamagui-extract",
29
+ enforce: "pre",
30
+ configureServer(_server) {
31
+ server = _server;
32
+ },
33
+ buildEnd() {
34
+ extractor.cleanupBeforeExit();
35
+ },
36
+ writeBundle(options2, bundle) {
37
+ setTimeout(() => {
38
+ console.warn("some sort of dangling process or osmethign, exit for now...");
39
+ process.exit(0);
40
+ }, 100);
41
+ },
42
+ config(_userConfig, env) {
43
+ const include = env.command === "serve" ? ["@tamagui/core/inject-styles"] : [];
44
+ return {
45
+ optimizeDeps: { include }
46
+ };
47
+ },
48
+ async configResolved(resolvedConfig) {
49
+ config = resolvedConfig;
50
+ extractor = createExtractor({
51
+ logger: resolvedConfig.logger
52
+ });
53
+ shouldReturnCSS = true;
54
+ virtualExt = `.tamagui.${shouldReturnCSS ? "css" : "js"}`;
55
+ },
56
+ async resolveId(source) {
57
+ if (source === "tamagui.css") {
58
+ await extractor.loadTamagui(options);
59
+ return GLOBAL_CSS_VIRTUAL_PATH;
60
+ }
61
+ const [validId, query] = source.split("?");
62
+ if (!validId.endsWith(virtualExt)) {
63
+ return;
64
+ }
65
+ const absoluteId = source.startsWith(config.root) ? source : getAbsoluteVirtualFileId(validId);
66
+ if (cssMap.has(absoluteId)) {
67
+ return absoluteId + (query ? `?${query}` : "");
68
+ }
69
+ },
70
+ /**
71
+ * TODO
72
+ *
73
+ * mainFields module:jsx breaks, so lets just have a mapping here
74
+ * where we load() and map it to the jsx path before transform
75
+ *
76
+ */
77
+ load(id, options2) {
78
+ const [validId] = id.split("?");
79
+ if (validId === GLOBAL_CSS_VIRTUAL_PATH) {
80
+ return extractor.getTamagui().getCSS();
81
+ }
82
+ if (!cssMap.has(validId)) {
83
+ return;
84
+ }
85
+ const css = cssMap.get(validId);
86
+ if (typeof css !== "string") {
87
+ return;
88
+ }
89
+ if (shouldReturnCSS || !server || server.config.isProduction) {
90
+ return css;
91
+ }
92
+ return outdent`
93
+ import { injectStyles } from '@tamagui/core/inject-styles';
94
+
95
+ const inject = (css) => injectStyles({
96
+ filePath: "${validId}",
97
+ css
98
+ });
99
+
100
+ inject(${JSON.stringify(css)});
101
+
102
+ if (import.meta.hot) {
103
+ import.meta.hot.on('${styleUpdateEvent(validId)}', (css) => {
104
+ inject(css);
105
+ });
106
+ }
107
+ `;
108
+ },
109
+ async transform(code, id, ssrParam) {
110
+ const [validId] = id.split("?");
111
+ if (!validId.endsWith(".tsx")) {
112
+ return;
113
+ }
114
+ const firstCommentIndex = code.indexOf("// ");
115
+ const { shouldDisable, shouldPrintDebug } = getPragmaOptions({
116
+ source: firstCommentIndex >= 0 ? code.slice(firstCommentIndex) : "",
117
+ path: validId
118
+ });
119
+ if (shouldDisable) {
120
+ return;
121
+ }
122
+ const extracted = await extractToClassNames({
123
+ extractor,
124
+ source: code,
125
+ sourcePath: validId,
126
+ options,
127
+ shouldPrintDebug
128
+ });
129
+ if (!extracted) {
130
+ return;
131
+ }
132
+ const rootRelativeId = `${validId}${virtualExt}`;
133
+ const absoluteId = getAbsoluteVirtualFileId(rootRelativeId);
134
+ let source = extracted.js;
135
+ if (extracted.styles) {
136
+ if (server && cssMap.has(absoluteId) && cssMap.get(absoluteId) !== extracted.styles) {
137
+ const { moduleGraph } = server;
138
+ const [module] = Array.from(moduleGraph.getModulesByFile(absoluteId) || []);
139
+ if (module) {
140
+ moduleGraph.invalidateModule(module);
141
+ module.lastHMRTimestamp = module.lastInvalidationTimestamp || Date.now();
142
+ }
143
+ server.ws.send({
144
+ type: "custom",
145
+ event: styleUpdateEvent(absoluteId),
146
+ data: extracted.styles
147
+ });
148
+ }
149
+ source = `${source}
150
+ import "${rootRelativeId}";`;
151
+ cssMap.set(absoluteId, extracted.styles);
152
+ }
153
+ return {
154
+ code: source.toString(),
155
+ map: extracted.map
156
+ };
157
+ }
158
+ };
159
+ }
160
+ export {
161
+ tamaguiExtractPlugin
162
+ };
163
+ //# sourceMappingURL=extract.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/extract.ts"],
4
+ "sourcesContent": ["// fork from https://github.com/seek-oss/vanilla-extract\n\nimport path from 'path'\n\nimport { TamaguiOptions } from '@tamagui/static'\nimport * as Static from '@tamagui/static'\nimport outdent from 'outdent'\nimport type { Plugin, ResolvedConfig, ViteDevServer } from 'vite'\nimport { normalizePath } from 'vite'\n\nconst { createExtractor, extractToClassNames, getPragmaOptions } = Static['default']\n\nconst styleUpdateEvent = (fileId: string) => `tamagui-style-update:${fileId}`\nconst GLOBAL_CSS_VIRTUAL_PATH = '__tamagui_global_css__.css'\n\nexport function tamaguiExtractPlugin(options: TamaguiOptions): Plugin {\n const disableStatic =\n options.disable || (options.disableDebugAttr && options.disableExtraction)\n\n if (disableStatic) {\n return {\n name: 'tamagui-extract',\n }\n }\n\n let extractor: ReturnType<typeof createExtractor> | null = null\n const cssMap = new Map<string, string>()\n\n let config: ResolvedConfig\n let server: ViteDevServer\n let shouldReturnCSS = true //config.command === 'serve'\n let virtualExt: string\n\n const getAbsoluteVirtualFileId = (filePath: string) => {\n if (filePath.startsWith(config.root)) {\n return filePath\n }\n return normalizePath(path.join(config.root, filePath))\n }\n\n return {\n name: 'tamagui-extract',\n enforce: 'pre',\n\n configureServer(_server) {\n server = _server\n },\n\n buildEnd() {\n extractor!.cleanupBeforeExit()\n },\n\n writeBundle(this, options, bundle) {\n setTimeout(() => {\n // eslint-disable-next-line no-console\n console.warn('some sort of dangling process or osmethign, exit for now...')\n process.exit(0)\n }, 100)\n },\n\n config(_userConfig, env) {\n const include = env.command === 'serve' ? ['@tamagui/core/inject-styles'] : []\n return {\n optimizeDeps: { include },\n }\n },\n\n async configResolved(resolvedConfig) {\n config = resolvedConfig\n extractor = createExtractor({\n logger: resolvedConfig.logger,\n })\n shouldReturnCSS = true\n // TODO postcss work with postcss.config.js\n // packageName = getPackageInfo(config.root).name;\n // if (config.command === 'serve') {\n // postCssConfig = await resolvePostcssConfig(config);\n // }\n virtualExt = `.tamagui.${shouldReturnCSS ? 'css' : 'js'}`\n },\n\n async resolveId(source) {\n if (source === 'tamagui.css') {\n await extractor!.loadTamagui(options)\n return GLOBAL_CSS_VIRTUAL_PATH\n }\n\n const [validId, query] = source.split('?')\n\n if (!validId.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)\n ? source\n : getAbsoluteVirtualFileId(validId)\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 .tamagui.js/.tamagui.css extension\n if (cssMap.has(absoluteId)) {\n // Keep the original query string for HMR.\n return absoluteId + (query ? `?${query}` : '')\n }\n },\n\n /**\n * TODO\n *\n * mainFields module:jsx breaks, so lets just have a mapping here\n * where we load() and map it to the jsx path before transform\n *\n */\n\n load(id, options) {\n const [validId] = id.split('?')\n\n if (validId === GLOBAL_CSS_VIRTUAL_PATH) {\n return extractor!.getTamagui()!.getCSS()\n }\n\n if (!cssMap.has(validId)) {\n return\n }\n\n const css = cssMap.get(validId)\n\n if (typeof css !== 'string') {\n return\n }\n\n if (shouldReturnCSS || !server || server.config.isProduction) {\n return css\n }\n\n return outdent`\n import { injectStyles } from '@tamagui/core/inject-styles';\n\n const inject = (css) => injectStyles({\n filePath: \"${validId}\",\n css\n });\n\n inject(${JSON.stringify(css)});\n\n if (import.meta.hot) {\n import.meta.hot.on('${styleUpdateEvent(validId)}', (css) => {\n inject(css);\n });\n }\n `\n },\n\n async transform(code, id, ssrParam) {\n const [validId] = id.split('?')\n\n if (!validId.endsWith('.tsx')) {\n return\n }\n\n // let ssr: boolean | undefined\n // if (typeof ssrParam === 'boolean') {\n // ssr = ssrParam\n // } else {\n // ssr = ssrParam?.ssr\n // }\n\n const firstCommentIndex = code.indexOf('// ')\n const { shouldDisable, shouldPrintDebug } = getPragmaOptions({\n source: firstCommentIndex >= 0 ? code.slice(firstCommentIndex) : '',\n path: validId,\n })\n\n if (shouldDisable) {\n return\n }\n\n const extracted = await extractToClassNames({\n extractor: extractor!,\n source: code,\n sourcePath: validId,\n options,\n shouldPrintDebug,\n })\n\n if (!extracted) {\n return\n }\n\n const rootRelativeId = `${validId}${virtualExt}`\n const absoluteId = getAbsoluteVirtualFileId(rootRelativeId)\n\n let source = extracted.js\n\n if (extracted.styles) {\n if (\n server &&\n cssMap.has(absoluteId) &&\n cssMap.get(absoluteId) !== extracted.styles\n ) {\n const { moduleGraph } = server\n const [module] = Array.from(moduleGraph.getModulesByFile(absoluteId) || [])\n\n if (module) {\n moduleGraph.invalidateModule(module)\n\n // Vite uses this timestamp to add `?t=` query string automatically for HMR.\n module.lastHMRTimestamp =\n (module as any).lastInvalidationTimestamp || Date.now()\n }\n\n server.ws.send({\n type: 'custom',\n event: styleUpdateEvent(absoluteId),\n data: extracted.styles,\n })\n }\n\n source = `${source}\\nimport \"${rootRelativeId}\";`\n cssMap.set(absoluteId, extracted.styles)\n }\n\n return {\n code: source.toString(),\n map: extracted.map,\n }\n\n // if (ssr && !process.env.VITE_RSC_BUILD) {\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 !== validId) {\n // this.addWatchFile(file)\n // }\n // }\n },\n }\n}\n"],
5
+ "mappings": "AAEA,OAAO,UAAU;AAGjB,YAAY,YAAY;AACxB,OAAO,aAAa;AAEpB,SAAS,qBAAqB;AAE9B,MAAM,EAAE,iBAAiB,qBAAqB,iBAAiB,IAAI,OAAO,SAAS;AAEnF,MAAM,mBAAmB,CAAC,WAAmB,wBAAwB;AACrE,MAAM,0BAA0B;AAEzB,SAAS,qBAAqB,SAAiC;AACpE,QAAM,gBACJ,QAAQ,WAAY,QAAQ,oBAAoB,QAAQ;AAE1D,MAAI,eAAe;AACjB,WAAO;AAAA,MACL,MAAM;AAAA,IACR;AAAA,EACF;AAEA,MAAI,YAAuD;AAC3D,QAAM,SAAS,oBAAI,IAAoB;AAEvC,MAAI;AACJ,MAAI;AACJ,MAAI,kBAAkB;AACtB,MAAI;AAEJ,QAAM,2BAA2B,CAAC,aAAqB;AACrD,QAAI,SAAS,WAAW,OAAO,IAAI,GAAG;AACpC,aAAO;AAAA,IACT;AACA,WAAO,cAAc,KAAK,KAAK,OAAO,MAAM,QAAQ,CAAC;AAAA,EACvD;AAEA,SAAO;AAAA,IACL,MAAM;AAAA,IACN,SAAS;AAAA,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,KAAK,IAAI;AAAA,UAC1D;AAEA,iBAAO,GAAG,KAAK;AAAA,YACb,MAAM;AAAA,YACN,OAAO,iBAAiB,UAAU;AAAA,YAClC,MAAM,UAAU;AAAA,UAClB,CAAC;AAAA,QACH;AAEA,iBAAS,GAAG;AAAA,UAAmB;AAC/B,eAAO,IAAI,YAAY,UAAU,MAAM;AAAA,MACzC;AAEA,aAAO;AAAA,QACL,MAAM,OAAO,SAAS;AAAA,QACtB,KAAK,UAAU;AAAA,MACjB;AAAA,IAwBF;AAAA,EACF;AACF;",
6
+ "names": ["options"]
7
+ }
@@ -0,0 +1,5 @@
1
+ export * from "./plugin.js";
2
+ export * from "./extract.js";
3
+ export * from "./native.js";
4
+ export * from "./nativePrebuild.js";
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/index.ts"],
4
+ "sourcesContent": ["export * from './plugin.js'\nexport * from './extract.js'\nexport * from './native.js'\nexport * from './nativePrebuild.js'\n"],
5
+ "mappings": "AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;",
6
+ "names": []
7
+ }