From db16547dbc8dffdd13e4c2287d7d96f9f3f6b99a Mon Sep 17 00:00:00 2001 From: aidanCQ Date: Mon, 18 Dec 2023 18:36:53 +0000 Subject: [PATCH] fix(): Preserve rsc directives in build. --- package-lock.json | 45 +++++++++++++++++++++++++++++++++++++++++++++ package.json | 1 + rollup.config.js | 7 +++++-- 3 files changed, 51 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index bcc5e3b..5052de8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -72,6 +72,7 @@ "rollup-plugin-dts": "^4.2.3", "rollup-plugin-peer-deps-external": "^2.2.4", "rollup-plugin-postcss": "^4.0.2", + "rollup-plugin-preserve-directives": "^0.2.0", "rollup-plugin-replace": "^2.2.0", "rollup-plugin-scss": "^3.0.0", "rollup-plugin-terser": "^7.0.2", @@ -14800,6 +14801,30 @@ "node": ">= 6" } }, + "node_modules/rollup-plugin-preserve-directives": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/rollup-plugin-preserve-directives/-/rollup-plugin-preserve-directives-0.2.0.tgz", + "integrity": "sha512-KUwbBaFvD1zFIDNnOkR+u64sSod3m0l6q46/SzTOa4GTQ6hp6w0FRr2u7x99YkY9qhlna5panmTmuLWeJ/2KWw==", + "dev": true, + "dependencies": { + "magic-string": "^0.30.0" + }, + "peerDependencies": { + "rollup": "2.x || 3.x" + } + }, + "node_modules/rollup-plugin-preserve-directives/node_modules/magic-string": { + "version": "0.30.5", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.5.tgz", + "integrity": "sha512-7xlpfBaQaP/T6Vh8MO/EqXSW5En6INHEvEXQiuff7Gku0PWjU3uf6w/j9o7O+SpB5fOAkrI5HeoNgwjEO0pFsA==", + "dev": true, + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.4.15" + }, + "engines": { + "node": ">=12" + } + }, "node_modules/rollup-plugin-replace": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/rollup-plugin-replace/-/rollup-plugin-replace-2.2.0.tgz", @@ -27113,6 +27138,26 @@ } } }, + "rollup-plugin-preserve-directives": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/rollup-plugin-preserve-directives/-/rollup-plugin-preserve-directives-0.2.0.tgz", + "integrity": "sha512-KUwbBaFvD1zFIDNnOkR+u64sSod3m0l6q46/SzTOa4GTQ6hp6w0FRr2u7x99YkY9qhlna5panmTmuLWeJ/2KWw==", + "dev": true, + "requires": { + "magic-string": "^0.30.0" + }, + "dependencies": { + "magic-string": { + "version": "0.30.5", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.5.tgz", + "integrity": "sha512-7xlpfBaQaP/T6Vh8MO/EqXSW5En6INHEvEXQiuff7Gku0PWjU3uf6w/j9o7O+SpB5fOAkrI5HeoNgwjEO0pFsA==", + "dev": true, + "requires": { + "@jridgewell/sourcemap-codec": "^1.4.15" + } + } + } + }, "rollup-plugin-replace": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/rollup-plugin-replace/-/rollup-plugin-replace-2.2.0.tgz", diff --git a/package.json b/package.json index 49e2c7b..bd1a24c 100644 --- a/package.json +++ b/package.json @@ -55,6 +55,7 @@ "rollup-plugin-dts": "^4.2.3", "rollup-plugin-peer-deps-external": "^2.2.4", "rollup-plugin-postcss": "^4.0.2", + "rollup-plugin-preserve-directives": "^0.2.0", "rollup-plugin-replace": "^2.2.0", "rollup-plugin-scss": "^3.0.0", "rollup-plugin-terser": "^7.0.2", diff --git a/rollup.config.js b/rollup.config.js index 5716dc2..d89cfc1 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -2,7 +2,9 @@ import commonjs from "@rollup/plugin-commonjs"; import resolve from "@rollup/plugin-node-resolve"; import typescript from "@rollup/plugin-typescript"; import copy from "rollup-plugin-copy"; +import preserveDirectives from "rollup-plugin-preserve-directives"; import { terser } from "rollup-plugin-terser"; + export default [ { input: "index.ts", @@ -10,7 +12,7 @@ export default [ { dir: "dist/", format: "esm", - // preserveModules: true, + preserveModules: true, }, ], plugins: [ @@ -28,7 +30,8 @@ export default [ targets: [{ src: "./src/tokens.css", dest: "./dist" }], }), // Minify output. - terser(), + terser({ compress: { directives: false } }), + preserveDirectives(), ], }, ];