{"_id":"@adamsoderstrom/esbuild-plugin-preserve-directives","_rev":"1-740871fbb1e3ede5b531dda9890273df","name":"@adamsoderstrom/esbuild-plugin-preserve-directives","dist-tags":{"latest":"0.0.10"},"versions":{"0.0.9":{"name":"@adamsoderstrom/esbuild-plugin-preserve-directives","version":"0.0.9","keywords":["esbuild","plugin","preserve","directives"],"author":{"name":"adamsoderstrom","email":"adamsoderstrom@me.com"},"license":"MIT","_id":"@adamsoderstrom/esbuild-plugin-preserve-directives@0.0.9","maintainers":[{"name":"adamsoderstrom","email":"adamsoderstrom@me.com"}],"homepage":"https://github.com/seojunhwan/esbuild-plugin-preserve-directives#readme","bugs":{"url":"https://github.com/seojunhwan/esbuild-plugin-preserve-directives/issues"},"dist":{"shasum":"cecc0e09aef791c260375304d48c2e3cee2063af","tarball":"https://registry.npmjs.org/@adamsoderstrom/esbuild-plugin-preserve-directives/-/esbuild-plugin-preserve-directives-0.0.9.tgz","fileCount":8,"integrity":"sha512-YbfHhP5MDChldrtCcRobbrs1Jqp25Uvx4vwLOWkrSgJuK3hQ3nfEkImHeZHYHUY+8thRFrd+sMyMU9el+9AfyQ==","signatures":[{"sig":"MEQCIG5Unit7EHWm78lJZ4doOYIDkFDSHBV866TFcd1hlNQsAiAtdEo/GBpSL2UA0ZotDHRg6hqp4KMc0y9GlN9/G75oaw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19769},"main":"./dist/index.js","type":"module","_from":"file:adamsoderstrom-esbuild-plugin-preserve-directives-0.0.9.tgz","types":"./dist/index.d.ts","engines":{"node":">=18.0.0"},"exports":{".":{"import":{"types":"./dist/index.d.ts","default":"./dist/index.mjs"},"require":{"types":"./dist/index.d.ts","default":"./dist/index.js"}}},"scripts":{"build":"pnpm run clean && node scripts/build.cjs && pnpm run build:types","clean":"rm -rf dist","release":"npx changeset publish","version":"npx changeset version","build:types":"tsc --project tsconfig.json --outDir dist"},"_npmUser":{"name":"adamsoderstrom","email":"adamsoderstrom@me.com"},"_resolved":"/tmp/302f4d73909f3098f9bdc060fa3c8d4a/adamsoderstrom-esbuild-plugin-preserve-directives-0.0.9.tgz","_integrity":"sha512-YbfHhP5MDChldrtCcRobbrs1Jqp25Uvx4vwLOWkrSgJuK3hQ3nfEkImHeZHYHUY+8thRFrd+sMyMU9el+9AfyQ==","repository":{"url":"git+https://github.com/seojunhwan/esbuild-plugin-preserve-directives.git","type":"git"},"_npmVersion":"10.7.0","description":"An esbuild plugin to preserve important directives like 'use client' at the top of output files.","directories":{},"_nodeVersion":"18.20.4","_hasShrinkwrap":false,"devDependencies":{"esbuild":"^0.23.0","typescript":"^5.5.3","@types/node":"^20.14.10","@changesets/cli":"^2.27.7"},"peerDependencies":{"esbuild":"^0.21.0"},"_npmOperationalInternal":{"tmp":"tmp/esbuild-plugin-preserve-directives_0.0.9_1724655308406_0.9230000192116041","host":"s3://npm-registry-packages"}},"0.0.10":{"name":"@adamsoderstrom/esbuild-plugin-preserve-directives","version":"0.0.10","description":"An esbuild plugin to preserve important directives like 'use client' at the top of output files.","author":{"name":"adamsoderstrom","email":"adamsoderstrom@me.com"},"license":"MIT","main":"./dist/index.js","exports":{".":{"require":{"default":"./dist/index.js","types":"./dist/index.d.ts"},"import":{"default":"./dist/index.mjs","types":"./dist/index.d.ts"}}},"keywords":["esbuild","plugin","preserve","directives"],"engines":{"node":">=18.0.0"},"repository":{"type":"git","url":"git+https://github.com/seojunhwan/esbuild-plugin-preserve-directives.git"},"devDependencies":{"@changesets/cli":"^2.27.7","@types/node":"^20.14.10","esbuild":"^0.23.0","typescript":"^5.5.3"},"peerDependencies":{"esbuild":"^0.21.0"},"scripts":{"clean":"rm -rf dist","build":"pnpm run clean && node scripts/build.cjs && pnpm run build:types","build:types":"tsc --project tsconfig.json --outDir dist","release":"npx changeset publish","version":"npx changeset version"},"types":"./dist/index.d.ts","bugs":{"url":"https://github.com/seojunhwan/esbuild-plugin-preserve-directives/issues"},"homepage":"https://github.com/seojunhwan/esbuild-plugin-preserve-directives#readme","_id":"@adamsoderstrom/esbuild-plugin-preserve-directives@0.0.10","_integrity":"sha512-LTuC89Ba+azBKwIi12dcGGsu/UjVj8L2ollj1sc0tK1bVVf3K0O0TvohCYiIYwqkSSv0kIIdPxHk4abSMlvPrA==","_resolved":"/private/var/folders/7n/x2mnfvxs69zbfzhn_sz8mmc80000gn/T/a1a5ecf3c06437169d1d7ca31ac9a860/adamsoderstrom-esbuild-plugin-preserve-directives-0.0.10.tgz","_from":"file:adamsoderstrom-esbuild-plugin-preserve-directives-0.0.10.tgz","_nodeVersion":"18.17.1","_npmVersion":"9.6.7","dist":{"integrity":"sha512-LTuC89Ba+azBKwIi12dcGGsu/UjVj8L2ollj1sc0tK1bVVf3K0O0TvohCYiIYwqkSSv0kIIdPxHk4abSMlvPrA==","shasum":"1ed62a405e0a2f9fc25881cb42a69f9df4bb216d","tarball":"https://registry.npmjs.org/@adamsoderstrom/esbuild-plugin-preserve-directives/-/esbuild-plugin-preserve-directives-0.0.10.tgz","fileCount":8,"unpackedSize":19750,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD8VEpPRuWwpo1tN8CGkfF1qLKbV63nBA0qqSMW36pgHQIgC1zJ+KBDJUVcPL0NMQnUMDjFd78piOMAmr6M0noPn0Y="}]},"_npmUser":{"name":"adamsoderstrom","email":"adamsoderstrom@me.com"},"directories":{},"maintainers":[{"name":"adamsoderstrom","email":"adamsoderstrom@me.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/esbuild-plugin-preserve-directives_0.0.10_1724671115184_0.3942187943526936"},"_hasShrinkwrap":false}},"time":{"created":"2024-08-26T06:55:08.316Z","modified":"2024-08-26T11:18:35.504Z","0.0.9":"2024-08-26T06:55:08.617Z","0.0.10":"2024-08-26T11:18:35.343Z"},"bugs":{"url":"https://github.com/seojunhwan/esbuild-plugin-preserve-directives/issues"},"author":{"name":"adamsoderstrom","email":"adamsoderstrom@me.com"},"license":"MIT","homepage":"https://github.com/seojunhwan/esbuild-plugin-preserve-directives#readme","keywords":["esbuild","plugin","preserve","directives"],"repository":{"type":"git","url":"git+https://github.com/seojunhwan/esbuild-plugin-preserve-directives.git"},"description":"An esbuild plugin to preserve important directives like 'use client' at the top of output files.","maintainers":[{"name":"adamsoderstrom","email":"adamsoderstrom@me.com"}],"readme":"# esbuild-plugin-preserve-directives\n\nesbuild-plugin-preserve-directives is a plugin for esbuild that preserves important directives (e.g., 'use client') at the top of output files.\n\n## Installation\n\n```bash\nnpm install -D esbuild-plugin-preserve-directives\n\nyarn add -D esbuild-plugin-preserve-directives\n\npnpm add -D esbuild-plugin-preserve-directives\n```\n\n## Usage\n\n### With esbuild\n\n```typescript\nimport { build } from 'esbuild';\nimport { preserveDirectivesPlugin } from 'esbuild-plugin-preserve-directives';\n\nbuild({\n  // ... other esbuild options\n  plugins: [\n    preserveDirectivesPlugin({\n      directives: ['use client', 'use strict'],\n      include: /\\.(js|ts|jsx|tsx)$/,\n      exclude: /node_modules/,\n    }),\n  ],\n});\n\nbuild();\n```\n\n### With tsup\n\n```typescript\nimport { defineConfig } from 'tsup';\nimport { preserveDirectivesPlugin } from 'esbuild-plugin-preserve-directives';\n\nexport default defineConfig({\n  // ... other tsup options\n  esbuildPlugins: [\n    preserveDirectivesPlugin({\n      directives: ['use client', 'use strict'],\n      include: /\\.(js|ts|jsx|tsx)$/,\n      exclude: /node_modules/,\n    }),\n  ],\n});\n```\n\n## Options\n\n- `directives`: List of directives to preserve\n- `include`: File pattern to apply the plugin (regex)\n- `exclude`: File pattern to ignore (regex)\n\n## How it works\n\nThis plugin operates during the build process as follows:\n\n1. Loads specified files and searches for directives.\n2. Stores found directives.\n3. After the build is complete, adds relevant directives to the top of output files.\n\nUsing esbuild's metafile option can provide more accurate results:\n\n- With metafile, the plugin can obtain a precise list of input files for each output file, improving the accuracy of directive preservation.\n- It may enhance performance in larger projects.\n\nTo enable the metafile option, add `metafile: true` to your esbuild configuration:\n\n```typescript\nimport { build } from 'esbuild';\nimport { preserveDirectivesPlugin } from 'esbuild-plugin-preserve-directives';\nbuild({\n  // ... other esbuild options\n  metafile: true,\n  plugins: [\n    preserveDirectivesPlugin({\n      directives: ['use client', 'use strict'],\n      include: /\\.(js|ts|jsx|tsx)$/,\n      exclude: /node_modules/,\n    }),\n  ],\n});\n```\n\nNote: Using metafile may slightly increase build time and memory usage, but the impact is usually minimal in most cases.\n\n## License\n\nMIT\n\n## Contributing\n\nIssues and pull requests are always welcome. For major changes, please open an issue first to discuss what you would like to change.\n\n## Author\n\nseojunhwan <seojunhwan@kakao.com>\n","readmeFilename":"README.md"}