Security News
Opengrep Emerges as Open Source Alternative Amid Semgrep Licensing Controversy
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
@a-la/export
Advanced tools
A set of rules for alamode to transpile module.exports into ES6 export statement.
@a-la/export
is a a set of rules for alamode
to transpile ESM modules' export
statements into CJS modules' module.exports
statements in Node.js.
yarn add -E @a-la/export
The ÀLaImport is the default export and an array containing a sequence of rules for Replaceable.
import ÀLaExport from '@a-la/import'
The set of rules changes export
to module.exports
statements. module.exports
will be bound to the default
export if it is present, and all named exports will be assigned to module.exports
after that.
Input | Output |
---|---|
|
|
When there's an unnamed default such as export default class {}
or export default async function () {}
, it will be replaced in place. Since all named exports will be assigned at the end anyway, there shouldn't be a problem.
Input | Output |
---|---|
|
|
When exporting from another module, some private internal variables are created. It is currently not possible to export a default
either as named, or as default
from more than one module.
Input | Output |
---|---|
|
|
Input | Output |
---|---|
|
|
If the default export is a primitive type such as boolean or number, it is not possible to use named exports as well, because module.exports
will be binded to the primitive, and further assignments to module.exports.namedExport
will not have any effect.
module.exports = 'STRING' // primitive (string)
module.exports.example = function () {}
console.log(module.exports.example) // undefined
Serial exports of declarations are not possible as it's difficult to parse them using a regular expression.
// not possible
export const
a = 'test',
b = () => {}
When using the export from
statement, a private variable for the targeted module will be created, e.g., export { default } from test
will create const $test = require('test')
variable, therefore a collision could happen if a variable with such name was declared in the code.
export { name1, name2, …, nameN };
export { variable1 as name1, variable2 as name2, …, nameN };
export let name1, name2, …, nameN; // also var, const
export let name1 = …, name2 = …, …, nameN; // also var, const
export function FunctionName(){...}
export class ClassName {...}
export default expression;
export default function (…) { … } // also class, function*
export default function name1(…) { … } // also class, function*
export { name1 as default, … };
export * from …;
export { name1, name2, …, nameN } from …;
export { import1 as name1, import2 as name2, …, nameN } from …;
export { default } from …;
The transform will attempt to preserve line and column numbers as they are for easier generation of source maps by alamode
. In future, this might change.
(c) À La Mode 2018
FAQs
A set of rules for ÀLaMode to transpile ES6 export statements into module.exports assignments.
The npm package @a-la/export receives a total of 8 weekly downloads. As such, @a-la/export popularity was classified as not popular.
We found that @a-la/export 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
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.