2024-12-08 15:53:13 +08:00
|
|
|
// @ts-check
|
|
|
|
|
|
|
|
/**
|
|
|
|
* runtime-core exports a number of internal helpers that are only used by
|
|
|
|
* runtime-vapor, which should be only preserved in vapor / esm-bundler builds.
|
|
|
|
* This plugin should be included as the first plugin for all other formats
|
|
|
|
* other than vapor / esm-bundler.
|
|
|
|
*
|
|
|
|
* @param {string} format
|
|
|
|
* @param {string} pkgName
|
|
|
|
* @returns {import('rollup').Plugin[]}
|
|
|
|
*/
|
|
|
|
export function trimVaporExportsPlugin(format, pkgName) {
|
|
|
|
if (
|
2025-02-08 20:42:34 +08:00
|
|
|
format.includes('vapor') ||
|
2024-12-08 20:51:42 +08:00
|
|
|
format.startsWith('esm-bundler') ||
|
2024-12-08 15:53:13 +08:00
|
|
|
pkgName === '@vue/runtime-vapor'
|
|
|
|
) {
|
|
|
|
return []
|
|
|
|
} else {
|
|
|
|
return [
|
|
|
|
{
|
|
|
|
name: 'trim-vapor-exports',
|
|
|
|
transform(code, id) {
|
2024-12-12 01:48:40 +08:00
|
|
|
if (
|
|
|
|
id.endsWith('runtime-core/src/index.ts') ||
|
|
|
|
id.endsWith('runtime-dom/src/index.ts')
|
|
|
|
) {
|
2024-12-08 15:53:13 +08:00
|
|
|
const index = code.lastIndexOf('// VAPOR ---')
|
|
|
|
return code.slice(0, index)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|