@open-mercato/core 0.5.1-develop.2683.4878a05b8e → 0.5.1-develop.2691.d8a0934b37
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/.turbo/turbo-build.log +4 -2
- package/build.mjs +32 -154
- package/package.json +3 -3
package/.turbo/turbo-build.log
CHANGED
package/build.mjs
CHANGED
|
@@ -1,173 +1,51 @@
|
|
|
1
|
-
import * as esbuild from 'esbuild'
|
|
2
1
|
import { glob } from 'glob'
|
|
3
|
-
import { readFileSync, writeFileSync, existsSync, mkdirSync, copyFileSync, readdirSync, rmSync } from 'node:fs'
|
|
4
2
|
import { dirname, join, relative } from 'node:path'
|
|
5
3
|
import { fileURLToPath } from 'node:url'
|
|
4
|
+
import { buildPackage } from '../../scripts/build-package.mjs'
|
|
6
5
|
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
mkdirSync(outdir, { recursive: true })
|
|
11
|
-
for (const entry of readdirSync(outdir)) {
|
|
12
|
-
rmSync(join(outdir, entry), { recursive: true, force: true })
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const srcEntryPoints = await glob('src/**/*.{ts,tsx}', {
|
|
16
|
-
cwd: __dirname,
|
|
17
|
-
ignore: ['**/__tests__/**', '**/*.test.ts', '**/*.test.tsx'],
|
|
18
|
-
absolute: true,
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
const generatedEntryPoints = await glob('generated/**/*.{ts,tsx}', {
|
|
22
|
-
cwd: __dirname,
|
|
23
|
-
ignore: ['**/__tests__/**', '**/*.test.ts', '**/*.test.tsx'],
|
|
24
|
-
absolute: true,
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
if (srcEntryPoints.length === 0) {
|
|
28
|
-
console.error('No source entry points found!')
|
|
29
|
-
process.exit(1)
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
console.log(`Found ${srcEntryPoints.length} source entry points`)
|
|
33
|
-
|
|
34
|
-
const entryPoints = srcEntryPoints
|
|
6
|
+
const packageDir = dirname(fileURLToPath(import.meta.url))
|
|
7
|
+
const distDir = join(packageDir, 'dist')
|
|
35
8
|
|
|
36
9
|
const toImportPath = (p) => p.replace(/\\/g, '/')
|
|
37
10
|
|
|
38
|
-
//
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
let content = readFileSync(file, 'utf-8')
|
|
49
|
-
|
|
50
|
-
// Helper to resolve #generated/* paths
|
|
51
|
-
const resolveGeneratedPath = (importPath) => {
|
|
52
|
-
if (importPath === 'entity-fields-registry') {
|
|
53
|
-
// Special case: entity-fields-registry is in generated-shims
|
|
54
|
-
return join(distDir, 'generated-shims', 'entity-fields-registry.js')
|
|
55
|
-
} else if (importPath.startsWith('entities/')) {
|
|
56
|
-
// Entity imports: #generated/entities/<name> → dist/generated/entities/<name>/index.js
|
|
57
|
-
return join(distDir, 'generated', importPath, 'index.js')
|
|
58
|
-
} else {
|
|
59
|
-
// Other generated files: #generated/<name> → dist/generated/<name>.js
|
|
60
|
-
return join(distDir, 'generated', importPath + '.js')
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// Resolve #generated/* static imports to relative paths
|
|
65
|
-
content = content.replace(
|
|
66
|
-
/from\s+["']#generated\/([^"']+)["']/g,
|
|
67
|
-
(match, importPath) => {
|
|
68
|
-
const targetPath = resolveGeneratedPath(importPath)
|
|
69
|
-
let relativePath = toImportPath(relative(fileDir, targetPath))
|
|
70
|
-
if (!relativePath.startsWith('.')) {
|
|
71
|
-
relativePath = './' + relativePath
|
|
72
|
-
}
|
|
73
|
-
return `from "${relativePath}"`
|
|
74
|
-
}
|
|
75
|
-
)
|
|
76
|
-
|
|
77
|
-
// Resolve #generated/* dynamic imports to relative paths
|
|
78
|
-
content = content.replace(
|
|
79
|
-
/import\s*\(\s*["']#generated\/([^"']+)["']\s*\)/g,
|
|
80
|
-
(match, importPath) => {
|
|
81
|
-
const targetPath = resolveGeneratedPath(importPath)
|
|
82
|
-
let relativePath = toImportPath(relative(fileDir, targetPath))
|
|
83
|
-
if (!relativePath.startsWith('.')) {
|
|
84
|
-
relativePath = './' + relativePath
|
|
85
|
-
}
|
|
86
|
-
return `import("${relativePath}")`
|
|
87
|
-
}
|
|
88
|
-
)
|
|
89
|
-
|
|
90
|
-
// Add .js to relative imports that don't have an extension
|
|
91
|
-
content = content.replace(
|
|
92
|
-
/from\s+["'](\.[^"']+)["']/g,
|
|
93
|
-
(match, path) => {
|
|
94
|
-
if (path.endsWith('.js') || path.endsWith('.json')) return match
|
|
95
|
-
// Check if it's a directory with index.js
|
|
96
|
-
const resolvedPath = join(fileDir, path)
|
|
97
|
-
if (existsSync(resolvedPath) && existsSync(join(resolvedPath, 'index.js'))) {
|
|
98
|
-
return `from "${path}/index.js"`
|
|
99
|
-
}
|
|
100
|
-
return `from "${path}.js"`
|
|
101
|
-
}
|
|
102
|
-
)
|
|
103
|
-
content = content.replace(
|
|
104
|
-
/import\s*\(\s*["'](\.[^"']+)["']\s*\)/g,
|
|
105
|
-
(match, path) => {
|
|
106
|
-
if (path.endsWith('.js') || path.endsWith('.json')) return match
|
|
107
|
-
// Check if it's a directory with index.js
|
|
108
|
-
const resolvedPath = join(fileDir, path)
|
|
109
|
-
if (existsSync(resolvedPath) && existsSync(join(resolvedPath, 'index.js'))) {
|
|
110
|
-
return `import("${path}/index.js")`
|
|
111
|
-
}
|
|
112
|
-
return `import("${path}.js")`
|
|
113
|
-
}
|
|
114
|
-
)
|
|
115
|
-
// Handle side-effect imports: import "./path" (no from clause)
|
|
116
|
-
content = content.replace(
|
|
117
|
-
/import\s+["'](\.[^"']+)["'];/g,
|
|
118
|
-
(match, path) => {
|
|
119
|
-
if (path.endsWith('.js') || path.endsWith('.json')) return match
|
|
120
|
-
// Check if it's a directory with index.js
|
|
121
|
-
const resolvedPath = join(fileDir, path)
|
|
122
|
-
if (existsSync(resolvedPath) && existsSync(join(resolvedPath, 'index.js'))) {
|
|
123
|
-
return `import "${path}/index.js";`
|
|
124
|
-
}
|
|
125
|
-
return `import "${path}.js";`
|
|
126
|
-
}
|
|
127
|
-
)
|
|
128
|
-
writeFileSync(file, content)
|
|
129
|
-
}
|
|
130
|
-
})
|
|
11
|
+
// Translate `#generated/<name>` imports into a relative path into dist/generated/.
|
|
12
|
+
// Called per emitted .js file by the shared atomic-write plugin.
|
|
13
|
+
function resolveGeneratedImport(importPath, fileDir) {
|
|
14
|
+
let targetPath
|
|
15
|
+
if (importPath === 'entity-fields-registry') {
|
|
16
|
+
targetPath = join(distDir, 'generated-shims', 'entity-fields-registry.js')
|
|
17
|
+
} else if (importPath.startsWith('entities/')) {
|
|
18
|
+
targetPath = join(distDir, 'generated', importPath, 'index.js')
|
|
19
|
+
} else {
|
|
20
|
+
targetPath = join(distDir, 'generated', importPath + '.js')
|
|
131
21
|
}
|
|
22
|
+
let rel = toImportPath(relative(fileDir, targetPath))
|
|
23
|
+
if (!rel.startsWith('.')) rel = './' + rel
|
|
24
|
+
return rel
|
|
132
25
|
}
|
|
133
26
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
jsx: 'automatic',
|
|
143
|
-
plugins: [addJsExtension],
|
|
27
|
+
const rewriteOptions = { resolveGeneratedImport }
|
|
28
|
+
|
|
29
|
+
await buildPackage(packageDir, {
|
|
30
|
+
name: 'core',
|
|
31
|
+
clearDist: true,
|
|
32
|
+
copyJson: true,
|
|
33
|
+
copyJsonIgnore: ['**/i18n/**'],
|
|
34
|
+
rewriteOptions,
|
|
144
35
|
})
|
|
145
36
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
ignore: ['**/node_modules/**', '**/i18n/**'], // i18n files are handled differently
|
|
37
|
+
const generatedEntryPoints = await glob('generated/**/*.{ts,tsx}', {
|
|
38
|
+
cwd: packageDir,
|
|
39
|
+
ignore: ['**/__tests__/**', '**/*.test.ts', '**/*.test.tsx'],
|
|
150
40
|
absolute: true,
|
|
151
41
|
})
|
|
152
|
-
for (const jsonFile of jsonFiles) {
|
|
153
|
-
const relativePath = relative(join(__dirname, 'src'), jsonFile)
|
|
154
|
-
const destPath = join(outdir, relativePath)
|
|
155
|
-
mkdirSync(dirname(destPath), { recursive: true })
|
|
156
|
-
copyFileSync(jsonFile, destPath)
|
|
157
|
-
}
|
|
158
42
|
|
|
159
|
-
// Build generated files to dist/generated
|
|
160
43
|
if (generatedEntryPoints.length > 0) {
|
|
161
|
-
await
|
|
44
|
+
await buildPackage(packageDir, {
|
|
45
|
+
name: 'core:generated',
|
|
162
46
|
entryPoints: generatedEntryPoints,
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
platform: 'node',
|
|
167
|
-
target: 'node18',
|
|
168
|
-
sourcemap: true,
|
|
169
|
-
plugins: [addJsExtension],
|
|
47
|
+
outbase: 'generated',
|
|
48
|
+
outdir: 'dist/generated',
|
|
49
|
+
rewriteOptions,
|
|
170
50
|
})
|
|
171
51
|
}
|
|
172
|
-
|
|
173
|
-
console.log('core built successfully')
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-mercato/core",
|
|
3
|
-
"version": "0.5.1-develop.
|
|
3
|
+
"version": "0.5.1-develop.2691.d8a0934b37",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -234,10 +234,10 @@
|
|
|
234
234
|
"ts-pattern": "^5.0.0"
|
|
235
235
|
},
|
|
236
236
|
"peerDependencies": {
|
|
237
|
-
"@open-mercato/shared": "0.5.1-develop.
|
|
237
|
+
"@open-mercato/shared": "0.5.1-develop.2691.d8a0934b37"
|
|
238
238
|
},
|
|
239
239
|
"devDependencies": {
|
|
240
|
-
"@open-mercato/shared": "0.5.1-develop.
|
|
240
|
+
"@open-mercato/shared": "0.5.1-develop.2691.d8a0934b37",
|
|
241
241
|
"@testing-library/dom": "^10.4.1",
|
|
242
242
|
"@testing-library/jest-dom": "^6.9.1",
|
|
243
243
|
"@testing-library/react": "^16.3.1",
|