GithubHelp home page GithubHelp logo

jamietre / babel-plugin-transform-es2015-modules-commonjs-simple Goto Github PK

View Code? Open in Web Editor NEW
26.0 26.0 3.0 69 KB

Alterntative to default module transformer that does not mangle symbol names

License: MIT License

JavaScript 100.00%

babel-plugin-transform-es2015-modules-commonjs-simple's People

Contributors

jamietre avatar pluma 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

Watchers

 avatar  avatar  avatar  avatar

babel-plugin-transform-es2015-modules-commonjs-simple's Issues

Use const

Hello,

Thank you very much for this plugin, it is the only escape hatch I found for proper transpiling of modules to commonjs ones.

However, I noticed that it assigns the imported stuff to var statements.

var _sanctuary = require("sanctuary");

var map = _sanctuary.map;
var add = _sanctuary.add;
var ap = _sanctuary.ap;

I would prefer them to be constants. Do you think it could be possible ?

Thanks in advance

Can't properly transoform the short code: "this;"

Hi,

I am a programmer who found your plugin very useful and necessary for my research project. I need to disable name mangling, which is why I am using your plugin.

Unfortunately, I found two bugs in your plugin.. First, it incorrectly transforms the following simple code:

this;

I used the following code to transfer the above sample code:


const babel = require('@babel/core');
const fs = require('fs')

var args = process.argv.slice(2);
if (args.length != 1)
{  console.log("Usage: node transform <target .js>")
   process.exit(0);
}
const code = fs.readFileSync(args[0], 'utf8');
var result = babel.transform(code,
      {  retainLines: true,
         compact: false,
         sourceType: 'unambiguous',
         sourceMaps: true,
         //presets: ['@babel/preset-env'],
         plugins: [
            "@babel/transform-runtime",
            [ "@babel/plugin-transform-modules-commonjs",
               { 'strictMode': false }
            ],
            ["transform-es2015-modules-commonjs-simple",
               { 'noMangle': true}
            ]
         ]
      }).code;

console.log(result)

Your plugin converts "this;" into "use strict; undefined". The properly converted code should be "this;". I wonder if there is any quick fix or if you could apply the fix for me.. I would really appreciate it.

vue.js project: "exports is not defined" error

Runtime error in browser:

Uncaught ReferenceError: exports is not defined
    at Module../src/vuetify/index.js (app.js:93043)

Many warnings during compilation:

"export 'default' (imported as 'mod') was not found

babel.config.js:

module.exports = {
  presets: [
    [
      "@vue/app", {}
    ],
    ["@vue/babel-preset-jsx", {}]
  ],
   "plugins": [
        ["transform-es2015-modules-commonjs-simple", {
            "noMangle": true
        }]
    ],
};

Selective Mangle

Occasionally, it's really nice to support circular references. Otherwise, I love the noMangle option. What would be required to support an opt-in mangle usage. Something like:

import:live {thing} from '../../file';

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.