{"versions":{"0.0.1":{"name":"bundle-import","version":"0.0.1","type":"module","description":"Bundle and load a file using the import-from-string.","imports":{"#*":"./*"},"exports":{".":{"require":"./dist/index.cjs","import":"./dist/index.mjs"}},"main":"dist/index.cjs","module":"dist/index.mjs","types":"dist/index.d.cts","typesVersions":{"*":{"*":["./dist/*","./dist/index.d.ts"]}},"repository":{"type":"git","url":"git+https://github.com/condorheroblog/bundle-import.git"},"keywords":["module-from-string","load-from-config","bundle-import","bundle-require","bundle-import"],"author":{"name":"CondorHero"},"license":"MIT","bugs":{"url":"https://github.com/condorheroblog/bundle-import/issues"},"homepage":"https://github.com/condorheroblog/bundle-import#readme","dependencies":{"get-tsconfig":"^4.7.2","import-from-string":"^0.0.4"},"simple-git-hooks":{"pre-commit":"npx lint-staged"},"lint-staged":{"*.{ts,js,mjs,cjs,json}":["eslint --fix","prettier --write"],"*.md":["eslint --fix"]},"devDependencies":{"@rollup/plugin-json":"^6.0.1","@trivago/prettier-plugin-sort-imports":"^4.2.1","@types/node":"^20.8.10","@typescript-eslint/eslint-plugin":"^6.10.0","@typescript-eslint/parser":"^6.10.0","bumpp":"^9.2.0","eslint":"^8.52.0","eslint-config-prettier":"^9.0.0","eslint-plugin-import":"^2.29.0","eslint-plugin-mdx":"^2.2.0","eslint-plugin-node-import":"^1.0.4","eslint-plugin-prettier":"^5.0.1","esno":"^0.17.0","lint-staged":"^15.0.2","prettier":"^3.0.3","rimraf":"^5.0.5","rollup":"^4.3.0","rollup-plugin-dts":"^6.1.0","rollup-plugin-esbuild":"^6.1.0","rollup-plugin-node-externals":"^6.1.2","simple-git-hooks":"^2.9.0","typescript":"^5.2.2","vitest":"^0.34.6"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org"},"scripts":{"dev:esm":"esno playground/index.mjs","dev:cjs":"esno playground/index.cjs","lint":"eslint .","lint:fix":"eslint . --fix","format":"prettier --write .","test":"vitest","build":"rimraf dist && rollup -c","build:watch":"rimraf dist && rollup -c -w","typecheck":"tsc --noEmit","release":"bumpp -r && pnpm -r publish --access public"},"_id":"bundle-import@0.0.1","_integrity":"sha512-L0z0iPX7t7ff5eZsK7oMEH+Ly2lzJczFKPHwrta6X8SF64a20R3wOrAOYK1MzHZVaWWugg9qlSTVfVwqvQJ2dw==","_resolved":"/private/var/folders/7j/t79xy7qs13ld89z06lzx68t00000gn/T/315426d467215d70d89abe691db926b4/bundle-import-0.0.1.tgz","_from":"file:bundle-import-0.0.1.tgz","_nodeVersion":"18.16.0","_npmVersion":"9.5.1","dist":{"integrity":"sha512-L0z0iPX7t7ff5eZsK7oMEH+Ly2lzJczFKPHwrta6X8SF64a20R3wOrAOYK1MzHZVaWWugg9qlSTVfVwqvQJ2dw==","shasum":"7cf8aec2b710ac97fca277880b0359abf2a50b8a","tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/bundle-import/-/bundle-import-0.0.1.tgz","fileCount":7,"unpackedSize":22059,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAkBGb91vfwBbzmojXEcI6KcNZ0X+Ogs0N3tE/57Qr+JAiEAhGwY8dnYucM2Xq6ZeKffmhqsSYCAHcDR1/nqCWfR58I="}]},"_npmUser":{"name":"anonymous","email":"love2xinwei@gmail.com"},"directories":{},"maintainers":[{"name":"anonymous","email":"love2xinwei@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/bundle-import_0.0.1_1699504525365_0.8083829596400838"},"_hasShrinkwrap":false,"contributors":[]},"0.0.2":{"name":"bundle-import","type":"module","version":"0.0.2","packageManager":"pnpm@9.12.1","description":"Bundle and load a file using the import-from-string.","imports":{"#*":"./*"},"author":{"name":"CondorHero"},"license":"MIT","homepage":"https://github.com/condorheroblog/bundle-import#readme","repository":{"type":"git","url":"git+https://github.com/condorheroblog/bundle-import.git"},"bugs":{"url":"https://github.com/condorheroblog/bundle-import/issues"},"keywords":["module-from-string","load-from-config","bundle-import","bundle-require","bundle-import"],"exports":{".":{"import":"./dist/index.mjs","require":"./dist/index.cjs"}},"main":"dist/index.cjs","module":"dist/index.mjs","types":"dist/index.d.cts","typesVersions":{"*":{"*":["./dist/*","./dist/index.d.ts"]}},"scripts":{"prepublishOnly":"nr build","dev:esm":"esno playground/index.mjs","dev:cjs":"esno playground/index.cjs","lint":"eslint .","lint:fix":"eslint . --fix","test":"vitest","build":"rimraf dist && rollup -c","build:watch":"rimraf dist && rollup -c -w","typecheck":"tsc --noEmit","release":"bumpp -r && pnpm -r publish --access public"},"dependencies":{"get-tsconfig":"^4.8.1","import-from-string":"^0.0.5"},"devDependencies":{"@antfu/eslint-config":"^3.8.0","@rollup/plugin-json":"^6.1.0","@types/node":"^22.9.0","bumpp":"^9.8.1","eslint":"^9.14.0","esno":"^4.8.0","lint-staged":"^15.2.10","rimraf":"^6.0.1","rollup":"^4.24.4","rollup-plugin-dts":"^6.1.1","rollup-plugin-esbuild":"^6.1.1","rollup-plugin-node-externals":"^7.1.3","simple-git-hooks":"^2.11.1","typescript":"^5.6.3","vitest":"^2.1.4"},"simple-git-hooks":{"pre-commit":"npx lint-staged"},"lint-staged":{"*.{ts,js,mjs,cjs,json,md}":["eslint --fix"]},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org"},"_id":"bundle-import@0.0.2","gitHead":"4958482e37b0f293243aa298b4e92c58bf4e414d","_nodeVersion":"20.15.0","_npmVersion":"10.7.0","dist":{"integrity":"sha512-XB3T6xlgqJHThyr2luo3pNAVhfN/Y2qFEsblrzUO5QZLpJtesget8jmGDImSairScy80ZKBDVcRdFzTzWv3v8A==","shasum":"289a838bdde45566e34dd9ac4b42c05558a61759","tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/bundle-import/-/bundle-import-0.0.2.tgz","fileCount":7,"unpackedSize":21448,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD9XIkMcBv7TX6m6hEwpAymHbpgCnbIRCoEtwlfksRWIQIhAOIsxAqGcb4L019G71YifPqSSurcv83ALKKR16hVESdt"}],"size":5347},"_npmUser":{"name":"anonymous","email":"love2xinwei@gmail.com"},"directories":{},"maintainers":[{"name":"anonymous","email":"love2xinwei@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/bundle-import_0.0.2_1730904262014_0.5948366271305614"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2024-11-06T14:44:22.208Z","publish_time":1730904262208,"_source_registry_name":"default","contributors":[]}},"dist-tags":{"latest":"0.0.2"},"name":"bundle-import","time":{"created":"2023-11-09T04:36:51.756Z","0.0.1":"2023-11-09T04:35:25.610Z","modified":"2024-11-06T15:27:06.432Z","0.0.2":"2024-11-06T14:44:22.208Z"},"readme":"# Bundle-import\n\n[![NPM version](https://img.shields.io/npm/v/bundle-import)](https://www.npmjs.com/package/bundle-import)\n[![Downloads](https://img.shields.io/npm/dw/bundle-import)](https://www.npmjs.com/package/bundle-import)\n[![License](https://img.shields.io/npm/l/bundle-import)](https://github.com/condorheroblog/bundle-import/blob/main/LICENSE)\n[![GitHub stars](https://img.shields.io/github/stars/condorheroblog/bundle-import)](https://github.com/condorheroblog/bundle-import/blob/main/packages/bundle-import)\n\nBundle and load a file using the import-from-string.\n\n## Difference from bundle-require\n\nMost of the code of Bundle-import comes from bundle-require. There is no objection to this, but Bundle-import does not generate temporary files when reading module contents, which can avoid conflicts with other tools. For example, the following two issues:\n\n1. [Tmp .mjs file in the current directory breaks other tools](https://github.com/egoist/bundle-require/issues/33)\n2. [vite 运行时，修改mock文件会生成很多个xxx.mjs文件](https://github.com/vbenjs/vite-plugin-mock/issues/98#issuecomment-1782467433)\n\n## Features\n\n- Support ESM and CJS environments\n- Support dynamic import\n- Support `import.meta.url`\n- Support access to global variables\n- No asynchronous IO operations\n- No module cache\n\n## Install\n\n```bash\nnpm install bundle-import\n```\n\n## Usage\n\n### ESM\n\n```mjs\nimport { bundleImport } from \"bundle-import\";\n\nconst { mod: mod1 } = await bundleImport({ filepath: \"./fixtures/index.cjs\", cwd: `${process.cwd()}/playground` });\nconsole.log(mod1);\n\nconst { mod: mod2 } = await bundleImport({ filepath: \"./playground/fixtures/index.mjs\" });\nconsole.log(mod2.default, mod2);\n```\n\n### CJS\n\n```cjs\nconst { bundleImport } = require(\"bundle-import\");\n\nasync function main() {\n\tconst { mod: mod1 } = await bundleImport({ filepath: \"./fixtures/index.cjs\", cwd: `${process.cwd()}/playground` });\n\tconsole.log(mod1);\n\n\tconst { mod: mod2 } = await bundleImport({ filepath: \"./playground/fixtures/index.mjs\" });\n\tconsole.log(mod2.default, mod2);\n}\n\nmain();\n```\n\n## API\n\n### bundleImport(options)\n\n#### options\n\n##### cwd\n\nType: `string`\\\nDefault: `process.cwd()`\n\nProject root directory.\n\n##### filename\n\nType: `string`\\\nRequired: `true`\n\nThe filepath to bundle and require.\n\n##### external\n\nType: `(string | RegExp)[]`\\\nRequired: `[]`\n\nExternal packages.\n\n##### tsconfig\n\nType: `string`\\\nRequired: `tsconfig.json`\n\nA custom tsconfig path to read `paths` option.\n\n##### format\n\nType: `\"cjs\" | \"esm\"`\\\n\nProvide bundle format explicitly to skip the default format inference.\n\n##### esbuildOptions\n\nType: `BuildOptions`\\\nRequired: `false`\n\nesbuild options.\n\n## Appreciation\n\n- [import-from-string](https://github.com/condorheroblog/import-from-string)\n- [bundle-require](https://github.com/egoist/bundle-require)\n- [module-from-string](https://github.com/exuanbo/module-from-string)\n- [require-from-string](https://github.com/floatdrop/require-from-string)\n\n## License\n\n[MIT](https://github.com/condorheroblog/bundle-import/blob/main/LICENSE) License © 2023-Present [Condor Hero](https://github.com/condorheroblog)","users":{}}