{"_id":"cjs2esmodule","_rev":"2798142","name":"cjs2esmodule","description":"将commonjs转为es module，可在vite中使用，也可直接转换文件","dist-tags":{"latest":"1.1.1"},"maintainers":[{"name":"ma125120","email":"1251208555@qq.com"}],"time":{"modified":"2022-07-18T11:45:15.000Z","created":"2021-03-11T08:47:52.349Z","1.1.1":"2021-03-25T05:32:35.461Z","1.1.0":"2021-03-19T02:39:02.579Z","1.0.2":"2021-03-12T07:03:18.991Z","1.0.1":"2021-03-11T10:06:38.469Z","1.0.0":"2021-03-11T09:48:20.050Z","0.1.0":"2021-03-11T08:54:35.699Z","0.0.2":"2021-03-11T08:48:20.394Z","0.0.1":"2021-03-11T08:47:52.349Z"},"users":{},"author":{"name":"马鹏达"},"repository":{"type":"git","url":"git+ssh://git@github.com/ma125120/cjs2esmodule.git"},"versions":{"1.1.1":{"name":"cjs2esmodule","version":"1.1.1","main":"lib/index.js","description":"将commonjs转为es module，可在vite中使用，也可直接转换文件","license":"MIT","repository":{"type":"git","url":"git+ssh://git@github.com/ma125120/cjs2esmodule.git"},"author":{"name":"马鹏达"},"email":"1251208555@qq.com","scripts":{"bd":"yarn tsc --declaration","test":"jest --config=jest.config.js","release":"standard-version","release:rc":"standard-version --prerelease rc","pup":"npm run release && git push --follow-tags origin master","pub":"npm run pup && npm publish","cz":"cz"},"keywords":["vite","vite plugin","commonjs to es module"],"dependencies":{"@babel/cli":"^7.13.10","@babel/core":"^7.13.10","@babel/preset-env":"^7.13.10","glob":"^7.1.6"},"devDependencies":{"@commitlint/cli":"^12.0.1","@commitlint/config-conventional":"^12.0.1","@types/jest":"^26.0.20","@types/node":"^14.14.33","@typescript-eslint/eslint-plugin":"^4.18.0","@typescript-eslint/parser":"^4.18.0","babel-jest":"^26.6.3","commitizen":"^4.2.3","eslint":"^7.22.0","husky":"^5.1.3","jest":"^26.6.3","lint-staged":"^10.5.4","standard-version":"^9.1.1","ts-jest":"^26.5.3","typescript":"^4.2.3"},"lint-staged":{"*.[jt]sx?":"eslint --fix"},"commitlint":{"extends":["@commitlint/config-conventional"]},"gitHead":"0f8b4c66651ee243993cb2bdc4b459061e9e2979","bugs":{"url":"https://github.com/ma125120/cjs2esmodule/issues"},"homepage":"https://github.com/ma125120/cjs2esmodule#readme","_id":"cjs2esmodule@1.1.1","_nodeVersion":"12.18.3","_npmVersion":"6.14.6","dist":{"shasum":"2833a04ef9ba558ebcd810f29327fde43d4fe739","size":89096,"noattachment":false,"key":"/cjs2esmodule/-/cjs2esmodule-1.1.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/cjs2esmodule/download/cjs2esmodule-1.1.1.tgz"},"_npmUser":{"name":"ma125120","email":"1251208555@qq.com"},"directories":{},"maintainers":[{"name":"ma125120","email":"1251208555@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/cjs2esmodule_1.1.1_1616650355331_0.48826227079287654"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2021-12-27T08:32:36.931Z","publish_time":1616650355461,"_cnpm_publish_time":1616650355461},"1.1.0":{"name":"cjs2esmodule","version":"1.1.0","main":"lib/index.js","description":"将commonjs转为es module，可在vite中使用，也可直接转换文件","license":"MIT","repository":{"type":"git","url":"git+ssh://git@github.com/ma125120/cjs2esmodule.git"},"author":{"name":"马鹏达"},"email":"1251208555@qq.com","scripts":{"bd":"yarn tsc --declaration","test":"jest --config=jest.config.js","release":"standard-version","release:rc":"standard-version --prerelease rc","pup":"npm run release && git push --follow-tags origin master","pub":"npm run pup && npm publish","cz":"cz"},"keywords":["vite","vite plugin","commonjs to es module"],"dependencies":{"@babel/cli":"^7.13.10","@babel/core":"^7.13.10","@babel/preset-env":"^7.13.10","glob":"^7.1.6"},"devDependencies":{"@commitlint/cli":"^12.0.1","@commitlint/config-conventional":"^12.0.1","@types/jest":"^26.0.20","@types/node":"^14.14.33","@typescript-eslint/eslint-plugin":"^4.18.0","@typescript-eslint/parser":"^4.18.0","babel-jest":"^26.6.3","commitizen":"^4.2.3","eslint":"^7.22.0","husky":"^5.1.3","jest":"^26.6.3","lint-staged":"^10.5.4","standard-version":"^9.1.1","ts-jest":"^26.5.3","typescript":"^4.2.3"},"lint-staged":{"*.[jt]sx?":"eslint --fix"},"commitlint":{"extends":["@commitlint/config-conventional"]},"gitHead":"0f8b4c66651ee243993cb2bdc4b459061e9e2979","bugs":{"url":"https://github.com/ma125120/cjs2esmodule/issues"},"homepage":"https://github.com/ma125120/cjs2esmodule#readme","_id":"cjs2esmodule@1.1.0","_nodeVersion":"14.16.0","_npmVersion":"6.14.11","dist":{"shasum":"2159c6fd4d8b4470ef7871f2a14b04250caa8700","size":30758,"noattachment":false,"key":"/cjs2esmodule/-/cjs2esmodule-1.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/cjs2esmodule/download/cjs2esmodule-1.1.0.tgz"},"_npmUser":{"name":"ma125120","email":"1251208555@qq.com"},"directories":{},"maintainers":[{"name":"ma125120","email":"1251208555@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/cjs2esmodule_1.1.0_1616121542416_0.6760580172113535"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2021-12-27T08:32:35.334Z","publish_time":1616121542579,"_cnpm_publish_time":1616121542579},"1.0.2":{"name":"cjs2esmodule","version":"1.0.2","main":"lib/index.js","description":"将commonjs转为es module，可在vite中使用，也可直接转换文件","license":"MIT","repository":{"type":"git","url":"git+ssh://git@github.com/ma125120/cjs2esmodule.git"},"author":{"name":"马鹏达"},"email":"1251208555@qq.com","scripts":{"gen":"yarn tsc --declaration","test":"jest --config=jest.config.js"},"keywords":["vite","vite plugin","commonjs to es module"],"dependencies":{"@babel/cli":"^7.13.10","@babel/core":"^7.13.10","@babel/preset-env":"^7.13.10","glob":"^7.1.6"},"devDependencies":{"@types/jest":"^26.0.20","@types/node":"^14.14.33","jest":"^26.6.3","ts-jest":"^26.5.3","typescript":"^4.2.3"},"gitHead":"6d68e45271ce86a285f463bec11a97d98f7f179a","bugs":{"url":"https://github.com/ma125120/cjs2esmodule/issues"},"homepage":"https://github.com/ma125120/cjs2esmodule#readme","_id":"cjs2esmodule@1.0.2","_nodeVersion":"12.18.3","_npmVersion":"6.14.6","dist":{"shasum":"0bb1aa15f5452cee59f90196d7c105d14a1a23bc","size":86528,"noattachment":false,"key":"/cjs2esmodule/-/cjs2esmodule-1.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/cjs2esmodule/download/cjs2esmodule-1.0.2.tgz"},"_npmUser":{"name":"ma125120","email":"1251208555@qq.com"},"directories":{},"maintainers":[{"name":"ma125120","email":"1251208555@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/cjs2esmodule_1.0.2_1615532598850_0.2129798926737987"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2021-12-27T08:32:33.796Z","publish_time":1615532598991,"_cnpm_publish_time":1615532598991},"1.0.1":{"name":"cjs2esmodule","version":"1.0.1","main":"lib/index.js","description":"将commonjs转为es module，可在vite中使用，也可直接转换文件","license":"MIT","repository":{"type":"git","url":"git+ssh://git@github.com/ma125120/cjs2esmodule.git"},"author":{"name":"马鹏达"},"email":"1251208555@qq.com","scripts":{"gen":"yarn tsc --declaration","test":"jest --config=jest.config.js"},"keywords":[],"dependencies":{"@babel/cli":"^7.13.10","@babel/core":"^7.13.10","@babel/preset-env":"^7.13.10","glob":"^7.1.6"},"devDependencies":{"@types/jest":"^26.0.20","@types/node":"^14.14.33","jest":"^26.6.3","ts-jest":"^26.5.3","typescript":"^4.2.3"},"gitHead":"3151d092b47558047c462e3cc9e27ca01e2c07f3","bugs":{"url":"https://github.com/ma125120/cjs2esmodule/issues"},"homepage":"https://github.com/ma125120/cjs2esmodule#readme","_id":"cjs2esmodule@1.0.1","_nodeVersion":"12.18.3","_npmVersion":"6.14.6","dist":{"shasum":"2162e26139efdebb90d3957493eaea18501c1f3d","size":86385,"noattachment":false,"key":"/cjs2esmodule/-/cjs2esmodule-1.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/cjs2esmodule/download/cjs2esmodule-1.0.1.tgz"},"_npmUser":{"name":"ma125120","email":"1251208555@qq.com"},"directories":{},"maintainers":[{"name":"ma125120","email":"1251208555@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/cjs2esmodule_1.0.1_1615457198259_0.003996854420673879"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2021-12-27T08:32:31.808Z","publish_time":1615457198469,"_cnpm_publish_time":1615457198469},"1.0.0":{"name":"cjs2esmodule","version":"1.0.0","main":"lib/index.js","description":"将commonjs转为es module，可在vite中使用，也可直接转换文件","license":"MIT","repository":{"type":"git","url":"git+ssh://git@github.com/ma125120/cjs2esmodule.git"},"author":{"name":"马鹏达"},"email":"1251208555@qq.com","scripts":{"gen":"yarn tsc --declaration","test":"jest --config=jest.config.js"},"keywords":[],"dependencies":{"@babel/cli":"^7.13.10","@babel/core":"^7.13.10","@babel/preset-env":"^7.13.10","glob":"^7.1.6"},"devDependencies":{"@types/jest":"^26.0.20","@types/node":"^14.14.33","jest":"^26.6.3","ts-jest":"^26.5.3","typescript":"^4.2.3"},"gitHead":"f8c1078316fc849e8deb2a620621b253666b2a99","bugs":{"url":"https://github.com/ma125120/cjs2esmodule/issues"},"homepage":"https://github.com/ma125120/cjs2esmodule#readme","_id":"cjs2esmodule@1.0.0","_nodeVersion":"12.18.3","_npmVersion":"6.14.6","dist":{"shasum":"d91cc22b57473af9411c9d51875b20771b982fec","size":86183,"noattachment":false,"key":"/cjs2esmodule/-/cjs2esmodule-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/cjs2esmodule/download/cjs2esmodule-1.0.0.tgz"},"_npmUser":{"name":"ma125120","email":"1251208555@qq.com"},"directories":{},"maintainers":[{"name":"ma125120","email":"1251208555@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/cjs2esmodule_1.0.0_1615456099932_0.11226803762962012"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2021-12-27T08:32:30.355Z","publish_time":1615456100050,"_cnpm_publish_time":1615456100050},"0.1.0":{"name":"cjs2esmodule","version":"0.1.0","main":"lib/index.js","description":"将commonjs转为es module，可在vite中使用，也可直接转换文件","license":"MIT","repository":{"type":"git","url":"git+ssh://git@github.com/ma125120/cjs2esmodule.git"},"author":{"name":"马鹏达"},"email":"1251208555@qq.com","scripts":{"gen":"yarn tsc --declaration","test":"jest --config=jest.config.js"},"keywords":[],"dependencies":{"@babel/cli":"^7.13.10","@babel/core":"^7.13.10","@babel/preset-env":"^7.13.10","glob":"^7.1.6"},"devDependencies":{"@types/jest":"^26.0.20","@types/node":"^14.14.33","jest":"^26.6.3","ts-jest":"^26.5.3","typescript":"^4.2.3"},"bugs":{"url":"https://github.com/ma125120/cjs2esmodule/issues"},"homepage":"https://github.com/ma125120/cjs2esmodule#readme","_id":"cjs2esmodule@0.1.0","_nodeVersion":"12.18.3","_npmVersion":"6.14.6","dist":{"shasum":"235f2c0303ff89e5681a2a5ca25720db69f7c8de","size":85866,"noattachment":false,"key":"/cjs2esmodule/-/cjs2esmodule-0.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/cjs2esmodule/download/cjs2esmodule-0.1.0.tgz"},"_npmUser":{"name":"ma125120","email":"1251208555@qq.com"},"directories":{},"maintainers":[{"name":"ma125120","email":"1251208555@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/cjs2esmodule_0.1.0_1615452875516_0.6291810186700246"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2021-12-27T08:32:28.940Z","publish_time":1615452875699,"_cnpm_publish_time":1615452875699},"0.0.2":{"name":"cjs2esmodule","version":"0.0.2","main":"lib/index.js","description":"将commonjs转为es module，可在vite中使用，也可直接转换文件","license":"MIT","repository":{"type":"git","url":"git+ssh://git@github.com/ma125120/cjs2esmodule.git"},"author":{"name":"马鹏达"},"email":"1251208555@qq.com","scripts":{"gen":"yarn tsc --declaration","test":"jest --config=jest.config.js"},"keywords":[],"dependencies":{"@babel/cli":"^7.13.10","@babel/core":"^7.13.10","@babel/preset-env":"^7.13.10","glob":"^7.1.6"},"devDependencies":{"@types/jest":"^26.0.20","@types/node":"^14.14.33","jest":"^26.6.3","ts-jest":"^26.5.3","typescript":"^4.2.3"},"bugs":{"url":"https://github.com/ma125120/cjs2esmodule/issues"},"homepage":"https://github.com/ma125120/cjs2esmodule#readme","_id":"cjs2esmodule@0.0.2","_nodeVersion":"12.18.3","_npmVersion":"6.14.6","dist":{"shasum":"1287fba29f1c0186ab5650430758d1fb3a0a6f67","size":60781,"noattachment":false,"key":"/cjs2esmodule/-/cjs2esmodule-0.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/cjs2esmodule/download/cjs2esmodule-0.0.2.tgz"},"_npmUser":{"name":"ma125120","email":"1251208555@qq.com"},"directories":{},"maintainers":[{"name":"ma125120","email":"1251208555@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/cjs2esmodule_0.0.2_1615452500173_0.14128853928452179"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2021-12-27T08:32:27.543Z","publish_time":1615452500394,"_cnpm_publish_time":1615452500394},"0.0.1":{"name":"cjs2esmodule","version":"0.0.1","main":"lib/index.js","description":"将commonjs转为es module，可在vite中使用，也可直接转换文件","license":"MIT","repository":{"type":"git","url":"git+ssh://git@github.com/ma125120/cjs2esm.git"},"author":{"name":"马鹏达"},"email":"1251208555@qq.com","scripts":{"gen":"yarn tsc --declaration","test":"jest --config=jest.config.js"},"keywords":[],"dependencies":{"@babel/cli":"^7.13.10","@babel/core":"^7.13.10","@babel/preset-env":"^7.13.10","glob":"^7.1.6"},"devDependencies":{"@types/jest":"^26.0.20","@types/node":"^14.14.33","jest":"^26.6.3","ts-jest":"^26.5.3","typescript":"^4.2.3"},"bugs":{"url":"https://github.com/ma125120/cjs2esm/issues"},"homepage":"https://github.com/ma125120/cjs2esm#readme","_id":"cjs2esmodule@0.0.1","_nodeVersion":"12.18.3","_npmVersion":"6.14.6","dist":{"shasum":"f8c712f3c9f362b59e21f1aef1e3e991466adae1","size":60778,"noattachment":false,"key":"/cjs2esmodule/-/cjs2esmodule-0.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/cjs2esmodule/download/cjs2esmodule-0.0.1.tgz"},"_npmUser":{"name":"ma125120","email":"1251208555@qq.com"},"directories":{},"maintainers":[{"name":"ma125120","email":"1251208555@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/cjs2esmodule_0.0.1_1615452472178_0.9304239207241813"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2021-12-27T08:32:26.008Z","publish_time":1615452472349,"_cnpm_publish_time":1615452472349}},"readme":"## 转换效果\r\n![avatar](./1.png)\r\n\r\n## 安装\r\n\r\n```cmd\r\nnpm i cjs2esmodule\r\n// 或者\r\nyarn add cjs2esmodule\r\n```\r\n\r\n## 使用\r\n\r\n### 在vite中使用\r\n该方式会使用 babel 转换 AST，所以如果速度慢的话，推荐使用脚本直接转换文件\r\n\r\n```js\r\nimport { defineConfig } from 'vite'\r\nimport { cjs2esmVitePlugin } from 'cjs2esmodule'\r\n\r\n// https://vitejs.dev/config/\r\nexport default defineConfig({\r\n  plugins: [cjs2esmVitePlugin()]\r\n})\r\n```\r\n\r\n### 使用脚本直接转换文件\r\n底层使用了glob，所以文件匹配模式遵循 glob\r\n\r\n```js\r\nconst { transformFiles } = require('cjs2esmodule')\r\n\r\ntransformFiles('./scripts/test.js')\r\n// 支持数组\r\ntransformFiles(['./utils/*.js', './components/*.js'])\r\n```\r\n","_attachments":{},"homepage":"https://github.com/ma125120/cjs2esmodule#readme","bugs":{"url":"https://github.com/ma125120/cjs2esmodule/issues"},"license":"MIT"}