Babel, Rollup'un TypeScript eklentisi ile kullanıldığında derlenmez
@rollup/plugin-typescript'i @rollup/plugin-babel ile çalıştıramıyorum ve TS kodundan üretilen JS, Babel tarafından çevrilmiyor
İlgili problemlere çözümler aradım, ancak işe yaramıyor gibiydi (babel 7, typescript eklentisi ile rollup kullanıldığında transpile etmiyor)
Aşağıda benim rollup yapılandırmam var
import { terser } from "rollup-plugin-terser";
import pluginTypescript from "@rollup/plugin-typescript";
import pluginCommonjs from "@rollup/plugin-commonjs";
import pluginNodeResolve from "@rollup/plugin-node-resolve";
import { babel } from "@rollup/plugin-babel";
import * as path from "path";
import pkg from "./package.json";
const moduleName = pkg.name.replace(/^@.*\//, "");
const inputFileName = "src/main.ts";
const author = pkg.author;
const banner = `
/**
* @license
* author: ${author}
* ${moduleName}.js v${pkg.version}
* Released under the ${pkg.license} license.
*/
`;
export default [
{
input: inputFileName,
output: [
{
name: moduleName,
file: pkg.browser,
format: "iife",
//sourcemap: "inline",
banner,
},
{
name: moduleName,
file: pkg.browser.replace(".js", ".min.js"),
format: "iife",
sourcemap: "inline",
banner,
plugins: [terser()],
},
],
plugins: [
pluginTypescript(),
pluginCommonjs({
extensions: [".js", ".ts"],
}),
babel({
extensions: [".ts"],
include: path.resolve("src", "**", "*.ts"),
babelHelpers: "bundled",
configFile: path.resolve(__dirname, ".babelrc.js"),
}),
pluginNodeResolve({
browser: true,
}),//
],
}
];
İşte benim Babel yapılandırmam
{
"presets": [
[
"@babel/env",
{
"modules": false,
"targets": {
"browsers": "> 1%, last 2 versions, ie > 11"
}
}
]
],
"plugins": [
[
"@babel/plugin-proposal-class-properties"
],
[
"@babel/plugin-transform-runtime",
{
"absoluteRuntime": false,
"corejs": 3,
"helpers": true,
"regenerator": true,
"version": "^7.13.17"
}
]
]
}
Kullandığım Rollup ve ilgili sürümler
"devDependencies": {
"@babel/cli": "^7.13.16",
"@babel/core": "^7.13.16",
"@babel/helpers": "^7.13.17",
"@babel/plugin-transform-runtime": "^7.13.15",
"@babel/preset-env": "^7.13.15",
"@rollup/plugin-babel": "^5.3.0",
"@rollup/plugin-commonjs": "^18.0.0",
"@rollup/plugin-node-resolve": "^11.2.1",
"@rollup/plugin-typescript": "^8.2.1",
"@types/jest": "^26.0.22",
"@typescript-eslint/eslint-plugin": "^4.22.0",
"@typescript-eslint/parser": "^4.22.0",
"eslint": "^7.24.0",
"jest": "^26.6.3",
"rollup": "^2.45.2",
"rollup-plugin-terser": "^7.0.2",
"ts-jest": "^26.5.5",
"typescript": "^4.2.4"
},
"dependencies": {
"@amipei/cookie": "0.0.2",
"@babel/runtime": "^7.13.17",
"@babel/runtime-corejs3": "^7.13.17",
"tslib": "^2.2.0"
}
Nerede yanlış yaptım? Lütfen bana cevap ver. Rollup günlerdir beni işkence ediyor
Cevap #1
Bu ön ayarı ekle - yoksa npm ile yükle
"presets": [ '@babel/preset-typescript' ]
