{"_id":"rollup-plugin-preserve-directives","_rev":"5-32cd394f5ee493cb825b0bc75482f340","name":"rollup-plugin-preserve-directives","dist-tags":{"latest":"0.4.0"},"versions":{"0.1.0":{"name":"rollup-plugin-preserve-directives","description":"A Rollup plugin to preserve directives like \"use client\" when preserveModules is true.","version":"0.1.0","author":{"name":"Fredrik Höglund","email":"fredrik.hoglund@gmail.com"},"license":"MIT","keywords":["rollup-plugin"],"publishConfig":{"access":"public"},"main":"dist/index.js","types":"dist/index.d.ts","repository":{"type":"git","url":"git+https://github.com/Ephem/rollup-plugin-preserve-directives.git"},"homepage":"https://github.com/Ephem/rollup-plugin-preserve-directives#readme","bugs":{"url":"https://github.com/Ephem/rollup-plugin-preserve-directives/issues"},"scripts":{"build":"tsc","watch":"tsc --watch"},"peerDependencies":{"rollup":"2.x || 3.x"},"devDependencies":{"magic-string":"^0.30.0","rollup":"^3.19.1","typescript":"^4.9.5"},"gitHead":"43dd78307745ed83916762699b5a185a9bcab363","_id":"rollup-plugin-preserve-directives@0.1.0","_nodeVersion":"18.13.0","_npmVersion":"8.19.3","dist":{"integrity":"sha512-fgzIK3hwF/afa6L1Qdsvshn0JlCHZRx0Sh9l0jjUgz3VK0unMFuEB4uqL3Vdae4OXkn+MBYCeNEN9vm81IteiA==","shasum":"60c6f6ba6679bad4844c66a98dd6e828cc08ab67","tarball":"https://registry.npmjs.org/rollup-plugin-preserve-directives/-/rollup-plugin-preserve-directives-0.1.0.tgz","fileCount":5,"unpackedSize":10231,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQClBQjy9sT5d7TntMHDHINbQ/Sns0rhv301z+XQt+wsLgIhALkj4/eXdqwuX+N+QpH7PgORUESs9a3YhEHxoSghjQIA"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkDj4KACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmozshAAkarHieza2kA6p+0NQiUQujLM04bPYU8N/M2GNjrAXmRyDVZW\r\nPaNON36ELfKCXJIHRcqDAYtDz4ToN61keEKdZVAwQz/Ibv+PGRByk/KbcAmW\r\nGci6omKG+BQrjhCXXmbBZ9AEUEyFPvJQLOkjdZw4gC6e2AuFrxMbRtyrhmmr\r\nN8c0VozS44fFYrYlifLlSiGIoiBnfPJWDhIK8A+LvavAUjPyidE+oQGQLdmv\r\nVhhvL43wwKpb/fdeV5J7QxeBT44cdJW8oSeNeV31Onv8/Rmgg5vIsXoR8yrQ\r\nEZHop8jFE9ritEdN5eEUDQckJyI6wKzZEQEaQKDsDAYI7stizSPGUR/PvHsO\r\nMiWVqhNJcd5Y2vL94b6PHVZn8hgm0RB6IjxmqI+VQVjEeFwb1x+50RN6FGej\r\nNOzsfOJzn76buiim/eVfhcMKxs7MdYtdKOKr0emwwq/RNX7L4Mfl+dtBJi5x\r\nUxeB5qwZtzuka1LMa/lOP0e40TXLkKIJar5HCS2cwXgv+nrl4Kd8X4Bo10e2\r\nKweKa0JuqSIugNgp+JDQbCeMB7u3vs3x1AgE8O8x6MkZDv9VeLXc1QHyXRHF\r\ng4YLfs0chk1SJ36b+mWtebUfN+FUFu6gZddMZaV8uoyi6Pd3jsHNZb5uoaFP\r\nC7glDUu6O4WO1H1uSMv+4jN06GpzLxF/B7s=\r\n=tkRq\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"ephem","email":"fredrik.hoglund@gmail.com"},"directories":{},"maintainers":[{"name":"ephem","email":"fredrik.hoglund@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/rollup-plugin-preserve-directives_0.1.0_1678654985968_0.1850356233072652"},"_hasShrinkwrap":false},"0.1.1":{"name":"rollup-plugin-preserve-directives","description":"A Rollup plugin to preserve directives like \"use client\" when preserveModules is true.","version":"0.1.1","author":{"name":"Fredrik Höglund","email":"fredrik.hoglund@gmail.com"},"license":"MIT","keywords":["rollup-plugin"],"publishConfig":{"access":"public"},"main":"dist/index.js","types":"dist/index.d.ts","repository":{"type":"git","url":"git+https://github.com/Ephem/rollup-plugin-preserve-directives.git"},"homepage":"https://github.com/Ephem/rollup-plugin-preserve-directives#readme","bugs":{"url":"https://github.com/Ephem/rollup-plugin-preserve-directives/issues"},"scripts":{"build":"tsc","watch":"tsc --watch"},"peerDependencies":{"rollup":"2.x || 3.x"},"dependencies":{"magic-string":"^0.30.0"},"devDependencies":{"rollup":"^3.19.1","typescript":"^4.9.5"},"gitHead":"555d94016d24a6e267c00f811a1b5f560a8c1e1b","_id":"rollup-plugin-preserve-directives@0.1.1","_nodeVersion":"18.13.0","_npmVersion":"8.19.3","dist":{"integrity":"sha512-htKdBt+0ONtxIx2nB10vmQwNn7xJrAKR+HL4rCiP972s6bVlFYaUBm3dXFGfD29Ur/LTOtSakmASi9EUdq/MPQ==","shasum":"9111a254899ea6b42f43d913741b9641570556f5","tarball":"https://registry.npmjs.org/rollup-plugin-preserve-directives/-/rollup-plugin-preserve-directives-0.1.1.tgz","fileCount":5,"unpackedSize":10575,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICiSKRDe7q9Dam+r3aPlLLSU+LahepkqcVhyP4LSUSTxAiARwxpEKj+VWbwkzk5lXH2n/TYh7REjnJh7azW1rxPphg=="}]},"_npmUser":{"name":"ephem","email":"fredrik.hoglund@gmail.com"},"directories":{},"maintainers":[{"name":"ephem","email":"fredrik.hoglund@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/rollup-plugin-preserve-directives_0.1.1_1683991764715_0.9980168721275828"},"_hasShrinkwrap":false},"0.2.0":{"name":"rollup-plugin-preserve-directives","description":"A Rollup plugin to preserve directives like \"use client\" when preserveModules is true.","version":"0.2.0","author":{"name":"Fredrik Höglund","email":"fredrik.hoglund@gmail.com"},"license":"MIT","keywords":["rollup-plugin"],"publishConfig":{"access":"public"},"type":"commonjs","types":"dist/index.d.ts","main":"dist/index.js","module":"dist/index.mjs","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"},"./package.json":"./package.json"},"repository":{"type":"git","url":"git+https://github.com/Ephem/rollup-plugin-preserve-directives.git"},"homepage":"https://github.com/Ephem/rollup-plugin-preserve-directives#readme","bugs":{"url":"https://github.com/Ephem/rollup-plugin-preserve-directives/issues"},"scripts":{"check":"tsc","build":"tsup src/index.ts --dts --format cjs,esm","watch":"npm run build --watch"},"peerDependencies":{"rollup":"2.x || 3.x"},"dependencies":{"magic-string":"^0.30.0"},"devDependencies":{"rollup":"^3.19.1","tsup":"^6.7.0","typescript":"^4.9.5"},"gitHead":"f4f461af92bbefc4b1eb6ff74bc9cb9648345620","_id":"rollup-plugin-preserve-directives@0.2.0","_nodeVersion":"18.13.0","_npmVersion":"8.19.3","dist":{"integrity":"sha512-KUwbBaFvD1zFIDNnOkR+u64sSod3m0l6q46/SzTOa4GTQ6hp6w0FRr2u7x99YkY9qhlna5panmTmuLWeJ/2KWw==","shasum":"cc9dc34371ecf22878dc27fdd5cfb3f47b5ee088","tarball":"https://registry.npmjs.org/rollup-plugin-preserve-directives/-/rollup-plugin-preserve-directives-0.2.0.tgz","fileCount":7,"unpackedSize":16923,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCBH6Ytj5TWrJGVsmSuzG4arELikwAcxlrJvq/cavwV2wIhANjHpKTSclAHaUyt8efLO3zv6RJwJh2H5cqvZmDz0Z05"}]},"_npmUser":{"name":"ephem","email":"fredrik.hoglund@gmail.com"},"directories":{},"maintainers":[{"name":"ephem","email":"fredrik.hoglund@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/rollup-plugin-preserve-directives_0.2.0_1685285635025_0.9137629185404401"},"_hasShrinkwrap":false},"0.3.0":{"name":"rollup-plugin-preserve-directives","description":"A Rollup plugin to preserve directives like \"use client\" when preserveModules is true.","version":"0.3.0","author":{"name":"Fredrik Höglund","email":"fredrik.hoglund@gmail.com"},"license":"MIT","keywords":["rollup-plugin"],"publishConfig":{"access":"public"},"type":"module","types":"dist/index.d.ts","main":"dist/index.cjs","module":"dist/index.js","exports":{".":{"import":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"require":{"types":"./dist/index.d.cts","default":"./dist/index.cjs"}},"./package.json":"./package.json"},"repository":{"type":"git","url":"git+https://github.com/Ephem/rollup-plugin-preserve-directives.git"},"homepage":"https://github.com/Ephem/rollup-plugin-preserve-directives#readme","bugs":{"url":"https://github.com/Ephem/rollup-plugin-preserve-directives/issues"},"scripts":{"check":"tsc","build":"tsup src/index.ts --dts --format cjs,esm","watch":"npm run build --watch"},"peerDependencies":{"rollup":"2.x || 3.x || 4.x"},"dependencies":{"magic-string":"^0.30.5"},"devDependencies":{"rollup":"^4.9.5","tsup":"^8.0.1","typescript":"^5.3.3"},"gitHead":"450dc3ea96a12f9065ee24128c68b9649ba3e0db","_id":"rollup-plugin-preserve-directives@0.3.0","_nodeVersion":"18.13.0","_npmVersion":"8.19.3","dist":{"integrity":"sha512-Q6ZhU0nIlD8+R0NNvdJnfeePDWq4D7isP0pEmcGQ6ixSigPOIia4t7EukorikNe+VpZS8FFTm6zFk7o/3eUEBQ==","shasum":"af602ccc3c901422fbc409d670ebc227ab815f82","tarball":"https://registry.npmjs.org/rollup-plugin-preserve-directives/-/rollup-plugin-preserve-directives-0.3.0.tgz","fileCount":10,"unpackedSize":21197,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIAgIEmzPG90S2QK9xUd8wqomPnfKm8Tu+vZDkgLFzvM3AiBfavnf12yPqMdqcJVFEQmwyy0um3H72BKGN9BFyHbY/A=="}]},"_npmUser":{"name":"ephem","email":"fredrik.hoglund@gmail.com"},"directories":{},"maintainers":[{"name":"ephem","email":"fredrik.hoglund@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/rollup-plugin-preserve-directives_0.3.0_1705257903985_0.0179435904663634"},"_hasShrinkwrap":false},"0.3.1":{"name":"rollup-plugin-preserve-directives","description":"A Rollup plugin to preserve directives like \"use client\" when preserveModules is true.","version":"0.3.1","author":{"name":"Fredrik Höglund","email":"fredrik.hoglund@gmail.com"},"license":"MIT","keywords":["rollup-plugin"],"publishConfig":{"access":"public"},"type":"module","types":"dist/index.d.ts","main":"dist/index.cjs","module":"dist/index.js","exports":{".":{"import":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"require":{"types":"./dist/index.d.cts","default":"./dist/index.cjs"}},"./package.json":"./package.json"},"repository":{"type":"git","url":"git+https://github.com/Ephem/rollup-plugin-preserve-directives.git"},"homepage":"https://github.com/Ephem/rollup-plugin-preserve-directives#readme","bugs":{"url":"https://github.com/Ephem/rollup-plugin-preserve-directives/issues"},"scripts":{"check":"tsc","build":"tsup src/index.ts --dts --format cjs,esm","watch":"npm run build --watch"},"peerDependencies":{"rollup":"2.x || 3.x || 4.x"},"dependencies":{"magic-string":"^0.30.5"},"devDependencies":{"rollup":"^4.9.5","tsup":"^8.0.1","typescript":"^5.3.3"},"gitHead":"0513773fa8ff7823708f7ee46dc9e6a33477ffcd","_id":"rollup-plugin-preserve-directives@0.3.1","_nodeVersion":"18.13.0","_npmVersion":"8.19.3","dist":{"integrity":"sha512-Jn1gWU7G55A1sU6eFpXmwknfBasF0XbBzRqsE6nqrb/gun+mGV7nx++CwOSGPJQpFzFqvKm5U4XNKo3LTLi4Hg==","shasum":"91323eeaa03b10b22aae372c5f94bc695e3c5dea","tarball":"https://registry.npmjs.org/rollup-plugin-preserve-directives/-/rollup-plugin-preserve-directives-0.3.1.tgz","fileCount":10,"unpackedSize":21601,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDZNgVpgxRac6b8RCAmfnpNetBmXUrCHSSnxlKXLiAWVwIhAM2Bdm8BJYIVIuWn89XkJung0+ZABkaJZUpf/z/NPbrG"}]},"_npmUser":{"name":"ephem","email":"fredrik.hoglund@gmail.com"},"directories":{},"maintainers":[{"name":"ephem","email":"fredrik.hoglund@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/rollup-plugin-preserve-directives_0.3.1_1705683980394_0.9227214047133931"},"_hasShrinkwrap":false},"0.4.0":{"name":"rollup-plugin-preserve-directives","description":"A Rollup plugin to preserve directives like \"use client\" when preserveModules is true.","version":"0.4.0","author":{"name":"Fredrik Höglund","email":"fredrik.hoglund@gmail.com"},"license":"MIT","keywords":["rollup-plugin"],"publishConfig":{"access":"public"},"type":"module","types":"dist/index.d.ts","main":"dist/index.cjs","module":"dist/index.js","exports":{".":{"import":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"require":{"types":"./dist/index.d.cts","default":"./dist/index.cjs"}},"./package.json":"./package.json"},"repository":{"type":"git","url":"git+https://github.com/Ephem/rollup-plugin-preserve-directives.git"},"homepage":"https://github.com/Ephem/rollup-plugin-preserve-directives#readme","bugs":{"url":"https://github.com/Ephem/rollup-plugin-preserve-directives/issues"},"scripts":{"check":"tsc","build":"tsup src/index.ts --dts --format cjs,esm","watch":"npm run build --watch"},"peerDependencies":{"rollup":"2.x || 3.x || 4.x"},"dependencies":{"@rollup/pluginutils":"^5.1.0","magic-string":"^0.30.5"},"devDependencies":{"rollup":"^4.9.5","tsup":"^8.0.1","typescript":"^5.3.3"},"gitHead":"e196a496b5c8339edd486bdf1f45efbf8ec25b8e","_id":"rollup-plugin-preserve-directives@0.4.0","_nodeVersion":"18.13.0","_npmVersion":"8.19.3","dist":{"integrity":"sha512-gx4nBxYm5BysmEQS+e2tAMrtFxrGvk+Pe5ppafRibQi0zlW7VYAbEGk6IKDw9sJGPdFWgVTE0o4BU4cdG0Fylg==","shasum":"5e22f448a49b8aa28898d151e7a707b0eab15a6e","tarball":"https://registry.npmjs.org/rollup-plugin-preserve-directives/-/rollup-plugin-preserve-directives-0.4.0.tgz","fileCount":10,"unpackedSize":23404,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDGIlZS/aLCOSnjLtNm2e9HGyG9DAjWJDljw72ZuTSYFAIhAJlRMWqmXX5X4YU1JN0m0IRSKiITAFH1s0X/0wfTNxOf"}]},"_npmUser":{"name":"ephem","email":"fredrik.hoglund@gmail.com"},"directories":{},"maintainers":[{"name":"ephem","email":"fredrik.hoglund@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/rollup-plugin-preserve-directives_0.4.0_1706862032457_0.4325063801658313"},"_hasShrinkwrap":false}},"time":{"created":"2023-03-12T21:03:05.878Z","0.1.0":"2023-03-12T21:03:06.158Z","modified":"2024-02-02T08:20:32.819Z","0.1.1":"2023-05-13T15:29:24.927Z","0.2.0":"2023-05-28T14:53:55.232Z","0.3.0":"2024-01-14T18:45:04.167Z","0.3.1":"2024-01-19T17:06:20.571Z","0.4.0":"2024-02-02T08:20:32.660Z"},"maintainers":[{"name":"ephem","email":"fredrik.hoglund@gmail.com"}],"description":"A Rollup plugin to preserve directives like \"use client\" when preserveModules is true.","homepage":"https://github.com/Ephem/rollup-plugin-preserve-directives#readme","keywords":["rollup-plugin"],"repository":{"type":"git","url":"git+https://github.com/Ephem/rollup-plugin-preserve-directives.git"},"author":{"name":"Fredrik Höglund","email":"fredrik.hoglund@gmail.com"},"bugs":{"url":"https://github.com/Ephem/rollup-plugin-preserve-directives/issues"},"license":"MIT","readme":"# rollup-plugin-preserve-directives\n\n> Note: This plugin is still largely untested. It should work fine, but use at your own risk and please help me test it!\n\nThis plugin preserves directives when `preserveModules: true` is set in the Rollup config.\n\nRollup by default always removes directives like `'use client'` from the top of files. This makes sense when bundling files because directives should be applied per file, which is not possible when bundling.\n\nWhen `preserveModules: true` is set, because each module is a separate output file, it's possible to keep directives, which is exactly what this plugin does. If you want to add a directive to an entire bundle, use something like [rollup-plugin-banner2](https://github.com/stropho/rollup-plugin-banner2).\n\n## Getting started\n\nInstall:\n\n```sh\nnpm install -D rollup-plugin-preserve-directives\n```\n\nAdd the plugin to `rollup.config.js` and make sure you are using `preserveModules: true`, or the plugin will output a warning and do nothing:\n\n```js\nimport preserveDirectives from \"rollup-plugin-preserve-directives\";\n\nexport default {\n  output: {\n    preserveModules: true,\n  },\n  plugins: [preserveDirectives()],\n};\n```\n\nIf you are using a minifier like terser, make sure that is not removing the directive again. In terser, you can set [`compress.directives`](https://terser.org/docs/api-reference#compress-options) to `false`.\n\n## Disabling warnings\n\n### Rollup warning\n\nThis plugin is currently not silencing the warning that Rollup outputs when it comes across directives. It looks something like this:\n\n`(!) Module level directives cause errors when bundled, 'use client' was ignored.`\n\nMaybe this plugin could hide that warning by default in the future, but for now you can add an `onwarn` handler in your Rollup config to ignore the warning there, [see the docs](https://rollupjs.org/configuration-options/#onwarn).\n\n### rollup-plugin-preserve-directives warning\n\nThis plugin currently warns when it's used in a build that has `preserveModules` false, since it does nothing then. If you for some reason want to suppress this warning, you can pass the option `suppressPreserveModulesWarning: true` in the config:\n\n```js\nimport preserveDirectives from \"rollup-plugin-preserve-directives\";\n\nexport default {\n  output: {\n    preserveModules: false,\n  },\n  // This suppresses the warning, but the plugin does nothing\n  plugins: [preserveDirectives({ suppressPreserveModulesWarning: true })],\n};\n```\n\nThis can be useful when you have a common list of plugins for several builds, where some have `preserveModules: false` and some `true`.\n\n### Include / exclude\n\nTo exclude certain files from being processed by this plugin, you can use the `include` and `exclude` options. These options take [minimatch globs](https://github.com/motemen/minimatch-cheat-sheet), and can be used like this:\n\n```js\nimport preserveDirectives from \"rollup-plugin-preserve-directives\";\n\nexport default {\n  output: {\n    preserveModules: true,\n  },\n  plugins: [preserveDirectives({ exclude: [\"**/*.scss\", \"**/*.pcss\"] })],\n};\n```\n\n## Motivation and usecase\n\nWhile this plugin is generic and works with any directive, the motivator was to be able to build libraries that wants to provide both React Server Components and Client Components without having to use separate entrypoints.\n\nThis will never be possible in bundled builds, but with this plugin, libraries can support it for unbundled versions.\n\n## Contributing, status and todos\n\nThis is currently an early and somewhat untested plugin, please help me try it out in more projects and report bugs! This is my first Rollup plugin, so code review and feedback is also very welcome. This plugin:\n\n- Generates correct sourcemaps (but help me verify)\n- Supports multiple directives (though I have never seen this)\n\nHere are some random todos:\n\n- Tests\n- Prettier/Linting/EditorConfig\n- If possible: Suppress the Rollup warning when this plugin is used\n  - Perhaps we should instead/also export a custom `onwarn` handler that suppresses the warning if people want to add that to any builds that are not using this plugin? (If this plugin is used in one build, the directive is probably not a problem in the other build)\n- Versioning, release pipeline, changelog etc\n","readmeFilename":"README.md"}