{"name":"@putout/plugin-esm","version":"1.0.1","keywords":["putout","putout-plugin","plugin","esm"],"author":{"url":"https://github.com/coderaiser","name":"coderaiser","email":"mnemonic.enemy@gmail.com"},"license":"MIT","_id":"@putout/plugin-esm@1.0.1","homepage":"https://github.com/coderaiser/putout/tree/master/packages/plugin-esm#readme","bugs":{"url":"https://github.com/coderaiser/putout/issues"},"tag":false,"dist":{"shasum":"232867335d7c6d58c7722115c70a277cc446870e","tarball":"http://registry-npm.ywwl.com/@putout/plugin-esm/download/@putout/plugin-esm-1.0.1.tgz","fileCount":12,"integrity":"sha512-LEjQAWoZ0Qbqd7QVxh82uRosBw60AWWjpUDQbKKZ6irFECxVMzc6byvFpG58v0FwehSNypLuVdkpC7ulkb5pyQ==","signatures":[{"sig":"MEUCICe7a05dETNwHJC9MGle96gzOIhMhmp5pw6z6vOYAADLAiEAsG6O4BZdbbZz8DWNXlP7vHOohxpRe3GBjNOy2TFqGM4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":18237,"size":5314,"noattachment":false,"key":"/@putout/plugin-esm/-/@putout/plugin-esm-1.0.1.tgz"},"main":"lib/index.js","type":"commonjs","engines":{"node":">=18"},"exports":{".":"./lib/index.js"},"gitHead":"e13017c627f66e99bdab9d8cca9717c345383c8a","release":false,"scripts":{"lint":"madrun lint","test":"madrun test","report":"madrun report","coverage":"madrun coverage","fix:lint":"madrun fix:lint","fresh:lint":"madrun fresh:lint","lint:fresh":"madrun lint:fresh","watch:test":"madrun watch:test"},"_npmUser":{"name":"coderaiser","email":"mnemonic.enemy@gmail.com"},"changelog":false,"repository":{"url":"git+https://github.com/coderaiser/putout.git","type":"git"},"_npmVersion":"10.9.0","description":"🐊Putout plugin improves ability to transform ESM code","directories":{},"_nodeVersion":"20.18.1","dependencies":{"parse-import-specifiers":"^1.0.3"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"c8":"^10.0.0","lerna":"^6.0.1","eslint":"^9.0.0","madrun":"^10.0.0","montag":"^1.2.1","nodemon":"^3.0.1","@putout/test":"^11.0.0","eslint-plugin-n":"^17.0.0","@putout/eslint-flat":"^2.0.0","@putout/plugin-tape":"*","eslint-plugin-putout":"^23.0.0","@putout/plugin-nodejs":"*","@putout/plugin-putout":"*","@putout/plugin-declare":"*","@putout/plugin-typescript":"*","@putout/plugin-reuse-duplicate-init":"*","@putout/plugin-declare-before-reference":"*"},"peerDependencies":{"putout":">=37"},"_npmOperationalInternal":{"tmp":"tmp/plugin-esm_1.0.1_1734816274152_0.8970267834286676","host":"s3://npm-registry-packages-npm-production"},"readme":"# @putout/plugin-esm [![NPM version][NPMIMGURL]][NPMURL]\n\n[NPMIMGURL]: https://img.shields.io/npm/v/@putout/plugin-esm.svg?style=flat&longCache=true\n[NPMURL]: https://npmjs.org/package/@putout/plugin-esm \"npm\"\n\n> The static `import` statement is used to `import` read only live bindings which are exported by another module.\n> 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.\n>\n> (c) [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import)\n\n🐊[**Putout**](https://github.com/coderaiser/putout) plugin adds ability to transform to new **Node.js** API and apply best practices.\n\n## Install\n\n```\nnpm i putout @putout/plugin-esm -D\n```\n\n## Rules\n\n- ✅ [declare-imports-first](#declare-imports-first);\n- ✅ [group-imports-by-source](#group-imports-by-source);\n- ✅ [merge-duplicate-imports](#merge-duplicate-imports);\n- ✅ [remove-quotes-from-import-assertions](#remove-quotes-from-import-assertions);\n- ✅ [remove-empty-import](#remove-empty-import);\n- ✅ [remove-empty-export](#remove-empty-export);\n- ✅ [sort-imports-by-specifiers](#sort-imports-by-specifiers);\n\n## Config\n\n```json\n{\n    \"rules\": {\n        \"esm/declare-imports-first\": \"on\",\n        \"esm/group-imports-by-source\": \"on\",\n        \"esm/merge-duplicate-imports\": \"on\",\n        \"esm/remove-quotes-from-import-assertions\": \"on\",\n        \"esm/remove-empty-export\": \"on\",\n        \"esm/remove-empty-import\": [\"on\", {\n            \"ignore\": []\n        }],\n        \"esm/sort-imports-by-specifiers\": \"on\"\n    }\n}\n```\n\n## declare-imports-first\n\nCheck out in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/b1c18e5d726afe4ebb69d6b7a7dda82b/8189590815a1b8adb35bb8a846e28228e3c7fadf). For **CommonJS** use [nodejs/declare-after-require](https://github.com/coderaiser/putout/tree/master/packages/plugin-nodejs#declare-after-require).\n\n## ❌ Example of incorrect code\n\n```js\nconst [arg] = process.argv;\nimport esbuild from 'esbuild';\n```\n\n## ✅ Example of correct code\n\n```js\nimport esbuild from 'esbuild';\n\nconst [arg] = process.argv;\n```\n\n## group-imports-by-source\n\nGroup order:\n\n- ✅ builtins;\n- ✅ external;\n- ✅ internal;\n\nCheckout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/3cc782acf95211f9d456d63a99032ee1/0674223d050bba572f5271ffdccf8616cb441af5).\n\n## ❌ Example of incorrect code\n\n```js\nimport fs from 'node:fs';\nimport {lodash} from 'lodash';\nimport react from 'react';\nimport d from '../hello.js';\nimport ss from '../../bb/ss.js';\nimport b from './ss.js';\n\nconst c = 5;\n```\n\n## ✅ Example of correct code\n\n```js\nimport fs from 'node:fs';\nimport react from 'react';\nimport {lodash} from 'lodash';\nimport b from './ss.js';\nimport d from '../hello.js';\nimport ss from '../../bb/ss.js';\n\nconst c = 5;\n```\n\n## merge-duplicate-imports\n\n### join\n\nTo disable use:\n\n```json\n{\n    \"rules\": {\n        \"esm/merge-duplicate-imports-join\": \"off\"\n    }\n}\n```\n\n#### ❌ Example of incorrect code\n\n```js\nimport test from 'supertape';\nimport {stub} from 'supertape';\n```\n\n#### ✅ Example of correct code\n\n```js\nimport test, {stub} from 'supertape';\n```\n\n### rename\n\nCheckout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/6604936dec6b1eed8ce0d143f2962f15/17b310a6e4d85b0b8615a8b91d0e27414e8af291).\n\nTo disable use:\n\n```json\n{\n    \"rules\": {\n        \"esm/merge-duplicate-imports-rename\": \"off\"\n    }\n}\n```\n\n#### ❌ Example of incorrect code\n\n```js\nimport putout from './putout.js';\nimport all from './putout.js';\nimport x from './putout.js';\n\nconsole.log(all);\nconsole.log(x);\n```\n\n#### ✅ Example of correct code\n\n```js\nimport putout from './putout.js';\n\nconsole.log(putout);\nconsole.log(putout);\n```\n\n## remove-empty-export\n\n```diff\n-export {};\n```\n\n## remove-empty-import\n\n```diff\n-import 'abc';\n```\n\n## remove-quotes-from-import-assertions\n\nCheckout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/f9f34acddbefba0ded53225ca10fa44e/7b4dba44602b9b2d28fe3a98989474a4b0d8d73d).\n\n### ❌ Example of incorrect code\n\n```js\nimport json from './mod.json' with { type: 'json' };\n```\n\n## ✅ Example of correct code\n\n```js\nimport json from './mod.json' with { type: 'json' };\n```\n\n## sort-imports-by-specifiers\n\nCheckout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/521e2ff199243a7ce1f65db7140c272e/28c0588281286f8a6765b8aa2ecabbfcde2973a7).\n\n### ❌ Example of incorrect code\n\n```js\nimport {\n    a,\n    b,\n    c,\n    d,\n} from 'd';\nimport a1 from 'a1';\n```\n\n### ✅ Example of correct code\n\n```js\nimport a1 from 'a1';\nimport {\n    a,\n    b,\n    c,\n    d,\n} from 'd';\n```\n\n## convert-assert-to-with\n\n> This feature would ideally use the `with` keyword to denote attributes, but there are existing implementations based on a previous version of the proposal using the `assert` keyword. Due to potential web compatibility risks, the proposal still includes `assert` marked as deprecated. Usage of the old syntax is discouraged, and its removal is being investigated.\n>\n> (c) [tc39](https://tc39.es/proposal-import-attributes/)\n\nCheck out in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/9f85897b998c6458efc19db6a5414b79/57ef7cdd113c7a0087e0f7a6e70522f60baa04f4).\n\n## ❌ Example of incorrect code\n\n```js\nimport json from './foo.json' assert { type: 'json' };\n\nimport('foo.json', {\n    assert: {\n        type: 'json',\n    },\n});\n```\n\n## ✅ Example of correct code\n\n```js\nimport json from './foo.json' with { type: 'json' };\n\nimport('foo.json', {\n    with: {\n        type: 'json',\n    },\n});\n```\n\n## License\n\nMIT\n","publish_time":1734816274369,"maintainers":[{"name":"coderaiser","email":"mnemonic.enemy@gmail.com"}],"_cnpm_publish_time":1734816274369,"dist-tags":{"latest":"10.12.1"}}