Open1
rollupでtypescriptを使う

@rollup/plugin-typescript
プラグインを使う
設定を追記
rollup.config.js
import typescript from '@rollup/plugin-typescript';
export default {
+ plugins: [typescript()]
};
これでビルドするとtslib
が必要と怒られる
src/index.ts → dist/index.js, dist/index.min.js...
[!] (plugin typescript) RollupError: @rollup/plugin-typescript: Could not find module 'tslib', which is required by this plugin. Is it installed?
...
ELIFECYCLE Command failed with exit code 1.
tslibを入れる
ビルドが成功
% pnpm build
省略
src/index.ts → dist/index.js, dist/index.min.js...
(!) Plugin typescript: @rollup/plugin-typescript TS5096: Option 'allowImportingTsExtensions' can only be used when either 'noEmit' or 'emitDeclarationOnly' is set.
created dist/index.js, dist/index.min.js in 769ms
tsconfig.jsonの設定
tsconfig.json
{
"compilerOptions": {
"target": "ES2020",
"useDefineForClassFields": true,
"module": "ESNext",
"lib": ["ES2020", "DOM"],
"skipLibCheck": true,
/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
"emitDeclarationOnly": true,
"declaration": true,
"declarationDir": "./types",
/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
},
"include": ["src"]
}