@emarketeer/ts-microservice-commons 7.1.0-beta.39 → 7.1.0-beta.40
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/dist/esbuild-plugins.js +1 -40
- package/package.json +1 -1
package/dist/esbuild-plugins.js
CHANGED
|
@@ -70,44 +70,5 @@ const recapDevHandlerWrapper = {
|
|
|
70
70
|
},
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
|
|
74
|
-
* esbuild-plugin-tsc wrapper that forces "module": "CommonJS".
|
|
75
|
-
*
|
|
76
|
-
* The service tsconfig uses "module": "NodeNext" which causes the tsc
|
|
77
|
-
* plugin to emit ESM helpers that esbuild then converts to CJS — double
|
|
78
|
-
* conversion adds ~2MB per bundle. This wrapper writes a temporary
|
|
79
|
-
* tsconfig that extends the service's config with module: CommonJS.
|
|
80
|
-
*/
|
|
81
|
-
const esbuildPluginTscCjs = () => {
|
|
82
|
-
const tmpConfig = path.join(process.cwd(), 'tsconfig.esbuild-tmp.json')
|
|
83
|
-
const baseConfig = path.join(process.cwd(), 'tsconfig.json')
|
|
84
|
-
|
|
85
|
-
if (fs.existsSync(baseConfig)) {
|
|
86
|
-
fs.writeFileSync(tmpConfig, JSON.stringify({
|
|
87
|
-
extends: './tsconfig.json',
|
|
88
|
-
compilerOptions: { module: 'CommonJS' }
|
|
89
|
-
}))
|
|
90
|
-
console.log('[esbuild-plugin-tsc] Using CJS override tsconfig:', tmpConfig)
|
|
91
|
-
} else {
|
|
92
|
-
console.log('[esbuild-plugin-tsc] No tsconfig.json found at', baseConfig, '— using defaults')
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
const plugin = esbuildPluginTsc({
|
|
96
|
-
tsconfigPath: fs.existsSync(tmpConfig) ? tmpConfig : undefined
|
|
97
|
-
})
|
|
98
|
-
|
|
99
|
-
return {
|
|
100
|
-
name: 'tsc-cjs',
|
|
101
|
-
setup(build) {
|
|
102
|
-
plugin.setup(build)
|
|
103
|
-
|
|
104
|
-
// Clean up temp file after build
|
|
105
|
-
build.onEnd(() => {
|
|
106
|
-
try { fs.unlinkSync(tmpConfig) } catch (e) { /* ignore */ }
|
|
107
|
-
})
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
const defaultPlugins = [recapDevAutoWrapper, esbuildPluginTscCjs()]
|
|
73
|
+
const defaultPlugins = [recapDevAutoWrapper, esbuildPluginTsc()]
|
|
113
74
|
module.exports = { defaultPlugins, recapDevHandlerWrapper }
|