0.0.9 • Published 5 years ago

@hqjs/babel-plugin-transform-modules v0.0.9

Weekly downloads
6
License
MIT
Repository
github
Last release
5 years ago

https://hqjs.org

Transform CommonJS modules files into ES modules

Installation

npm install hqjs@babel-plugin-transform-modules

Transformation

Can recognise UMD files and mixed import, export with require statements. Turns dynamic require into static imports. Transforms double default.

It will turn

import a from 'a';
import b from 'b';

let t;
if (process.env.NODE_ENV === 'production') {
  require('x');
} else {
  t = require('y');
}

import 'w';

export const z = 0;

export default class A {}

exports.q = 1;

exports.default = {t};

module.exports = {a};

into

import a from 'a';
import b from 'b';
import "x";
import _ref2 from "y";
import 'w';
const _ref = {
  exports: {}
};

(function (module, exports) {
  let t;

  if (process.env.NODE_ENV === 'production') {} else {
    t = _ref2;
  }

  exports.z = 0;

  class A {}

  exports.q = 1;
  module.exports = Object.assign(A, exports);
  module.exports = {
    t
  };
  module.exports = {
    a
  };
})(_ref, _ref.exports);

export default _ref.exports;
0.0.9

5 years ago

0.0.8

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

6 years ago

0.0.1

7 years ago