$ npm install @putout/plugin-esm
The static
importstatement is used toimportread only live bindings which are exported by another module. The imported bindings are called live bindings because they are updated by the module that exported the binding, but cannot be re-assigned by the importing module.(c) MDN
πPutout plugin adds ability to transform to new Node.js API and apply best practices.
npm i putout @putout/plugin-esm -D
{
"rules": {
"esm/declare-imports-first": "on",
"esm/group-imports-by-source": "on",
"esm/merge-duplicate-imports": "on",
"esm/remove-quotes-from-import-assertions": "on",
"esm/remove-empty-export": "on",
"esm/remove-empty-import": ["on", {
"ignore": []
}],
"esm/sort-imports-by-specifiers": "on"
}
}
Check out in πPutout Editor. For CommonJS use nodejs/declare-after-require.
const [arg] = process.argv;
import esbuild from 'esbuild';
import esbuild from 'esbuild';
const [arg] = process.argv;
Group order:
Checkout in πPutout Editor.
import fs from 'node:fs';
import {lodash} from 'lodash';
import react from 'react';
import d from '../hello.js';
import ss from '../../bb/ss.js';
import b from './ss.js';
const c = 5;
import fs from 'node:fs';
import react from 'react';
import {lodash} from 'lodash';
import b from './ss.js';
import d from '../hello.js';
import ss from '../../bb/ss.js';
const c = 5;
To disable use:
{
"rules": {
"esm/merge-duplicate-imports-join": "off"
}
}
import test from 'supertape';
import {stub} from 'supertape';
import test, {stub} from 'supertape';
Checkout in πPutout Editor.
To disable use:
{
"rules": {
"esm/merge-duplicate-imports-rename": "off"
}
}
import putout from './putout.js';
import all from './putout.js';
import x from './putout.js';
console.log(all);
console.log(x);
import putout from './putout.js';
console.log(putout);
console.log(putout);
-export {};
-import 'abc';
Checkout in πPutout Editor.
import json from './mod.json' with { type: 'json' };
import json from './mod.json' with { type: 'json' };
Checkout in πPutout Editor.
import {
a,
b,
c,
d,
} from 'd';
import a1 from 'a1';
import a1 from 'a1';
import {
a,
b,
c,
d,
} from 'd';
This feature would ideally use the
withkeyword to denote attributes, but there are existing implementations based on a previous version of the proposal using theassertkeyword. Due to potential web compatibility risks, the proposal still includesassertmarked as deprecated. Usage of the old syntax is discouraged, and its removal is being investigated.(c) tc39
Check out in πPutout Editor.
import json from './foo.json' assert { type: 'json' };
import('foo.json', {
assert: {
type: 'json',
},
});
import json from './foo.json' with { type: 'json' };
import('foo.json', {
with: {
type: 'json',
},
});
MIT
© 2010 - cnpmjs.org x YWFE | Home | YWFE