@tamagui/vite-plugin 1.0.1-beta.71

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,18 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from === "object" || typeof from === "function") {
7
+ for (let key of __getOwnPropNames(from))
8
+ if (!__hasOwnProp.call(to, key) && key !== except)
9
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
+ }
11
+ return to;
12
+ };
13
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var src_exports = {};
16
+ module.exports = __toCommonJS(src_exports);
17
+ __reExport(src_exports, require("./plugin"), module.exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/index.ts"],
4
+ "sourcesContent": ["export * from './plugin'\n"],
5
+ "mappings": ";;;;;;;;;;;;;;AAAA;AAAA;AAAA,wBAAc,qBAAd;",
6
+ "names": []
7
+ }
@@ -0,0 +1,28 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var plugin_exports = {};
19
+ __export(plugin_exports, {
20
+ plugin: () => plugin
21
+ });
22
+ module.exports = __toCommonJS(plugin_exports);
23
+ const plugin = {};
24
+ // Annotate the CommonJS export names for ESM import in node:
25
+ 0 && (module.exports = {
26
+ plugin
27
+ });
28
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/plugin.ts"],
4
+ "sourcesContent": ["export const plugin = {}\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;AAAO,MAAM,SAAS,CAAC;",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./plugin";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/index.ts"],
4
+ "sourcesContent": ["export * from './plugin'\n"],
5
+ "mappings": "AAAA;",
6
+ "names": []
7
+ }
@@ -0,0 +1,5 @@
1
+ const plugin = {};
2
+ export {
3
+ plugin
4
+ };
5
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/plugin.ts"],
4
+ "sourcesContent": ["export const plugin = {}\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": "AAAO,MAAM,SAAS,CAAC;",
6
+ "names": []
7
+ }
@@ -0,0 +1 @@
1
+ export * from "./plugin";
@@ -0,0 +1,4 @@
1
+ const plugin = {};
2
+ export {
3
+ plugin
4
+ };
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "@tamagui/vite-plugin",
3
+ "version": "1.0.1-beta.71",
4
+ "types": "./types/index.d.ts",
5
+ "main": "dist/cjs",
6
+ "module": "dist/esm",
7
+ "module:jsx": "dist/jsx",
8
+ "license": "MIT",
9
+ "files": [
10
+ "src",
11
+ "types",
12
+ "dist"
13
+ ],
14
+ "scripts": {
15
+ "build": "tamagui-build",
16
+ "watch": "tamagui-build --watch",
17
+ "clean": "tamagui-build clean",
18
+ "clean:build": "tamagui-build clean:build"
19
+ },
20
+ "dependencies": {
21
+ "@tamagui/static": "^1.0.1-beta.71",
22
+ "fs-extra": "^9.1.0",
23
+ "lodash": "^4.17.21"
24
+ },
25
+ "devDependencies": {
26
+ "@tamagui/build": "^1.0.1-beta.71"
27
+ },
28
+ "publishConfig": {
29
+ "access": "public"
30
+ }
31
+ }
package/src/index.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './plugin'
package/src/plugin.ts ADDED
@@ -0,0 +1,189 @@
1
+ export const plugin = {}
2
+ // fork from https://github.com/seek-oss/vanilla-extract/blob/master/packages/vite-plugin/src/index.ts
3
+
4
+ // import path from 'path'
5
+
6
+ // import outdent from 'outdent'
7
+ // import type { Plugin, ResolvedConfig, ViteDevServer } from 'vite'
8
+ // import { normalizePath } from 'vite'
9
+
10
+ // const styleUpdateEvent = (fileId: string) => `tamagui-style-update:${fileId}`
11
+
12
+ // interface Options {
13
+ // identifiers?: IdentifierOption
14
+ // esbuildOptions?: CompileOptions['esbuildOptions']
15
+ // }
16
+ // export function vanillaExtractPlugin({ identifiers, esbuildOptions }: Options = {}): Plugin {
17
+ // let config: ResolvedConfig
18
+ // let server: ViteDevServer
19
+ // let postCssConfig: PostCSSConfigResult | null
20
+ // const cssMap = new Map<string, string>()
21
+
22
+ // let virtualExt: string
23
+ // let packageName: string
24
+
25
+ // const getAbsoluteVirtualFileId = (source: string) => normalizePath(path.join(config.root, source))
26
+
27
+ // return {
28
+ // name: 'tamagui',
29
+ // enforce: 'pre',
30
+ // configureServer(_server) {
31
+ // server = _server
32
+ // },
33
+ // config(_userConfig, env) {
34
+ // const include = env.command === 'serve' ? ['@tamagui/css/injectStyles'] : []
35
+
36
+ // return {
37
+ // optimizeDeps: { include },
38
+ // ssr: {
39
+ // external: ['@tamagui/css', '@tamagui/css/fileScope', '@tamagui/css/adapter'],
40
+ // },
41
+ // }
42
+ // },
43
+ // async configResolved(resolvedConfig) {
44
+ // config = resolvedConfig
45
+ // packageName = getPackageInfo(config.root).name
46
+
47
+ // if (config.command === 'serve') {
48
+ // postCssConfig = await resolvePostcssConfig(config)
49
+ // }
50
+
51
+ // virtualExt = `.vanilla.${config.command === 'serve' ? 'js' : 'css'}`
52
+ // },
53
+ // resolveId(source) {
54
+ // if (!source.endsWith(virtualExt)) {
55
+ // return
56
+ // }
57
+
58
+ // // Absolute paths seem to occur often in monorepos, where files are
59
+ // // imported from outside the config root.
60
+ // const absoluteId = source.startsWith(config.root) ? source : getAbsoluteVirtualFileId(source)
61
+
62
+ // // There should always be an entry in the `cssMap` here.
63
+ // // The only valid scenario for a missing one is if someone had written
64
+ // // a file in their app using the .vanilla.js/.vanilla.css extension
65
+ // if (cssMap.has(absoluteId)) {
66
+ // return absoluteId
67
+ // }
68
+ // },
69
+ // load(id) {
70
+ // if (!cssMap.has(id)) {
71
+ // return
72
+ // }
73
+
74
+ // const css = cssMap.get(id)
75
+
76
+ // if (typeof css !== 'string') {
77
+ // return
78
+ // }
79
+
80
+ // if (!server || server.config.isProduction) {
81
+ // return css
82
+ // }
83
+
84
+ // return outdent`
85
+ // import { injectStyles } from '@tamagui/css/injectStyles';
86
+
87
+ // const inject = (css) => injectStyles({
88
+ // fileScope: ${JSON.stringify({ filePath: id })},
89
+ // css
90
+ // });
91
+
92
+ // inject(${JSON.stringify(css)});
93
+
94
+ // import.meta.hot.on('${styleUpdateEvent(id)}', (css) => {
95
+ // inject(css);
96
+ // });
97
+ // `
98
+ // },
99
+ // async transform(code, id, ssrParam) {
100
+ // if (!cssFileFilter.test(id)) {
101
+ // return null
102
+ // }
103
+
104
+ // let ssr: boolean | undefined
105
+
106
+ // if (typeof ssrParam === 'boolean') {
107
+ // ssr = ssrParam
108
+ // } else {
109
+ // ssr = ssrParam?.ssr
110
+ // }
111
+
112
+ // const index = id.indexOf('?')
113
+ // const validId = index === -1 ? id : id.substring(0, index)
114
+
115
+ // if (ssr) {
116
+ // return addFileScope({
117
+ // source: code,
118
+ // filePath: normalizePath(validId),
119
+ // rootPath: config.root,
120
+ // packageName,
121
+ // })
122
+ // }
123
+
124
+ // const { source, watchFiles } = await compile({
125
+ // filePath: validId,
126
+ // cwd: config.root,
127
+ // esbuildOptions,
128
+ // })
129
+
130
+ // for (const file of watchFiles) {
131
+ // // In start mode, we need to prevent the file from rewatching itself.
132
+ // // If it's a `build --watch`, it needs to watch everything.
133
+ // if (config.command === 'build' || file !== id) {
134
+ // this.addWatchFile(file)
135
+ // }
136
+ // }
137
+
138
+ // const output = await processVanillaFile({
139
+ // source,
140
+ // filePath: validId,
141
+ // identOption: identifiers ?? (config.mode === 'production' ? 'short' : 'debug'),
142
+ // serializeVirtualCssPath: async ({ fileScope, source }) => {
143
+ // const rootRelativeId = `${fileScope.filePath}${virtualExt}`
144
+ // const absoluteId = getAbsoluteVirtualFileId(rootRelativeId)
145
+
146
+ // let cssSource = source
147
+
148
+ // if (postCssConfig) {
149
+ // const postCssResult = await (await import('postcss'))
150
+ // .default(postCssConfig.plugins)
151
+ // .process(source, {
152
+ // ...postCssConfig.options,
153
+ // from: undefined,
154
+ // map: false,
155
+ // })
156
+
157
+ // cssSource = postCssResult.css
158
+ // }
159
+
160
+ // if (server && cssMap.has(absoluteId) && cssMap.get(absoluteId) !== source) {
161
+ // const { moduleGraph } = server
162
+ // const module = moduleGraph.getModuleById(absoluteId)
163
+
164
+ // if (module) {
165
+ // moduleGraph.invalidateModule(module)
166
+ // }
167
+
168
+ // server.ws.send({
169
+ // type: 'custom',
170
+ // event: styleUpdateEvent(absoluteId),
171
+ // data: cssSource,
172
+ // })
173
+ // }
174
+
175
+ // cssMap.set(absoluteId, cssSource)
176
+
177
+ // // We use the root relative id here to ensure file contents (content-hashes)
178
+ // // are consistent across build machines
179
+ // return `import "${rootRelativeId}";`
180
+ // },
181
+ // })
182
+
183
+ // return {
184
+ // code: output,
185
+ // map: { mappings: '' },
186
+ // }
187
+ // },
188
+ // }
189
+ // }
@@ -0,0 +1,2 @@
1
+ export * from './plugin';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA"}
@@ -0,0 +1,2 @@
1
+ export declare const plugin: {};
2
+ //# sourceMappingURL=plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,MAAM,IAAK,CAAA"}