Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
6to5 turns ES6 code into vanilla ES5, so you can use ES6 features today.
$ npm install -g 6to5
To be implemented:
Compile the file script.js
and output it to script-compiled.js
.
$ 6to5 script.js -o script-compiled.js
Compile the entire src
directory and output it to the lib
directory.
$ 6to5 src -d lib
Compile the file script.js
and output it to stdout.
$ 6to5 script.js
Launch a repl.
$ 6to5-node
Evaluate code.
$ 6to5-node -e "class Test { }"
Compile and run test.js
.
$ 6to5-node test
var to5 = require("6to5");
to5.transform("code();");
to5.transformFileSync("filename.js");
to5.transformFile("filename.js", function (err, data) {
});
to5.transform("code();", {
// List of transformers to EXCLUDE
// This is a camelised version of the name found in `features`
// eg. "Arrow functions" is "arrowFunctions"
blacklist: [],
// List of transformers to ONLY use.
// See `blacklist` for naming scheme.
whitelist: [],
// Append source map and comment to bottom of returned output.
sourceMap: false,
// Returns an object `{ code: "", map: {} }` instead of an appended string.
sourceMapObject: false,
// Filename for use in errors etc.
filename: "unknown",
// Format options
// See https://github.com/Constellation/escodegen/wiki/API for options.
format: {}
});
All subsequent files required by node will be transformed into ES5 compatible code. An ES6 polyfill is also required negating the polyfill caveat.
require("6to5/register");
6to5 does not include a runtime nor polyfill and it's up to the developer to include one in compiled browser code.
A polyfill is included with 6to5 code that can be included in node like so:
require("6to5/polyfill");
This is simply a wrapper around the es6-shim and es6-symbol polyfills.
When using the require hook the aforementioned polyfill is required.
If you're planning on using 6to5 output in the browser then it's up to you to include polyfills. es6-symbol and es6-shim support the vast majority of polyfill concerns.
Iterator/Symbol polyfill required.
Built-in classes such as Date
, Array
and DOM
cannot be subclassed due to
limitations in ES5 implementations.
6to5 is different to Traceur in a few very distinct ways.
Traceur requires quite a bulky runtime (~75KB) and produces quite verbose code. While this can be trimmed down by selectively building the runtime, it's an unneccesary step when a runtime can be eliminated entirely.
Instead of mapping to a runtime, 6to5 maps directly to the equivalent ES5. This means that your transpiled code will be as simple as possible.
FAQs
Turn ES6 code into readable vanilla ES5 with source maps
The npm package 6to5 receives a total of 297 weekly downloads. As such, 6to5 popularity was classified as not popular.
We found that 6to5 demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.