jamietre / babel-plugin-transform-es2015-modules-commonjs-simple Goto Github PK
View Code? Open in Web Editor NEWAlterntative to default module transformer that does not mangle symbol names
License: MIT License
Alterntative to default module transformer that does not mangle symbol names
License: MIT License
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
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.
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
}]
],
};
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';
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.