-
Notifications
You must be signed in to change notification settings - Fork 70
Description
Troubleshooting
-
Does
tsc
have the same output? If so, please explain why this is incorrect behavior -
Does your Rollup plugin order match this plugin's compatibility? If not, please elaborate
-
Can you create a minimal example that reproduces this behavior? Preferably, use this environment for your reproduction
What happens and why it is incorrect
Environment
Versions
System:
OS: Linux 4.19 Debian GNU/Linux 10 (buster) 10 (buster)
CPU: (8) x64 Intel(R) Xeon(R) Platinum 8260 CPU @ 2.40GHz
Memory: 10.49 GB / 15.41 GB
Container: Yes
Shell: 5.7.1 - /usr/bin/zsh
Binaries:
Node: 16.19.0 - /run/user/1001/fnm_multishells/846809_1680868810665/bin/node
Yarn: 1.22.19 - /run/user/1001/fnm_multishells/846809_1680868810665/bin/yarn
npm: 8.19.3 - /run/user/1001/fnm_multishells/846809_1680868810665/bin/npm
npmPackages:
typescript: ^5.0.2 => 5.0.2
rollup.config.js
:
rollup.config.js
import path from 'path';
import { defineConfig } from 'rollup';
import { genPlugin, genTypeDefinePlugin } from './plugins';
import { resolveFile, getPackageJson } from './utils';
const pkg = getPackageJson();
const libName = pkg.name;
const devPlugins = genPlugin({
isDev: true,
pluginTypescriptOptions: {
sourceMap: true,
},
});
/** @type {import('rollup').OutputOptions[]} */
const output = [
// {
// file: resolveFile(`dist/${libName}.cjs.js`),
// format: 'cjs',
// },
{
file: resolveFile(`dist/${libName}.js`),
format: 'es',
},
];
// build config for development
export default defineConfig([
{
watch: {
include: ['src/**'],
},
input: resolveFile('src/index.ts'),
output,
plugins: devPlugins,
external: [...Object.keys(pkg.dependencies), 'protobufjs/minimal'],
},
]);
tsconfig.json
:
tsconfig.json
{
"compilerOptions": {
"moduleResolution": "node",
"module": "ESNext",
"target": "ES2020",
"lib": ["dom", "ESNext"],
"sourceMap": true,
"declaration": true,
"declarationMap": true,
"declarationDir": "./type",
"outDir": "./lib",
"strict": true,
"noImplicitAny": true,
"allowSyntheticDefaultImports": true,
"strictPropertyInitialization": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"baseUrl": ".",
"paths": {
"@/*": ["src/*"]
},
"plugins": [
{
"transform": "typescript-transform-paths",
"useRootDirs": true,
"afterDeclarations": true
}
]
},
"include": ["src/**/*.ts", "src/**/*.d.ts"]
}
package.json
:
package.json
"rollup-plugin-typescript2": "^0.34.1",
plugin output with verbosity 3
:
detail
When rebuilding, rollup-plugin-typescript2 computes a hash key for the cache. One portion of the hash is the Rollup config, which is actually so big of an object that it is a significant performance degradation to compute its hash.
Referencing this part of code:
rollup-plugin-typescript2/src/tscache.ts
Lines 93 to 102 in f6db596
this.cacheDir = `${this.cacheRoot}/${this.cachePrefix}${objHash( | |
{ | |
version: this.cacheVersion, | |
rootFilenames, | |
options: this.options, | |
rollupConfig: this.rollupConfig, | |
tsVersion: tsModule.version, | |
}, | |
this.hashOptions, | |
)}`; |
In the profiling below, we can see that computing the hash compute takes up almost all of the time, about 20s: