diff --git a/README.md b/README.md index b045c77..66c9e7a 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ **New:** Building library for React Server Component support is added in `0.9.0`! `'use client'` and `'use server'` directives now are handled properly, without triggering rollup warnings. [Start using `'use client'` and `'use server'` in your library by adding two lines in your `rollup.config.js`](#react-server-component-directives-use-client-and-use-server) -> Since `0.9.1` the support for `'use client'` and `'use server'` has been separated into a standalone rollup plugin [`rollup-swc-preserve-directives`](https://github.com/huozhi/rollup-plugin-swc-preserve-directives), the previous `preserveUseDirective` named export is retained for the backward compatability. +> Since `0.9.1` the support for `'use client'` and `'use server'` has been separated into a standalone rollup plugin [`rollup-preserve-directives`](https://github.com/huozhi/rollup-preserve-directives), the previous `preserveUseDirective` named export is retained for the backward compatibility. ## Comparison @@ -168,36 +168,36 @@ const swcMinifyConfig = {} ~~Since version `0.9.0`, the support for `'use client'` and `'use server'` has been added:~~ -> The support for `'use client'` and `'use server'` has been separated into a standalone rollup plugin [`rollup-swc-preserve-directives`](https://github.com/huozhi/rollup-plugin-swc-preserve-directives), maintained by [@huozhi](https://github.com/huozhi) and me. The previous `preserveUseDirective` named export is retained for the backward compatibility. +> The support for `'use client'` and `'use server'` has been separated into a standalone rollup plugin [`rollup-preserve-directives`](https://github.com/huozhi/rollup-preserve-directives), maintained by [@huozhi](https://github.com/huozhi) and me. The previous `preserveUseDirective` named export is retained for the backward compatibility. ```bash # npm -npm install -D rollup-swc-preserve-directives +npm install -D rollup-preserve-directives # yarn -yarn add -D rollup-swc-preserve-directives +yarn add -D rollup-preserve-directives # pnpm -pnpm add -D rollup-swc-preserve-directives +pnpm add -D rollup-preserve-directives ``` ```js // rollup.config.js import { swc } from 'rollup-plugin-swc3'; -import swcPreserveDirectives from 'rollup-swc-preserve-directives'; +import preserveDirectives from 'rollup-preserve-directives'; export default { input: 'xxxx', output: {}, plugins: [ swc(), - // And add `swcPreserveDirectives` plugin after the `swc` plugin - swcPreserveDirectives() + // And add `preserveDirectives` plugin after the `swc` plugin + preserveDirectives() ]; } ``` And that is it! -`swcPreserveDirectives` supports: +`preserveDirectives` supports: - Merging duplicated directives in the output bundles @@ -220,7 +220,7 @@ And that is it! export default { input: 'src/index.js', output: { file: 'dist/index.js' } - plugins: [swc(), swcPreserveDirectives()] + plugins: [swc(), preserveDirectives()] } // dist/index.js @@ -255,7 +255,7 @@ And that is it! }, // output both client bundle and server bundle in the "dist/" directory output: { dir: 'dist/', entryFileName: '[name].js' } - plugins: [swc(), swcPreserveDirectives()] + plugins: [swc(), preserveDirectives()] } // dist/client.js diff --git a/package-lock.json b/package-lock.json index b6db4af..8ffbad0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,7 @@ "@fastify/deepmerge": "^1.3.0", "@rollup/pluginutils": "^5.0.5", "get-tsconfig": "^4.7.2", - "rollup-swc-preserve-directives": "^0.6.0" + "rollup-preserve-directives": "^1.0.0" }, "devDependencies": { "@eslint-sukka/node": "^4.1.9", @@ -1812,6 +1812,7 @@ "version": "1.3.96", "resolved": "https://registry.npmjs.org/@swc/core/-/core-1.3.96.tgz", "integrity": "sha512-zwE3TLgoZwJfQygdv2SdCK9mRLYluwDOM53I+dT6Z5ZvrgVENmY3txvWDvduzkV+/8IuvrRbVezMpxcojadRdQ==", + "dev": true, "hasInstallScript": true, "dependencies": { "@swc/counter": "^0.1.1", @@ -1852,6 +1853,7 @@ "cpu": [ "arm64" ], + "dev": true, "optional": true, "os": [ "darwin" @@ -1867,6 +1869,7 @@ "cpu": [ "x64" ], + "dev": true, "optional": true, "os": [ "darwin" @@ -1882,6 +1885,7 @@ "cpu": [ "arm" ], + "dev": true, "optional": true, "os": [ "linux" @@ -1897,6 +1901,7 @@ "cpu": [ "arm64" ], + "dev": true, "optional": true, "os": [ "linux" @@ -1912,6 +1917,7 @@ "cpu": [ "arm64" ], + "dev": true, "optional": true, "os": [ "linux" @@ -1927,6 +1933,7 @@ "cpu": [ "x64" ], + "dev": true, "optional": true, "os": [ "linux" @@ -1942,6 +1949,7 @@ "cpu": [ "x64" ], + "dev": true, "optional": true, "os": [ "linux" @@ -1957,6 +1965,7 @@ "cpu": [ "arm64" ], + "dev": true, "optional": true, "os": [ "win32" @@ -1972,6 +1981,7 @@ "cpu": [ "ia32" ], + "dev": true, "optional": true, "os": [ "win32" @@ -1987,6 +1997,7 @@ "cpu": [ "x64" ], + "dev": true, "optional": true, "os": [ "win32" @@ -1998,12 +2009,14 @@ "node_modules/@swc/counter": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/@swc/counter/-/counter-0.1.2.tgz", - "integrity": "sha512-9F4ys4C74eSTEUNndnER3VJ15oru2NumfQxS8geE+f3eB5xvfxpWyqE5XlVnxb/R14uoXi6SLbBwwiDSkv+XEw==" + "integrity": "sha512-9F4ys4C74eSTEUNndnER3VJ15oru2NumfQxS8geE+f3eB5xvfxpWyqE5XlVnxb/R14uoXi6SLbBwwiDSkv+XEw==", + "dev": true }, "node_modules/@swc/types": { "version": "0.1.5", "resolved": "https://registry.npmjs.org/@swc/types/-/types-0.1.5.tgz", - "integrity": "sha512-myfUej5naTBWnqOCc/MdVOLVjXUXtIA+NpDrDBKJtLLg2shUjBu3cZmB/85RyitKc55+lUUyl7oRfLOvkr2hsw==" + "integrity": "sha512-myfUej5naTBWnqOCc/MdVOLVjXUXtIA+NpDrDBKJtLLg2shUjBu3cZmB/85RyitKc55+lUUyl7oRfLOvkr2hsw==", + "dev": true }, "node_modules/@types/babel__traverse": { "version": "7.20.4", @@ -5164,15 +5177,14 @@ "typescript": "^4.5 || ^5.0" } }, - "node_modules/rollup-swc-preserve-directives": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/rollup-swc-preserve-directives/-/rollup-swc-preserve-directives-0.6.0.tgz", - "integrity": "sha512-MkKETpYF2ml5p15IxqbvLdFxWV6b99ALT6qL/okXYhaaiK8Mqu95nyk90+m58Ye+jMOpnhQsdK3JGMIPUV7i5g==", + "node_modules/rollup-preserve-directives": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/rollup-preserve-directives/-/rollup-preserve-directives-1.0.0.tgz", + "integrity": "sha512-9HVk/jWHQ8gQEvRGemMr6iSzKnflRWnbkYILpQ4Qbs0Xlcd09k4/GNnMlinPmkuBY6Hz3NtVtEf7sC4bNah2cQ==", "dependencies": { "@napi-rs/magic-string": "^0.3.4" }, "peerDependencies": { - "@swc/core": ">=1.3.79", "rollup": "^2.0.0 || ^3.0.0 || ^4.0.0" } }, diff --git a/package.json b/package.json index 7d8f080..c124460 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "@fastify/deepmerge": "^1.3.0", "@rollup/pluginutils": "^5.0.5", "get-tsconfig": "^4.7.2", - "rollup-swc-preserve-directives": "^0.6.0" + "rollup-preserve-directives": "^1.0.0" }, "devDependencies": { "@eslint-sukka/node": "^4.1.9", diff --git a/src/directive.ts b/src/directive.ts index fe9c978..cff2d4b 100644 --- a/src/directive.ts +++ b/src/directive.ts @@ -1,4 +1,4 @@ /** * preserveUseDirective is now a separate plugin, re-export to maintain the backward compatibility */ -export { default as preserveUseDirective } from 'rollup-swc-preserve-directives'; +export { default as preserveUseDirective } from 'rollup-preserve-directives';