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

rollup + rollup-plugin-babel + @babel/polyfill #250

Closed
robinloeffel opened this issue Sep 14, 2018 · 6 comments
Closed

rollup + rollup-plugin-babel + @babel/polyfill #250

robinloeffel opened this issue Sep 14, 2018 · 6 comments

Comments

@robinloeffel
Copy link
Member

When trying to build my project with rollup@latest, rollup-plugin-babel@latest, @babel/core@latest and @babel/polyfill@latest, I get the following error originating from rollup-plugin-babel:

[!] (babel plugin) TypeError: Cannot read property 'code' of null
node_modules/core-js/modules/es7.symbol.async-iterator.js
TypeError: Cannot read property 'code' of null
at /Users/robin.loeffel/Sites/misc/mehrsprachig/node_modules/rollup-plugin-babel/dist/rollup-plugin-babel.cjs.js:53:52
at Object.transform$1 (/Users/robin.loeffel/Sites/misc/mehrsprachig/node_modules/rollup-plugin-babel/dist/rollup-plugin-babel.cjs.js:174:18)
at /Users/robin.loeffel/Sites/misc/mehrsprachig/node_modules/rollup/dist/rollup.js:20831:25
at

You can check out my code here—I wouldn't be surprised if it's my fault. I'm not that experienced with rollup. 😄

It also sometimes appears with node_modules/regenerator-runtime/runtime.js instead of node_modules/core-js/modules/es7.symbol.async-iterator.js.

@Andarist
Copy link
Member

Thanks for the report. It's a problem in the plugin - gonna fix it tomorrow.

@Andarist
Copy link
Member

Could u try rollup-plugin-babel@beta?

@robinloeffel
Copy link
Member Author

robinloeffel commented Sep 19, 2018

I works now, thank you! But I get the warning that "Plugins that transform code (such as 'babel') should generate accompanying sourcemaps", even though I have babel configured to output source maps.

module.exports = {
    sourceMaps: true,
    presets: [
        ['@babel/preset-env', {
            targets: {
                ie: 11,
                browsers: 'last 2 versions'
            },
            useBuiltIns: 'usage'
        }]
    ],
    ignore: [ 'node_modules' ]
};
import babel from 'rollup-plugin-babel';
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import { uglify } from 'rollup-plugin-uglify';
import { eslint } from 'rollup-plugin-eslint';

// two separate objects for two separate outputs
// firstly esnext for bundlers, then umd for browsers
export default [{
    input: 'src/mehrsprachig.js',
    plugins: [
        eslint(),
        resolve(),
        commonjs()
    ],
    output: {
        dir: 'dist',
        sourcemap: true,
        file: 'mehrsprachig.es.js',
        format: 'es'
    }
}, {
    input: 'src/mehrsprachig.js',
    plugins: [
        eslint(),
        resolve(),
        commonjs(),
        babel(),
        uglify()
    ],
    output: {
        dir: 'dist',
        sourcemap: true,
        name: 'Mehrsprachig',
        file: 'mehrsprachig.umd.js',
        format: 'umd'
    }
}];

@Andarist
Copy link
Member

Thanks for reporting back, I think we might need to return null instead of { code } when no transformation takes place (because of your ignore rule in babelrc). I need to investigate if it's supported in all current supported versions of rollup.

@Andarist
Copy link
Member

Andarist commented Jan 2, 2019

I think this was fixed by some of the latest releases, closing this but I would appreciate you checking again if it works now correctly for you and reporting back if it does.

@Andarist Andarist closed this as completed Jan 2, 2019
@robinloeffel
Copy link
Member Author

Works correctly now, thanks!

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

2 participants