Skip to content
This repository has been archived by the owner on Aug 4, 2021. It is now read-only.

Do I still need this plugin when using babel7? #129

Closed
lili21 opened this issue Dec 5, 2018 · 5 comments
Closed

Do I still need this plugin when using babel7? #129

lili21 opened this issue Dec 5, 2018 · 5 comments

Comments

@lili21
Copy link

lili21 commented Dec 5, 2018

since babel7 already support typescript.

So I can stick with rollup-plugin-babel + babel7, right ?

@Quilljou
Copy link

Quilljou commented Jan 7, 2019

I guess use @babel/preset-typescript is a better choice

@zhaparoff
Copy link

I guess use @babel/preset-typescript is a better choice

It doesn't work for me when using it with rollup-plugin-babel, although works pretty fine when running babel isolated: rollup/rollup-plugin-babel#255
Seems we still need to transpile TS with rollup-plugin-typescript separately.

@Quilljou
Copy link

Quilljou commented Feb 3, 2019

@zhaparoff I have already used babel + ts + react for devlopment. below is my rollup config and babel config

import babel from 'rollup-plugin-babel';
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import replace from 'rollup-plugin-replace';

const extensions = [
    '.js', '.jsx', '.ts', '.tsx',
];

export default {
    input: 'src/index.ts',
    output: {
        file: 'dist.js',
        dir: 'dist',
        format: 'umd',
        sourcemap: true
    },
    plugins: [
        replace({
            'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
        }),
        resolve({
            extensions
        }),
        commonjs({
            include: 'node_modules/**',
            namedExports: {
                'node_modules/react-dom/index.js': ['render'],
                'node_modules/react/index.js': ['Component', 'PropTypes', 'createElement']
            }
        }),
        babel({
            extensions,
            runtimeHelpers: true,
            exclude: 'node_modules/**' // only transpile our source code
        })
    ]
};
{
    "presets": [
        ["@babel/preset-env", {
            "modules": false,
            "loose": true,
            "debug": true,
            "useBuiltIns": "usage"
        }],
       [ "@babel/preset-typescript", {
           "isTSX": true,
           "allExtensions": true
       }],
       "@babel/preset-react"
    ],
    "plugins": ["@babel/plugin-proposal-class-properties"]
}

@DrSensor
Copy link

DrSensor commented Feb 4, 2019

There some explanation about the caveats of using @babel/preset-typescript here
https://blogs.msdn.microsoft.com/typescript/2018/08/27/typescript-and-babel-7/
However, babel is still needed if you want to use macros 🎣

DrSensor added a commit to DrSensor/bot-byte that referenced this issue Feb 4, 2019
- [npm start] remove typescript declaration file
- [npm start] use babel with typescript preset
- [npm build] use typescript compiler

references:
- rollup/rollup-plugin-babel#255
- rollup/rollup-plugin-typescript#129
- rollup/rollup-plugin-babel#271
- rollup/rollup-plugin-babel#279
- microsoft/TypeScript-Babel-Starter#29
@shellscape
Copy link
Contributor

Hey folks (this is a canned reply, but we mean it!). Thanks to everyone who participated in this issue. We're getting ready to move this plugin to a new home at https://github.com/rollup/plugins, and we have to do some spring cleaning of the issues to make that happen. We're going to close this one, but it doesn't mean that it's not still valid. We've got some time yet before the move while we resolve pending Pull Requests, so if this issue is still relevant, please @ me and I'll make sure it gets transferred to the new repo. 🍺

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants