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

Why JavaScript API and CLI output different result? #87

@differui

Description

@differui
  • babelrc-rollup 2.6.1
  • rollup 0.36.1
  • rollup-plugin-babel 5.0.4
  • node 4.1.0
  • npm 3.8.1

This is a JavaScript lib called tether written in UMD:

https://github.com/HubSpot/tether/raw/master/dist/js/tether.js

Import into entry:

import 'tether';

And here is the .babelrc file:

{
    "presets": [
        "es2015"
    ]
}

Use JavaScript API output the bundle:

const rollup = require('rollup');
const babelrc = require('babelrc-rollup');
const babel = require('rollup-plugin-babel');

rollup.rollup({
    entry: './src/index.js',
    plugins: [
        babel(babelrc.default())
    ],
    context: 'window'
}).then(function (bundle) {
    bundle.write({
        format: 'iife',
        dest: './build/index1.js'
    });
});

Use CLI rollup.config.js:

// Rollup plugins
import babelrc from 'babelrc-rollup';
import babel from 'rollup-plugin-babel';

export default {
    entry: 'src/index.js',
    dest: 'build/index2.js',
    format: 'iife',
    plugins: [
        babel(babelrc())
    ]
};

As a result the prior manner lost function extend() {}, function removeClass() {} compare with later one.

Does rollup did the right thing?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions