@tamagui/vite-plugin-cjs 2.0.0-1768586279389 → 2.0.0-1768696252732
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/extensions.mjs +42 -22
- package/dist/cjs/extensions.native.js +42 -24
- package/dist/cjs/extract.mjs +170 -106
- package/dist/cjs/extract.native.js +192 -121
- package/dist/cjs/index.mjs +28 -17
- package/dist/cjs/index.native.js +28 -19
- package/dist/cjs/loadTamagui.mjs +69 -48
- package/dist/cjs/loadTamagui.native.js +68 -49
- package/dist/cjs/plugin.mjs +211 -157
- package/dist/cjs/plugin.native.js +225 -160
- package/dist/esm/extensions.native.js +13 -2
- package/dist/esm/extract.native.js +139 -89
- package/dist/esm/index.native.js +2 -2
- package/dist/esm/loadTamagui.native.js +22 -17
- package/dist/esm/plugin.native.js +170 -127
- package/package.json +2 -2
package/dist/cjs/extensions.mjs
CHANGED
|
@@ -1,27 +1,47 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty
|
|
1
|
+
var __defProp = Object.defineProperty
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty
|
|
5
5
|
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, {
|
|
8
|
+
get: all[name],
|
|
9
|
+
enumerable: !0,
|
|
10
|
+
})
|
|
10
11
|
},
|
|
11
12
|
__copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from ==
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
13
|
+
if ((from && typeof from == 'object') || typeof from == 'function')
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
!__hasOwnProp.call(to, key) &&
|
|
16
|
+
key !== except &&
|
|
17
|
+
__defProp(to, key, {
|
|
18
|
+
get: () => from[key],
|
|
19
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
|
|
20
|
+
})
|
|
21
|
+
return to
|
|
22
|
+
}
|
|
23
|
+
var __toCommonJS = (mod) =>
|
|
24
|
+
__copyProps(
|
|
25
|
+
__defProp({}, '__esModule', {
|
|
26
|
+
value: !0,
|
|
27
|
+
}),
|
|
28
|
+
mod
|
|
29
|
+
)
|
|
30
|
+
var extensions_exports = {}
|
|
22
31
|
__export(extensions_exports, {
|
|
23
|
-
extensions: () => extensions
|
|
24
|
-
})
|
|
25
|
-
module.exports = __toCommonJS(extensions_exports)
|
|
26
|
-
const extensions = [
|
|
32
|
+
extensions: () => extensions,
|
|
33
|
+
})
|
|
34
|
+
module.exports = __toCommonJS(extensions_exports)
|
|
35
|
+
const extensions = [
|
|
36
|
+
'.ios.js',
|
|
37
|
+
'.native.js',
|
|
38
|
+
'.native.ts',
|
|
39
|
+
'.native.tsx',
|
|
40
|
+
'.js',
|
|
41
|
+
'.jsx',
|
|
42
|
+
'.json',
|
|
43
|
+
'.ts',
|
|
44
|
+
'.tsx',
|
|
45
|
+
'.mjs',
|
|
46
|
+
]
|
|
27
47
|
//# sourceMappingURL=extensions.mjs.map
|
|
@@ -1,29 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
1
|
+
var __defProp = Object.defineProperty
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty
|
|
7
5
|
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, {
|
|
8
|
+
get: all[name],
|
|
9
|
+
enumerable: !0,
|
|
10
|
+
})
|
|
12
11
|
},
|
|
13
12
|
__copyProps = (to, from, except, desc) => {
|
|
14
|
-
if (from && typeof from ==
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
13
|
+
if ((from && typeof from == 'object') || typeof from == 'function')
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
!__hasOwnProp.call(to, key) &&
|
|
16
|
+
key !== except &&
|
|
17
|
+
__defProp(to, key, {
|
|
18
|
+
get: () => from[key],
|
|
19
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
|
|
20
|
+
})
|
|
21
|
+
return to
|
|
22
|
+
}
|
|
23
|
+
var __toCommonJS = (mod) =>
|
|
24
|
+
__copyProps(
|
|
25
|
+
__defProp({}, '__esModule', {
|
|
26
|
+
value: !0,
|
|
27
|
+
}),
|
|
28
|
+
mod
|
|
29
|
+
)
|
|
30
|
+
var extensions_exports = {}
|
|
24
31
|
__export(extensions_exports, {
|
|
25
|
-
extensions: () => extensions
|
|
26
|
-
})
|
|
27
|
-
module.exports = __toCommonJS(extensions_exports)
|
|
28
|
-
var extensions = [
|
|
32
|
+
extensions: () => extensions,
|
|
33
|
+
})
|
|
34
|
+
module.exports = __toCommonJS(extensions_exports)
|
|
35
|
+
var extensions = [
|
|
36
|
+
'.ios.js',
|
|
37
|
+
'.native.js',
|
|
38
|
+
'.native.ts',
|
|
39
|
+
'.native.tsx',
|
|
40
|
+
'.js',
|
|
41
|
+
'.jsx',
|
|
42
|
+
'.json',
|
|
43
|
+
'.ts',
|
|
44
|
+
'.tsx',
|
|
45
|
+
'.mjs',
|
|
46
|
+
]
|
|
29
47
|
//# sourceMappingURL=extensions.native.js.map
|
package/dist/cjs/extract.mjs
CHANGED
|
@@ -1,97 +1,132 @@
|
|
|
1
|
-
var __create = Object.create
|
|
2
|
-
var __defProp = Object.defineProperty
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames
|
|
1
|
+
var __create = Object.create
|
|
2
|
+
var __defProp = Object.defineProperty
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames
|
|
5
5
|
var __getProtoOf = Object.getPrototypeOf,
|
|
6
|
-
__hasOwnProp = Object.prototype.hasOwnProperty
|
|
6
|
+
__hasOwnProp = Object.prototype.hasOwnProperty
|
|
7
7
|
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, {
|
|
10
|
+
get: all[name],
|
|
11
|
+
enumerable: !0,
|
|
12
|
+
})
|
|
12
13
|
},
|
|
13
14
|
__copyProps = (to, from, except, desc) => {
|
|
14
|
-
if (from && typeof from ==
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
15
|
+
if ((from && typeof from == 'object') || typeof from == 'function')
|
|
16
|
+
for (let key of __getOwnPropNames(from))
|
|
17
|
+
!__hasOwnProp.call(to, key) &&
|
|
18
|
+
key !== except &&
|
|
19
|
+
__defProp(to, key, {
|
|
20
|
+
get: () => from[key],
|
|
21
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
|
|
22
|
+
})
|
|
23
|
+
return to
|
|
24
|
+
}
|
|
25
|
+
var __toESM = (mod, isNodeMode, target) => (
|
|
26
|
+
(target = mod != null ? __create(__getProtoOf(mod)) : {}),
|
|
27
|
+
__copyProps(
|
|
28
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
29
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
30
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
31
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
32
|
+
isNodeMode || !mod || !mod.__esModule
|
|
33
|
+
? __defProp(target, 'default', {
|
|
34
|
+
value: mod,
|
|
35
|
+
enumerable: !0,
|
|
36
|
+
})
|
|
37
|
+
: target,
|
|
38
|
+
mod
|
|
39
|
+
)
|
|
40
|
+
),
|
|
41
|
+
__toCommonJS = (mod) =>
|
|
42
|
+
__copyProps(
|
|
43
|
+
__defProp({}, '__esModule', {
|
|
44
|
+
value: !0,
|
|
45
|
+
}),
|
|
46
|
+
mod
|
|
47
|
+
)
|
|
48
|
+
var extract_exports = {}
|
|
33
49
|
__export(extract_exports, {
|
|
34
|
-
tamaguiExtractPlugin: () => tamaguiExtractPlugin
|
|
35
|
-
})
|
|
36
|
-
module.exports = __toCommonJS(extract_exports)
|
|
37
|
-
var Static = __toESM(require(
|
|
38
|
-
import_static_worker = require(
|
|
39
|
-
import_node_path = __toESM(require(
|
|
40
|
-
import_vite = require(
|
|
41
|
-
import_loadTamagui = require(
|
|
42
|
-
import_node_crypto = require(
|
|
50
|
+
tamaguiExtractPlugin: () => tamaguiExtractPlugin,
|
|
51
|
+
})
|
|
52
|
+
module.exports = __toCommonJS(extract_exports)
|
|
53
|
+
var Static = __toESM(require('@tamagui/static-worker'), 1),
|
|
54
|
+
import_static_worker = require('@tamagui/static-worker'),
|
|
55
|
+
import_node_path = __toESM(require('node:path'), 1),
|
|
56
|
+
import_vite = require('vite'),
|
|
57
|
+
import_loadTamagui = require('./loadTamagui.mjs'),
|
|
58
|
+
import_node_crypto = require('node:crypto')
|
|
43
59
|
function tamaguiExtractPlugin(optionsIn) {
|
|
44
|
-
if (optionsIn?.disable)
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
60
|
+
if (optionsIn?.disable)
|
|
61
|
+
return {
|
|
62
|
+
name: 'tamagui-extract',
|
|
63
|
+
}
|
|
64
|
+
const getHash = (input) =>
|
|
65
|
+
(0, import_node_crypto.createHash)('sha1').update(input).digest('base64'),
|
|
48
66
|
clearCompilerCache = () => {
|
|
49
|
-
memoryCache = {}, cacheSize = 0
|
|
50
|
-
}
|
|
67
|
+
;(memoryCache = {}), (cacheSize = 0)
|
|
68
|
+
}
|
|
51
69
|
let memoryCache = {},
|
|
52
|
-
cacheSize = 0
|
|
53
|
-
const cssMap = /* @__PURE__ */new Map()
|
|
54
|
-
let config, server
|
|
55
|
-
const virtualExt =
|
|
56
|
-
getAbsoluteVirtualFileId =
|
|
70
|
+
cacheSize = 0
|
|
71
|
+
const cssMap = /* @__PURE__ */ new Map()
|
|
72
|
+
let config, server
|
|
73
|
+
const virtualExt = '.tamagui.css',
|
|
74
|
+
getAbsoluteVirtualFileId = (filePath) =>
|
|
75
|
+
filePath.startsWith(config.root)
|
|
76
|
+
? filePath
|
|
77
|
+
: (0, import_vite.normalizePath)(
|
|
78
|
+
import_node_path.default.join(config.root, filePath)
|
|
79
|
+
)
|
|
57
80
|
function isVite6AndNotClient(environment) {
|
|
58
|
-
return environment?.name && environment.name !==
|
|
81
|
+
return environment?.name && environment.name !== 'client'
|
|
59
82
|
}
|
|
60
83
|
function isVite6Native(environment) {
|
|
61
|
-
return
|
|
84
|
+
return (
|
|
85
|
+
environment?.name && (environment.name === 'ios' || environment.name === 'android')
|
|
86
|
+
)
|
|
62
87
|
}
|
|
63
88
|
function invalidateModule(absoluteId) {
|
|
64
|
-
if (!server) return
|
|
65
|
-
const {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
89
|
+
if (!server) return
|
|
90
|
+
const { moduleGraph } = server,
|
|
91
|
+
modules = moduleGraph.getModulesByFile(absoluteId)
|
|
92
|
+
if (modules)
|
|
93
|
+
for (const module2 of modules)
|
|
94
|
+
moduleGraph.invalidateModule(module2),
|
|
95
|
+
(module2.lastHMRTimestamp = module2.lastInvalidationTimestamp || Date.now())
|
|
70
96
|
}
|
|
71
97
|
return {
|
|
72
|
-
name:
|
|
73
|
-
enforce:
|
|
98
|
+
name: 'tamagui-extract',
|
|
99
|
+
enforce: 'pre',
|
|
74
100
|
configureServer(_server) {
|
|
75
|
-
server = _server
|
|
101
|
+
server = _server
|
|
76
102
|
},
|
|
77
103
|
async buildStart() {
|
|
78
|
-
await (0, import_loadTamagui.loadTamaguiBuildConfig)(optionsIn)
|
|
104
|
+
await (0, import_loadTamagui.loadTamaguiBuildConfig)(optionsIn)
|
|
79
105
|
},
|
|
80
106
|
async closeBundle() {
|
|
81
|
-
await Static?.destroyPool()
|
|
107
|
+
await Static?.destroyPool()
|
|
82
108
|
},
|
|
83
109
|
config(userConf) {
|
|
84
|
-
userConf.optimizeDeps ||= {},
|
|
110
|
+
;(userConf.optimizeDeps ||= {}),
|
|
111
|
+
(userConf.optimizeDeps.include ||= []),
|
|
112
|
+
userConf.optimizeDeps.include.push('@tamagui/core/inject-styles')
|
|
85
113
|
},
|
|
86
114
|
async configResolved(resolvedConfig) {
|
|
87
|
-
config = resolvedConfig
|
|
115
|
+
config = resolvedConfig
|
|
88
116
|
},
|
|
89
117
|
async resolveId(source) {
|
|
90
|
-
if (
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
118
|
+
if (
|
|
119
|
+
isVite6Native(this.environment) ||
|
|
120
|
+
(import_loadTamagui.tamaguiOptions?.disableServerOptimization &&
|
|
121
|
+
isVite6AndNotClient(this.environment))
|
|
122
|
+
)
|
|
123
|
+
return
|
|
124
|
+
const [validId, query] = source.split('?')
|
|
125
|
+
if (!validId.endsWith(virtualExt)) return
|
|
126
|
+
const absoluteId = source.startsWith(config.root)
|
|
127
|
+
? source
|
|
128
|
+
: getAbsoluteVirtualFileId(validId)
|
|
129
|
+
if (cssMap.has(absoluteId)) return absoluteId + (query ? `?${query}` : '')
|
|
95
130
|
},
|
|
96
131
|
/**
|
|
97
132
|
* TODO
|
|
@@ -101,62 +136,91 @@ function tamaguiExtractPlugin(optionsIn) {
|
|
|
101
136
|
*
|
|
102
137
|
*/
|
|
103
138
|
async load(id) {
|
|
104
|
-
if (
|
|
105
|
-
|
|
106
|
-
|
|
139
|
+
if (
|
|
140
|
+
import_loadTamagui.disableStatic ||
|
|
141
|
+
isVite6Native(this.environment) ||
|
|
142
|
+
(import_loadTamagui.tamaguiOptions?.disableServerOptimization &&
|
|
143
|
+
isVite6AndNotClient(this.environment))
|
|
144
|
+
)
|
|
145
|
+
return
|
|
146
|
+
const [validId] = id.split('?')
|
|
147
|
+
return cssMap.get(validId)
|
|
107
148
|
},
|
|
108
149
|
transform: {
|
|
109
|
-
order:
|
|
150
|
+
order: 'pre',
|
|
110
151
|
async handler(code, id) {
|
|
111
|
-
if (
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}
|
|
122
|
-
|
|
152
|
+
if (
|
|
153
|
+
import_loadTamagui.disableStatic ||
|
|
154
|
+
isVite6Native(this.environment) ||
|
|
155
|
+
(import_loadTamagui.tamaguiOptions?.disableServerOptimization &&
|
|
156
|
+
isVite6AndNotClient(this.environment))
|
|
157
|
+
)
|
|
158
|
+
return
|
|
159
|
+
const [validId] = id.split('?')
|
|
160
|
+
if (!validId.endsWith('.tsx')) return
|
|
161
|
+
const firstCommentIndex = code.indexOf('// '),
|
|
162
|
+
{ shouldDisable, shouldPrintDebug } = await (0,
|
|
163
|
+
import_static_worker.getPragmaOptions)({
|
|
164
|
+
source: firstCommentIndex >= 0 ? code.slice(firstCommentIndex) : '',
|
|
165
|
+
path: validId,
|
|
166
|
+
})
|
|
167
|
+
if (
|
|
168
|
+
(shouldPrintDebug &&
|
|
169
|
+
(console.trace(
|
|
170
|
+
`Current file: ${id} in environment: ${this.environment?.name}, shouldDisable: ${shouldDisable}`
|
|
171
|
+
),
|
|
172
|
+
console.info(`
|
|
123
173
|
|
|
124
174
|
Original source:
|
|
125
175
|
${code}
|
|
126
176
|
|
|
127
|
-
`)),
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
177
|
+
`)),
|
|
178
|
+
shouldDisable)
|
|
179
|
+
)
|
|
180
|
+
return
|
|
181
|
+
const cacheEnv =
|
|
182
|
+
this.environment.name === 'client' || this.environment.name === 'ssr'
|
|
183
|
+
? // same cache key for ssr and web since they are the same
|
|
184
|
+
'web'
|
|
185
|
+
: this.environment.name,
|
|
131
186
|
cacheKey = getHash(`${cacheEnv}${code}${id}`),
|
|
132
|
-
cached = memoryCache[cacheKey]
|
|
133
|
-
if (cached) return cached
|
|
134
|
-
let extracted
|
|
187
|
+
cached = memoryCache[cacheKey]
|
|
188
|
+
if (cached) return cached
|
|
189
|
+
let extracted
|
|
135
190
|
try {
|
|
136
191
|
extracted = await Static.extractToClassNames({
|
|
137
192
|
source: code,
|
|
138
193
|
sourcePath: validId,
|
|
139
194
|
options: import_loadTamagui.tamaguiOptions,
|
|
140
|
-
shouldPrintDebug
|
|
141
|
-
})
|
|
195
|
+
shouldPrintDebug,
|
|
196
|
+
})
|
|
142
197
|
} catch (err) {
|
|
143
|
-
console.error(err instanceof Error ? err.message : String(err))
|
|
144
|
-
return
|
|
198
|
+
console.error(err instanceof Error ? err.message : String(err))
|
|
199
|
+
return
|
|
145
200
|
}
|
|
146
|
-
if (!extracted) return
|
|
201
|
+
if (!extracted) return
|
|
147
202
|
const rootRelativeId = `${validId}${virtualExt}`,
|
|
148
|
-
absoluteId = getAbsoluteVirtualFileId(rootRelativeId)
|
|
149
|
-
let source = extracted.js
|
|
150
|
-
extracted.styles &&
|
|
151
|
-
|
|
203
|
+
absoluteId = getAbsoluteVirtualFileId(rootRelativeId)
|
|
204
|
+
let source = extracted.js
|
|
205
|
+
extracted.styles &&
|
|
206
|
+
(this.addWatchFile(rootRelativeId),
|
|
207
|
+
server && cssMap.has(absoluteId) && invalidateModule(rootRelativeId),
|
|
208
|
+
(source = `${source}
|
|
209
|
+
import "${rootRelativeId}";`),
|
|
210
|
+
cssMap.set(absoluteId, extracted.styles))
|
|
152
211
|
const codeOut = source.toString(),
|
|
153
212
|
out = {
|
|
154
213
|
code: codeOut,
|
|
155
|
-
map: extracted.map
|
|
156
|
-
}
|
|
157
|
-
return
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
214
|
+
map: extracted.map,
|
|
215
|
+
}
|
|
216
|
+
return (
|
|
217
|
+
(cacheSize += codeOut.length),
|
|
218
|
+
cacheSize > 26214400 && clearCompilerCache(),
|
|
219
|
+
(memoryCache[cacheKey] = out),
|
|
220
|
+
out
|
|
221
|
+
)
|
|
222
|
+
},
|
|
223
|
+
},
|
|
224
|
+
}
|
|
161
225
|
}
|
|
162
226
|
//# sourceMappingURL=extract.mjs.map
|