Git Product home page Git Product logo

rollup-plugin-babel-minify's Introduction

rollup-plugin-babel-minify

Build Status codecov Dependency Status devDependencies Status npm

Allows using babel-minify with Rollup.

☠️ Project is deprecated! ☠️

Version 10.0.0, released on 2020-03-14, will be the last version of the project, as babel-minify is basically dead. Please consider using rollup-plugin-terser instead.

Installation

npm install rollup-plugin-babel-minify [--save-dev]

Usage

import { rollup } from 'rollup';
import minify from 'rollup-plugin-babel-minify';

rollup( {
	input: './src/index.js',
	plugins: [
		minify( {
			// Options for babel-minify.
		} )
	]
} );

For the list of options, check babel-minify preset's docs.

There are additional options:

  • comments (default: true): indicates if comments should be preserved in source;
  • banner (default: undefined): the comment which should be prepended to the transformed bundle;
  • bannerNewLine (since 4.0.0, default: false): indicates if the banner comment should be followed by a new line;
  • sourceMap (default: true): indicates if sourcemap should be generated;
  • plugins (since 6.2.0): indicates which Babel plugins should be loaded alongside minify preset; two plugins are loaded by default:

Check API docs for more detailed description.

License

See LICENSE file for details.

rollup-plugin-babel-minify's People

Contributors

akhomchenko avatar boopathi avatar comandeer avatar greenkeeper[bot] avatar greenkeeperio-bot avatar haroenv avatar pieterbeulque avatar soanvig avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

rollup-plugin-babel-minify's Issues

Improve release system

Currently even tagged versions on GitHub don't have dist files. It should be changed.

Drop support for Rollup < 0.58.0

Currently package supports Rollup >= 0.41.5, however in the recent versions Rollup has changed how it parses options. Due to this fact, package now has two methods for passing parameters, which is not ideal. It would be nice to drop support for old versions of Rollup.

Error when minifying dynamic import

Steps to reproduce the issue

  1. run rollup build without rollup-plugin-babel-minify, build successful
  2. add minify and get the error
src/index.js → public/module...
[!] (babel-minify plugin) SyntaxError: Error transforming bundle with 'babel-minify' plugin: unknown: Support for the experimental syntax 'dynamicImport' isn't currently enabled (94:7):

  92 |     key: "handleClick",
  93 |     value: function handleClick() {
> 94 |       import("./moduleA.js").then(function (module) {
     |       ^
  95 |         console.log(module.default);
  96 |       }).catch(function (err) {// Handle failure
  97 |       });

Add @babel/plugin-syntax-dynamic-import (https://git.io/vb4Sv) to the 'plugins' section of your Babel config to enable parsing.
undefined (94:6)
SyntaxError: Error transforming bundle with 'babel-minify' plugin: unknown: Support for the experimental syntax 'dynamicImport' isn't currently enabled (94:7):

Babelrc is:

{
	"presets": [
		["@babel/env", {
			"modules": false
		}],
		["@babel/preset-react"]
	],
	"plugins": [
		["@babel/plugin-syntax-dynamic-import"]
	]
}

Running Babel via CLI babel src/App.js -o compiled.js with the following babelrc is successful:

{
	"presets": [
		["@babel/env", {
			"modules": false
		}],
		["@babel/preset-react"],
		["minify", {
			"mangle": {
				"topLevel": true,
			}
		}]
	],
	"plugins": [
		["@babel/plugin-syntax-dynamic-import"]
	]
}

Version of package: 6.1.1
Node.js & npm versions: 11.0.0, 6.4.1
Operating system: macOS 10.13.6

Move to testing source

Currently tests are run against bundled, built version of the library. It would be nice to change that and run tests against ES6 source with only modules transpiled.

Reorganize tests

Currently all tests repeat the same boilerplate code. Extracting it to separate function would simplify whole tests a lot.

Add support for options

Babili from version 0.0.10 supports passing options. It would be nice to support it in a plugin.

Move to Babel 7

  • switch to @babel/core
  • update plugins and presets
  • update babel-register for tests
  • update config

Banner is outputted twice

Steps to reproduce the issue

  1. Use this plugin with following Rollup configuration:

    import minify from 'rollup-plugin-babel-minify';
    
    export default {
    	input: 'index.js',
    	plugins: [
    		minify()
    	],
    	output: {
    		banner: '/* hublabubla */',
    		file: 'bundle.js',
    		format: 'es'
    	}
    };

Expected result

The banner is outputted once at the beginning of the bundle.

Actual result

The banner is outputted twice.

Other details

Version of package: reproducible at least from 6.2.0

The issue is present only when banner is passed as rollup option, works fine when is passed as plugin's option.

Drop prepublish script

prepublish script basically duplicates preversion one. Building package before versioning should be enough as published version is the same as versioned one.

An in-range update of rollup is breaking the build 🚨

The devDependency rollup was updated from 0.66.0 to 0.66.1.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

rollup is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

Commits

The new version differs by 6 commits.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Name Change

Babili is renamed to babel-minify Ref: babel/minify#124

  • Change name to rollup-plugin-babel-minify
  • Publish to npm after babel-minify is published. I have the name rollup-plugin-babel-minify on npm.

Fix failing test

Test adds banner inherited from root configuration is failing. Additionally rollup is raising warning for it:

The following options have been renamed — please update your config: banner -> output.banner

Banner is not working as expected

There are several issues with banner:

  • banner option is not overriding top level options, it extends it
  • banner in rollup accepts function, while string only is expected in plugin

PR is ready, I will submit it soon.

Deprecate support for Node <6

As LTS is already 8 and 4 still has some issues with ES6 syntax, it seems to be safe now to deprecate support for Node <6.

Add additional tests

  • dedicated tests for utils
  • tests for multiple chunks (API and CLI)
  • tests for assets

Babili not compressing whole bundle

Steps to reproduce the issue

// bundle.js
rollup({
  entry,
  plugins: [babel(babelConfig), babili()],
}).then(bundle => {
  bundle.write({
    format: 'umd',
    dest: `dist/umd/${dest}`,
    sourceMap,
    moduleName,
  });
  bundle.write({
    format: 'es',
    dest: `dist/esm/${dest}`,
    sourceMap,
  });
});
// babel config
const env = require.resolve('babel-preset-env');
const stage2 = require.resolve('babel-preset-stage-2');
const externalHelpers = require.resolve('babel-plugin-external-helpers');

module.exports = {
  presets: [
    [
      env,
      {
        targets: {
          browsers: ['last 2 versions', 'ie >= 10'],
        },
        modules: false,
      },
    ],
    stage2,
  ],
  plugins: [externalHelpers],
};

Expected result

The output bundle should be a compressed bunch of code.

Actual result

The output is not compressed at all...

Other details

Version of package:
latest

Node.js & npm versions:
latest

Operating system:
latest macOS

An in-range update of rollup is breaking the build 🚨

Version 0.41.2 of rollup just got published.

Branch Build failing 🚨
Dependency rollup
Current Version 0.41.1
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As rollup is “only” a devDependency of this project it might not break production or downstream projects, but “only” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this 💪


Status Details
  • continuous-integration/travis-ci/push The Travis CI build failed Details
Commits

The new version differs by 9 commits .

  • e2d9b6b -> v0.41.2
  • 2a01a99 Merge pull request #1241 from kzc/0_41_0_changelog_addition
  • c038cda Merge pull request #1240 from rollup/gh-841-updated
  • 61528b7 change log addition for 0.41.0
  • 82b284d optimize ns["foo"] (#841)
  • 40a0ed5 Merge pull request #1239 from rollup/gh-1213
  • bc0f791 suppress warnings with --silent (closes #1213)
  • 6384b6c Merge pull request #1238 from rollup/gh-797
  • 101ad28 use options.indent for UMD block - fixes #797

See the full diff.

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

Drop support for Node <6

As LTS is already 8 and 4 still has some issues with ES6 syntax, it seems to be safe now to wait one version after #69 and drop support for Node <6.

Fix Node 4 support

Node 4 does not support default options used in codebase. Probably using rollup preset also for tests will solve the issue.

Cannot read property 'names' of null

This is what I get when I try to use this plugin:

TypeError: Cannot read property 'names' of null
    at new Link (/Users/federicozivolo/Progetti/popper-js/node_modules/rollup/src/utils/collapseSourcemaps.js:19:19)
    at /Users/federicozivolo/Progetti/popper-js/node_modules/rollup/src/utils/collapseSourcemaps.js:147:12
    at Array.forEach (native)
    at collapseSourcemaps (/Users/federicozivolo/Progetti/popper-js/node_modules/rollup/src/utils/collapseSourcemaps.js:146:23)
    at Bundle.render (/Users/federicozivolo/Progetti/popper-js/node_modules/rollup/src/Bundle.js:436:11)
    at generate (/Users/federicozivolo/Progetti/popper-js/node_modules/rollup/src/rollup.js:73:28)
    at Object.write (/Users/federicozivolo/Progetti/popper-js/node_modules/rollup/src/rollup.js:102:20)
    at /Users/federicozivolo/Progetti/popper-js/node_modules/rollup/bin/rollup:908:18
    at process._tickCallback (internal/process/next_tick.js:103:7)
    at Module.runMain (module.js:607:11)

Force npm install on Travis CI

Travis CI seems to force npm ci as a new install command, breaking GreenKeeper integration. Let's force "legacy" npm install.

Add tests for Babel 7

Babel 7 is currently in beta, so it would be nice to test it alongside with Babel 6.

Empty sourcemaps when using bannerNewLine = true.

Steps to reproduce the issue

Add bannerNewLine: true to your rollup-plugin-babel-minify config.

Expected result

Newline should be added after banner, sourcemaps should not be cleared.

Actual result

Newline is added after banner, but sourcemaps also get cleared. By cleared, I mean that I get the following:

{"version":3,"file":"moneybutton.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;"}

Disabling this option yields the complete sourcemaps.

Other details

Looking at the code, the bug seems to be in this line:

https://github.com/Comandeer/rollup-plugin-babel-minify/blob/master/src/index.js#L50

When calling addNewLine, the source maps generated by transform are completely disregarded.

Version of package: 6.0.0

Node.js & npm versions: 8.11.3 , 5.6.0

Operating system: Ubuntu 18.04.1 LTS

Add ability to use plugins

Babel can use plugins alongside presets. Therefore rollup-plugin-babel-minify should allow passing additional plugins via plugins option:

rollupPlugin( {
	plugins: [
		'@babel/plugin-syntax-dynamic-import'
	]
} )

Update nyc

Seems like Greenkeeper didn't update this one.

Current version in use: 12
Latest version: 13

Version 10 of node.js has been released

Version 10 of Node.js (code name Dubnium) has been released! 🎊

To see what happens to your code in Node.js 10, Greenkeeper has created a branch with the following changes:

  • Added the new Node.js version to your .travis.yml

If you’re interested in upgrading this repo to Node.js 10, you can open a PR with these changes. Please note that this issue is just intended as a friendly reminder and the PR as a possible starting point for getting your code running on Node.js 10.

More information on this issue

Greenkeeper has checked the engines key in any package.json file, the .nvmrc file, and the .travis.yml file, if present.

  • engines was only updated if it defined a single version, not a range.
  • .nvmrc was updated to Node.js 10
  • .travis.yml was only changed if there was a root-level node_js that didn’t already include Node.js 10, such as node or lts/*. In this case, the new version was appended to the list. We didn’t touch job or matrix configurations because these tend to be quite specific and complex, and it’s difficult to infer what the intentions were.

For many simpler .travis.yml configurations, this PR should suffice as-is, but depending on what you’re doing it may require additional work or may not be applicable at all. We’re also aware that you may have good reasons to not update to Node.js 10, which is why this was sent as an issue and not a pull request. Feel free to delete it without comment, I’m a humble robot and won’t feel rejected 🤖


FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.