@open-mercato/shared 0.5.1-develop.2681.c559bb2bc3 → 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 +2 -2
- package/build.mjs +13 -102
- package/dist/lib/version.js +1 -1
- package/dist/lib/version.js.map +1 -1
- package/package.json +1 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
shared built successfully
|
|
1
|
+
[build:shared] found 201 entry points
|
|
2
|
+
[build:shared] built successfully
|
package/build.mjs
CHANGED
|
@@ -1,116 +1,27 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { glob } from 'glob'
|
|
3
|
-
import { readFileSync, writeFileSync, existsSync } from 'node:fs'
|
|
1
|
+
import { readFileSync } from 'node:fs'
|
|
4
2
|
import { dirname, join } from 'node:path'
|
|
5
3
|
import { fileURLToPath } from 'node:url'
|
|
4
|
+
import { buildPackage } from '../../scripts/build-package.mjs'
|
|
6
5
|
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
// Read the package version at build time for injection
|
|
10
|
-
const packageJson = JSON.parse(readFileSync(join(__dirname, 'package.json'), 'utf-8'))
|
|
6
|
+
const packageDir = dirname(fileURLToPath(import.meta.url))
|
|
7
|
+
const packageJson = JSON.parse(readFileSync(join(packageDir, 'package.json'), 'utf-8'))
|
|
11
8
|
const packageVersion = packageJson.version
|
|
12
9
|
|
|
13
|
-
//
|
|
10
|
+
// Inject build-time version into lib/version.ts without touching the source file.
|
|
14
11
|
const injectVersion = {
|
|
15
12
|
name: 'inject-version',
|
|
16
13
|
setup(build) {
|
|
17
|
-
build.onLoad({ filter: /lib\/version\.ts$/ }, async () => {
|
|
18
|
-
|
|
19
|
-
contents: `// Build-time generated version
|
|
14
|
+
build.onLoad({ filter: /lib\/version\.ts$/ }, async () => ({
|
|
15
|
+
contents: `// Build-time generated version
|
|
20
16
|
export const APP_VERSION = '${packageVersion}'
|
|
21
17
|
export const appVersion = APP_VERSION
|
|
22
18
|
`,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
19
|
+
loader: 'ts',
|
|
20
|
+
}))
|
|
21
|
+
},
|
|
27
22
|
}
|
|
28
23
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
absolute: true,
|
|
24
|
+
await buildPackage(packageDir, {
|
|
25
|
+
name: 'shared',
|
|
26
|
+
extraPlugins: [injectVersion],
|
|
33
27
|
})
|
|
34
|
-
|
|
35
|
-
if (entryPoints.length === 0) {
|
|
36
|
-
console.error('No entry points found!')
|
|
37
|
-
process.exit(1)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
console.log(`Found ${entryPoints.length} entry points`)
|
|
41
|
-
|
|
42
|
-
// Plugin to add .js extension to relative imports
|
|
43
|
-
const addJsExtension = {
|
|
44
|
-
name: 'add-js-extension',
|
|
45
|
-
setup(build) {
|
|
46
|
-
build.onEnd(async (result) => {
|
|
47
|
-
if (result.errors.length > 0) return
|
|
48
|
-
const outputFiles = await glob('dist/**/*.js', { cwd: __dirname, absolute: true })
|
|
49
|
-
for (const file of outputFiles) {
|
|
50
|
-
const fileDir = dirname(file)
|
|
51
|
-
let content = readFileSync(file, 'utf-8')
|
|
52
|
-
// Add .js to relative imports that don't have an extension
|
|
53
|
-
content = content.replace(
|
|
54
|
-
/from\s+["'](\.[^"']+)["']/g,
|
|
55
|
-
(match, path) => {
|
|
56
|
-
if (path.endsWith('.js') || path.endsWith('.json')) return match
|
|
57
|
-
// Check if it's a directory with index.js
|
|
58
|
-
const resolvedPath = join(fileDir, path)
|
|
59
|
-
if (existsSync(resolvedPath) && existsSync(join(resolvedPath, 'index.js'))) {
|
|
60
|
-
return `from "${path}/index.js"`
|
|
61
|
-
}
|
|
62
|
-
return `from "${path}.js"`
|
|
63
|
-
}
|
|
64
|
-
)
|
|
65
|
-
content = content.replace(
|
|
66
|
-
/import\s*\(\s*["'](\.[^"']+)["']\s*\)/g,
|
|
67
|
-
(match, path) => {
|
|
68
|
-
if (path.endsWith('.js') || path.endsWith('.json')) return match
|
|
69
|
-
// Check if it's a directory with index.js
|
|
70
|
-
const resolvedPath = join(fileDir, path)
|
|
71
|
-
if (existsSync(resolvedPath) && existsSync(join(resolvedPath, 'index.js'))) {
|
|
72
|
-
return `import("${path}/index.js")`
|
|
73
|
-
}
|
|
74
|
-
return `import("${path}.js")`
|
|
75
|
-
}
|
|
76
|
-
)
|
|
77
|
-
// Handle side-effect imports: import "./path" (no from clause)
|
|
78
|
-
content = content.replace(
|
|
79
|
-
/import\s+["'](\.[^"']+)["'];/g,
|
|
80
|
-
(match, path) => {
|
|
81
|
-
if (path.endsWith('.js') || path.endsWith('.json')) return match
|
|
82
|
-
// Check if it's a directory with index.js
|
|
83
|
-
const resolvedPath = join(fileDir, path)
|
|
84
|
-
if (existsSync(resolvedPath) && existsSync(join(resolvedPath, 'index.js'))) {
|
|
85
|
-
return `import "${path}/index.js";`
|
|
86
|
-
}
|
|
87
|
-
return `import "${path}.js";`
|
|
88
|
-
}
|
|
89
|
-
)
|
|
90
|
-
writeFileSync(file, content)
|
|
91
|
-
}
|
|
92
|
-
})
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
const outdir = join(__dirname, 'dist')
|
|
97
|
-
|
|
98
|
-
const result = await esbuild.build({
|
|
99
|
-
entryPoints,
|
|
100
|
-
outdir,
|
|
101
|
-
outbase: join(__dirname, 'src'),
|
|
102
|
-
format: 'esm',
|
|
103
|
-
platform: 'node',
|
|
104
|
-
target: 'node18',
|
|
105
|
-
sourcemap: true,
|
|
106
|
-
jsx: 'automatic',
|
|
107
|
-
write: true,
|
|
108
|
-
plugins: [injectVersion, addJsExtension],
|
|
109
|
-
})
|
|
110
|
-
|
|
111
|
-
if (result.errors.length > 0) {
|
|
112
|
-
console.error('Build errors:', result.errors)
|
|
113
|
-
process.exit(1)
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
console.log('shared built successfully')
|
package/dist/lib/version.js
CHANGED
package/dist/lib/version.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/lib/version.ts"],
|
|
4
|
-
"sourcesContent": ["// Build-time generated version\nexport const APP_VERSION = '0.5.1-develop.
|
|
4
|
+
"sourcesContent": ["// Build-time generated version\nexport const APP_VERSION = '0.5.1-develop.2691.d8a0934b37'\nexport const appVersion = APP_VERSION\n"],
|
|
5
5
|
"mappings": "AACO,MAAM,cAAc;AACpB,MAAM,aAAa;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|