@ecomiq/storefront 2.0.1 → 2.0.3

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": "@ecomiq/storefront",
3
- "version": "2.0.1",
3
+ "version": "2.0.3",
4
4
  "description": "Micro framework SSR de Ecomiq para storefronts. Páginas, datos y deploy sin configurar nada.",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/codegen.mjs CHANGED
@@ -631,7 +631,7 @@ function resolvePackageDir(packageName, fromFiles) {
631
631
  try {
632
632
  const require = createRequire(fromFile)
633
633
  try {
634
- return dirname(realpathSync(require.resolve(`${packageName}/package.json`)))
634
+ return dirname(require.resolve(`${packageName}/package.json`))
635
635
  } catch {
636
636
  const entry = require.resolve(packageName)
637
637
  return findPackageRoot(entry, packageName)
@@ -650,7 +650,7 @@ function findPackageRoot(startPath, packageName) {
650
650
  if (existsSync(pkgPath)) {
651
651
  try {
652
652
  const pkg = JSON.parse(readFileSync(pkgPath, 'utf8'))
653
- if (pkg.name === packageName) return realpathSync(dir)
653
+ if (pkg.name === packageName) return dir
654
654
  } catch {
655
655
  /* ignore */
656
656
  }
@@ -664,12 +664,16 @@ function findPackageRoot(startPath, packageName) {
664
664
  function linkInto(dir, name, targetPath) {
665
665
  mkdirSync(dir, { recursive: true })
666
666
  const linkPath = join(dir, name)
667
- let desired
667
+
668
+ // Target absoluto y ya resuelto: los symlinks relativos se rompen cuando un
669
+ // directorio padre es a su vez un symlink (p. ej. /var → /private/var en macOS).
670
+ let destination
668
671
  try {
669
- desired = realpathSync(targetPath)
672
+ destination = realpathSync(targetPath)
670
673
  } catch {
671
- desired = resolve(targetPath)
674
+ destination = resolve(targetPath)
672
675
  }
676
+
673
677
  try {
674
678
  const current = lstatSync(linkPath)
675
679
  if (current.isSymbolicLink()) {
@@ -679,7 +683,7 @@ function linkInto(dir, name, targetPath) {
679
683
  } catch {
680
684
  resolved = resolve(dir, readlinkSync(linkPath))
681
685
  }
682
- if (resolved === desired) return
686
+ if (resolved === destination) return
683
687
  unlinkSync(linkPath)
684
688
  } else if (current.isDirectory() || current.isFile()) {
685
689
  return
@@ -688,7 +692,7 @@ function linkInto(dir, name, targetPath) {
688
692
  /* no existe aún */
689
693
  }
690
694
  try {
691
- symlinkSync(desired, linkPath, 'junction')
695
+ symlinkSync(destination, linkPath, 'junction')
692
696
  } catch {
693
697
  /* FS sin symlinks: la resolución cae al hoisting */
694
698
  }
@@ -4,7 +4,6 @@
4
4
  * los plugins se importan aquí (contexto del framework) y se pasan como
5
5
  * instancias, así la resolución de módulos nunca depende del proyecto.
6
6
  */
7
- import { createRequire } from 'node:module'
8
7
  import { dirname, resolve } from 'node:path'
9
8
  import { fileURLToPath } from 'node:url'
10
9
  import { tanstackStart } from '@tanstack/react-start/plugin/vite'
@@ -18,6 +17,28 @@ const postcssBrowserStub = fileURLToPath(
18
17
 
19
18
  const frameworkRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..')
20
19
 
20
+ /** Packages que workerd debe ver como ESM (sin prebundle CJS con `require`). */
21
+ const SSR_NO_EXTERNAL = [
22
+ '@tanstack/react-start',
23
+ '@tanstack/react-router',
24
+ '@tanstack/react-query',
25
+ '@tanstack/router-core',
26
+ '@tanstack/history',
27
+ '@tanstack/react-store',
28
+ '@tanstack/start-server-core',
29
+ '@tanstack/start-client-core',
30
+ '@tanstack/start-storage-context',
31
+ '@ecomiq/storefront',
32
+ '@ecomiq/core',
33
+ ]
34
+
35
+ const OPTIMIZE_EXCLUDE = [
36
+ '@tanstack/react-start',
37
+ '@tanstack/start-server-core',
38
+ '@tanstack/start-client-core',
39
+ '@tanstack/react-router',
40
+ ]
41
+
21
42
  function resolveSanitizeHtmlPostcss(source, importer) {
22
43
  if (source !== 'postcss') return null
23
44
  if (!importer?.includes('/sanitize-html/')) return null
@@ -53,26 +74,15 @@ function sanitizeHtmlClientBoundary() {
53
74
  }
54
75
  }
55
76
 
56
- function resolveFrameworkPackage(name) {
57
- try {
58
- const require = createRequire(resolve(frameworkRoot, 'package.json'))
59
- return dirname(require.resolve(`${name}/package.json`))
60
- } catch {
61
- return null
62
- }
63
- }
64
-
65
77
  export function createViteConfig({ appDir, config, projectRoot }) {
66
78
  const root = projectRoot ?? resolve(appDir, '..')
67
- const reactStartRoot = resolveFrameworkPackage('@tanstack/react-start')
68
- const allow = new Set([
79
+ const allow = [
69
80
  '..',
70
81
  root,
71
82
  frameworkRoot,
72
83
  resolve(appDir, 'node_modules'),
73
84
  resolve(root, 'node_modules'),
74
- ])
75
- if (reactStartRoot) allow.add(reactStartRoot)
85
+ ]
76
86
 
77
87
  return {
78
88
  root: appDir,
@@ -86,14 +96,15 @@ export function createViteConfig({ appDir, config, projectRoot }) {
86
96
  '@tanstack/react-start',
87
97
  '@tanstack/react-query',
88
98
  ],
89
- ...(reactStartRoot
90
- ? {
91
- alias: {
92
- // Asegura subpaths (`/server-entry`) cuando workerd no hereda el hoisting.
93
- '@tanstack/react-start': reactStartRoot,
94
- },
95
- }
96
- : {}),
99
+ },
100
+ // Bundlear TanStack en SSR (no externalizar) evita `file://` de pnpm y
101
+ // mantiene ESM. No usar optimizeDeps.include: el prebundle mete `require`
102
+ // y workerd (ESM) falla con "require is not defined".
103
+ ssr: {
104
+ noExternal: [...SSR_NO_EXTERNAL],
105
+ },
106
+ optimizeDeps: {
107
+ exclude: [...OPTIMIZE_EXCLUDE],
97
108
  },
98
109
  plugins: [
99
110
  tailwindcss(),
@@ -128,7 +139,7 @@ export function createViteConfig({ appDir, config, projectRoot }) {
128
139
  server: {
129
140
  fs: {
130
141
  // pages/, lib/ y public/ del usuario viven un nivel arriba de .ecomiq
131
- allow: [...allow],
142
+ allow,
132
143
  },
133
144
  },
134
145
  }