@stacksjs/defaults 0.70.102 → 0.70.104

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
@@ -2,7 +2,7 @@
2
2
  "name": "@stacksjs/defaults",
3
3
  "type": "module",
4
4
  "sideEffects": false,
5
- "version": "0.70.102",
5
+ "version": "0.70.104",
6
6
  "description": "Default Stacks scaffold resources (views, layouts, components, preloader) — shipped so apps consuming the framework from node_modules get the same fallback resources a vendored checkout provides. Source of truth: storage/framework/defaults.",
7
7
  "author": "Chris Breuer",
8
8
  "license": "MIT",
@@ -36,7 +36,13 @@ const fastCommands = [
36
36
  'scaffold:crud',
37
37
  ]
38
38
  const isRepl = !process.argv[1]
39
- const skipPreloader = isRepl || (args.length > 0 && fastCommands.some(cmd => args[0] === cmd || args[0].startsWith(`${cmd}:`)))
39
+ // Dependency installation runs package lifecycle scripts before Bun has finished
40
+ // linking every workspace package. Loading @stacksjs/env (or the wider auto-import
41
+ // graph) from a postinstall script can therefore fail even though the install is
42
+ // otherwise valid. Postinstall scripts are bootstrap work and must stay independent
43
+ // of the application runtime preloader.
44
+ const isPostinstall = process.env.npm_lifecycle_event === 'postinstall'
45
+ const skipPreloader = isRepl || isPostinstall || (args.length > 0 && fastCommands.some(cmd => args[0] === cmd || args[0].startsWith(`${cmd}:`)))
40
46
 
41
47
  if (!skipPreloader) {
42
48
  // Detect production/deployment commands and set environment accordingly BEFORE loading env files
@@ -66,8 +72,15 @@ if (!skipPreloader) {
66
72
  process.env.NODE_ENV = 'production'
67
73
  }
68
74
 
69
- // Load .env files with encryption support using our native Bun plugin
70
- const { autoLoadEnv } = await import('@stacksjs/env')
75
+ // Load .env files with encryption support using the vendored source first.
76
+ // The preloader runs before Bun has necessarily linked workspace packages
77
+ // (fresh installs and minimal Linux/Docker checkouts are the important
78
+ // cases), so resolving @stacksjs/env here creates a bootstrap cycle. The
79
+ // source plugin is self-contained; retain the package fallback for contexts
80
+ // where defaults is consumed outside the standard framework layout.
81
+ const envPackage = '@stacksjs/' + 'env'
82
+ const { autoLoadEnv } = await import('../../../core/env/src/plugin.ts')
83
+ .catch(() => import(envPackage))
71
84
 
72
85
  // Auto-load .env files based on environment
73
86
  // Set quiet: true to prevent duplicate logging across multiple processes