@tamagui/static 3.0.0-beta.755.1 → 3.0.0-beta.804.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/static",
3
- "version": "3.0.0-beta.755.1",
3
+ "version": "3.0.0-beta.804.1",
4
4
  "gitHead": "a49cc7ea6b93ba384e77a4880ae48ac4a5635c14",
5
5
  "license": "MIT",
6
6
  "source": "src/index.ts",
@@ -39,27 +39,27 @@
39
39
  "access": "public"
40
40
  },
41
41
  "scripts": {
42
- "build": "tamagui-build --skip-native",
43
- "watch": "tamagui-build --skip-native --watch",
42
+ "build": "tamagui-build --skip-native --keep-env-target",
43
+ "watch": "tamagui-build --skip-native --keep-env-target --watch",
44
44
  "clean": "tamagui-build clean",
45
45
  "clean:build": "tamagui-build clean:build"
46
46
  },
47
47
  "dependencies": {
48
- "@tamagui/cli-color": "3.0.0-beta.755.1",
49
- "@tamagui/compiler-core": "3.0.0-beta.755.1",
50
- "@tamagui/config-default": "3.0.0-beta.755.1",
51
- "@tamagui/core": "3.0.0-beta.755.1",
52
- "@tamagui/dom": "3.0.0-beta.755.1",
53
- "@tamagui/fake-react-native": "3.0.0-beta.755.1",
54
- "@tamagui/generate-themes": "3.0.0-beta.755.1",
55
- "@tamagui/helpers": "3.0.0-beta.755.1",
56
- "@tamagui/helpers-node": "3.0.0-beta.755.1",
57
- "@tamagui/react-native-web-internals": "3.0.0-beta.755.1",
58
- "@tamagui/react-native-web-lite": "3.0.0-beta.755.1",
59
- "@tamagui/shorthands": "3.0.0-beta.755.1",
60
- "@tamagui/style-grammar": "3.0.0-beta.755.1",
61
- "@tamagui/types": "3.0.0-beta.755.1",
62
- "@tamagui/web": "3.0.0-beta.755.1",
48
+ "@tamagui/cli-color": "3.0.0-beta.804.1",
49
+ "@tamagui/compiler-core": "3.0.0-beta.804.1",
50
+ "@tamagui/config-default": "3.0.0-beta.804.1",
51
+ "@tamagui/core": "3.0.0-beta.804.1",
52
+ "@tamagui/dom": "3.0.0-beta.804.1",
53
+ "@tamagui/fake-react-native": "3.0.0-beta.804.1",
54
+ "@tamagui/generate-themes": "3.0.0-beta.804.1",
55
+ "@tamagui/helpers": "3.0.0-beta.804.1",
56
+ "@tamagui/helpers-node": "3.0.0-beta.804.1",
57
+ "@tamagui/react-native-web-internals": "3.0.0-beta.804.1",
58
+ "@tamagui/react-native-web-lite": "3.0.0-beta.804.1",
59
+ "@tamagui/shorthands": "3.0.0-beta.804.1",
60
+ "@tamagui/style-grammar": "3.0.0-beta.804.1",
61
+ "@tamagui/types": "3.0.0-beta.804.1",
62
+ "@tamagui/web": "3.0.0-beta.804.1",
63
63
  "browserslist": "^4.28.1",
64
64
  "check-dependency-version-consistency": "^4.1.0",
65
65
  "esbuild": "0.28.1",
@@ -71,7 +71,7 @@
71
71
  "react-native-web": "~0.21.0"
72
72
  },
73
73
  "devDependencies": {
74
- "@tamagui/build": "3.0.0-beta.755.1",
74
+ "@tamagui/build": "3.0.0-beta.804.1",
75
75
  "@types/find-root": "^1.1.2",
76
76
  "@types/node": "^22.1.0",
77
77
  "@types/webpack": "^4.41.26",
package/src/compiler.ts CHANGED
@@ -212,12 +212,14 @@ export interface CompilerInput {
212
212
  source: string
213
213
  root: string
214
214
  target: CompilerTarget
215
+ /** Host environment whose resolver produced this module graph. */
216
+ environment?: string
215
217
  project: CompilerProject
216
218
  resolve(specifier: string, importer: string): Promise<CompilerResolution | null>
217
219
  load(id: string): Promise<string | null>
218
220
  }
219
221
 
220
- export type CompilerUpdateInput = Omit<CompilerInput, 'target'>
222
+ export type CompilerUpdateInput = CompilerInput
221
223
 
222
224
  export interface CompilerResult {
223
225
  plan: LoweredModulePlan
@@ -233,6 +235,10 @@ function externalId(specifier: string): ResolvedModuleId {
233
235
  return resolvedModuleId(`external://${encodeURIComponent(specifier)}`)
234
236
  }
235
237
 
238
+ function compilerContext(input: CompilerInput): string {
239
+ return `${input.root}\0${input.target}\0${input.environment ?? ''}\0${input.project.generation}`
240
+ }
241
+
236
242
  function sourceCanBeLinked(root: string, id: string): boolean {
237
243
  const clean = cleanId(id)
238
244
  const normalized = clean.replace(/\\/g, '/')
@@ -249,6 +255,8 @@ export class CompilerFrontend {
249
255
  private readonly session = new CompilerSession()
250
256
  private queue: Promise<unknown> = Promise.resolve()
251
257
  private readonly planCaches = new Map<string, ModulePlanCache>()
258
+ private readonly moduleRecords = new Map<ResolvedModuleId, HostModuleInput>()
259
+ private moduleContext: string | null = null
252
260
 
253
261
  /**
254
262
  * One cache per project root and platform. Absent when the project produced
@@ -281,7 +289,22 @@ export class CompilerFrontend {
281
289
  }
282
290
 
283
291
  compile(input: CompilerInput): Promise<CompilerResult> {
284
- const operation = this.queue.then(() => this.compileNow(input))
292
+ // compiling must not leak process-global state: internal stages set
293
+ // TAMAGUI_TARGET / IS_STATIC while evaluating modules for a platform, and
294
+ // an embedder (or a test that renders at runtime after compiling) must see
295
+ // its own environment unchanged afterward
296
+ const operation = this.queue.then(async () => {
297
+ const previousTarget = process.env.TAMAGUI_TARGET
298
+ const previousStatic = process.env.IS_STATIC
299
+ try {
300
+ return await this.compileNow(input)
301
+ } finally {
302
+ if (previousTarget === undefined) delete process.env.TAMAGUI_TARGET
303
+ else process.env.TAMAGUI_TARGET = previousTarget
304
+ if (previousStatic === undefined) delete process.env.IS_STATIC
305
+ else process.env.IS_STATIC = previousStatic
306
+ }
307
+ })
285
308
  this.queue = operation.catch(() => undefined)
286
309
  return operation
287
310
  }
@@ -292,6 +315,7 @@ export class CompilerFrontend {
292
315
  const invalidated = new Set<ResolvedModuleId>()
293
316
  for (const module of modules.values()) {
294
317
  for (const id of await this.session.update(module)) invalidated.add(id)
318
+ this.moduleRecords.set(module.id, module)
295
319
  }
296
320
  return [...invalidated].sort()
297
321
  })
@@ -308,9 +332,13 @@ export class CompilerFrontend {
308
332
  }
309
333
 
310
334
  remove(id: string) {
311
- const operation = this.queue.then(() =>
312
- this.session.remove(resolvedModuleId(cleanId(id)))
313
- )
335
+ const operation = this.queue.then(async () => {
336
+ const result = await this.session.remove(resolvedModuleId(cleanId(id)))
337
+ for (const invalidatedId of result.invalidatedIds) {
338
+ this.moduleRecords.delete(invalidatedId)
339
+ }
340
+ return result
341
+ })
314
342
  this.queue = operation.catch(() => undefined)
315
343
  return operation
316
344
  }
@@ -324,6 +352,7 @@ export class CompilerFrontend {
324
352
  const invalidated = new Set<ResolvedModuleId>()
325
353
  for (const module of modules.values()) {
326
354
  for (const id of await this.session.update(module)) invalidated.add(id)
355
+ this.moduleRecords.set(module.id, module)
327
356
  }
328
357
  const projectInfo = input.project.projectInfo
329
358
  if (!projectInfo.tamaguiConfig || !projectInfo.components) {
@@ -366,6 +395,12 @@ export class CompilerFrontend {
366
395
  rootModule: HostModuleInput
367
396
  modules: Map<ResolvedModuleId, HostModuleInput>
368
397
  }> {
398
+ const moduleContext = compilerContext(input)
399
+ if (this.moduleContext !== moduleContext) {
400
+ this.moduleRecords.clear()
401
+ this.moduleContext = moduleContext
402
+ }
403
+
369
404
  const componentBySpecifier = new Map(
370
405
  input.project.componentModules.map((component) => [
371
406
  component.moduleName,
@@ -375,6 +410,20 @@ export class CompilerFrontend {
375
410
  const modules = new Map<ResolvedModuleId, HostModuleInput>()
376
411
  const loading = new Set<ResolvedModuleId>()
377
412
 
413
+ const addInstalledClosure = (module: HostModuleInput): void => {
414
+ if (modules.has(module.id) || loading.has(module.id)) return
415
+ loading.add(module.id)
416
+ for (const dependency of module.imports) {
417
+ if (dependency.external) continue
418
+ const installedDependency = this.moduleRecords.get(dependency.resolvedId)
419
+ if (installedDependency && this.session.has(dependency.resolvedId)) {
420
+ addInstalledClosure(installedDependency)
421
+ }
422
+ }
423
+ modules.set(module.id, module)
424
+ loading.delete(module.id)
425
+ }
426
+
378
427
  const loadModule = async (
379
428
  rawId: string,
380
429
  source: string
@@ -382,6 +431,11 @@ export class CompilerFrontend {
382
431
  const id = resolvedModuleId(cleanId(rawId))
383
432
  const existing = modules.get(id)
384
433
  if (existing) return existing
434
+ const installed = this.moduleRecords.get(id)
435
+ if (installed?.source === source && this.session.has(id)) {
436
+ addInstalledClosure(installed)
437
+ return installed
438
+ }
385
439
  if (loading.has(id)) {
386
440
  return { id, source, imports: [] }
387
441
  }
@@ -406,9 +460,14 @@ export class CompilerFrontend {
406
460
  : externalId(specifier)
407
461
  imports.push({ specifier, resolvedId, external: !canLink })
408
462
  if (canLink && !modules.has(resolvedId) && !loading.has(resolvedId)) {
409
- const dependencySource = await input.load(resolution.id)
410
- if (dependencySource !== null) {
411
- await loadModule(resolution.id, dependencySource)
463
+ const installedDependency = this.moduleRecords.get(resolvedId)
464
+ if (installedDependency && this.session.has(resolvedId)) {
465
+ addInstalledClosure(installedDependency)
466
+ } else {
467
+ const dependencySource = await input.load(resolution.id)
468
+ if (dependencySource !== null) {
469
+ await loadModule(resolution.id, dependencySource)
470
+ }
412
471
  }
413
472
  }
414
473
  }