
Security News
TC39 Advances 11 Proposals for Math Precision, Binary APIs, and More
TC39 advances 11 JavaScript proposals, with two moving to Stage 4, bringing better math, binary APIs, and more features one step closer to the ECMAScript spec.
ES2015 to CommonJS import/export transformer
Fully based on ascjs, asbundle is a no-brainer to create out of the box browser compatible bundles. Don't miss it out!
This module does one thing only: it loosely transpiles ES2015 import/export statements into valid CommonJS in order to fix the only part of Node that's incompatible with modern JS.
You can use ascjs as binary utility or as module.
npm install -g ascjs
# to see what you can do
ascjs --help
As executable, you can use ascjs to output, or save, some code content.
ascjs code
ascjs --ignore=a.js,b.js sourceFile
ascjs --no-default
ascjs sourceFile
ascjs sourceFile destFile
# folders are recursively parsed
# destFolder is mandatory
ascjs sourceFolder destFolder
You can also use it via pipe operator.
echo code | ascjs
cat source.js | ascjs | uglifyjs -o dest.js
As module, you can require it and use it to convert ESM to CJS.
const ascjs = require('ascjs');
ascjs('import "test";');
// require("test");
export default ...
intent as exports.default
.js
code and transform it for Node only before publishing on npm.mjs
modules and transform them into CommonJS for Browserify or other bundlers as targetimport(...)
is untouched. If you write that, let Webpack handle it for you later on--ignore=...
a comma separated paths to ignore parsing--no-default
remove the __esModule
flag and export default via module.exports =
This module can transform the following ES2015+ code
import func, {a, b} from './module.js';
import * as tmp from 'other';
const val = 123;
export default function test() {
console.log('ascjs');
};
export {func, val};
into the following one:
'use strict';
const func = (m => m.__esModule ? m.default : m)(require('./module.js'));
const {a, b} = require('./module.js');
const tmp = require('other');
const val = 123;
function test() {
console.log('ascjs');
}
Object.defineProperty(exports, '__esModule', {value: true}).default = test;
exports.func = func;
exports.val = val;
FAQs
ES2015 to CommonJS import/export transformer
The npm package ascjs receives a total of 3,870 weekly downloads. As such, ascjs popularity was classified as popular.
We found that ascjs 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
TC39 advances 11 JavaScript proposals, with two moving to Stage 4, bringing better math, binary APIs, and more features one step closer to the ECMAScript spec.
Research
/Security News
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
Product
Customize license detection with Socket’s new license overlays: gain control, reduce noise, and handle edge cases with precision.