From b5dd496a9d1cb303b2c641a136ee276d42f05489 Mon Sep 17 00:00:00 2001 From: Christian Pillsbury Date: Wed, 13 Aug 2025 12:42:55 -0700 Subject: [PATCH] refactor: migrate key packages from tsup to rollup for build consistency MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Migrate icon packages and main platform packages to rollup while maintaining tsup for simpler core packages: Packages migrated to rollup: - packages/core/icons - Core SVG icon definitions - packages/html/html-icons - HTML-specific icon components - packages/html/html - Main HTML package - packages/react/react-icons - React icon components Packages remaining on tsup: - Core packages (media, media-store, playback-engine) - Simple TypeScript builds - Helper packages (*-media-elements, *-media-store) - Working fine with tsup - React Native packages - Per exclusion request Benefits: - Consistent build tooling across icon and platform packages - Better asset handling capability for future SVG/CSS requirements - Maintained simplicity for packages that don't need advanced features - All packages build successfully with proper CommonJS/ESM outputs 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- package-lock.json | 5 ++ packages/core/icons/package.json | 7 ++- packages/core/icons/rollup.config.js | 62 +++++++++++++++++++ packages/core/icons/tsconfig.build.json | 11 ++++ packages/core/icons/tsup.config.ts | 21 ------- packages/html/html-icons/package.json | 7 ++- packages/html/html-icons/rollup.config.js | 62 +++++++++++++++++++ packages/html/html-icons/tsconfig.build.json | 11 ++++ packages/html/html-icons/tsup.config.ts | 21 ------- packages/html/html/package.json | 7 ++- packages/html/html/rollup.config.js | 62 +++++++++++++++++++ packages/html/html/tsconfig.build.json | 11 ++++ packages/html/html/tsup.config.ts | 21 ------- packages/react/react-icons/package.json | 7 ++- packages/react/react-icons/rollup.config.js | 62 +++++++++++++++++++ .../react/react-icons/tsconfig.build.json | 11 ++++ packages/react/react-icons/tsup.config.ts | 21 ------- 17 files changed, 321 insertions(+), 88 deletions(-) create mode 100644 packages/core/icons/rollup.config.js create mode 100644 packages/core/icons/tsconfig.build.json delete mode 100644 packages/core/icons/tsup.config.ts create mode 100644 packages/html/html-icons/rollup.config.js create mode 100644 packages/html/html-icons/tsconfig.build.json delete mode 100644 packages/html/html-icons/tsup.config.ts create mode 100644 packages/html/html/rollup.config.js create mode 100644 packages/html/html/tsconfig.build.json delete mode 100644 packages/html/html/tsup.config.ts create mode 100644 packages/react/react-icons/rollup.config.js create mode 100644 packages/react/react-icons/tsconfig.build.json delete mode 100644 packages/react/react-icons/tsup.config.ts diff --git a/package-lock.json b/package-lock.json index 55ecfba8..b4b785c9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5698,6 +5698,11 @@ "version": "0.1.0", "license": "Apache-2.0", "devDependencies": { + "@rollup/plugin-commonjs": "^25.0.0", + "@rollup/plugin-node-resolve": "^15.0.0", + "@rollup/plugin-typescript": "^11.0.0", + "rollup": "^4.0.0", + "tslib": "^2.6.0", "typescript": "^5.3.0" } }, diff --git a/packages/core/icons/package.json b/packages/core/icons/package.json index a643ec18..4909b847 100644 --- a/packages/core/icons/package.json +++ b/packages/core/icons/package.json @@ -16,7 +16,7 @@ "dist" ], "scripts": { - "build": "tsup", + "build": "rollup -c && tsc --project tsconfig.build.json", "test": "echo \"No tests yet\"", "clean": "rm -rf dist" }, @@ -29,6 +29,11 @@ ], "license": "Apache-2.0", "devDependencies": { + "rollup": "^4.0.0", + "@rollup/plugin-typescript": "^11.0.0", + "@rollup/plugin-node-resolve": "^15.0.0", + "@rollup/plugin-commonjs": "^25.0.0", + "tslib": "^2.6.0", "typescript": "^5.3.0" }, "publishConfig": { diff --git a/packages/core/icons/rollup.config.js b/packages/core/icons/rollup.config.js new file mode 100644 index 00000000..0fe567ba --- /dev/null +++ b/packages/core/icons/rollup.config.js @@ -0,0 +1,62 @@ +const typescript = require('@rollup/plugin-typescript'); +const resolve = require('@rollup/plugin-node-resolve'); +const commonjs = require('@rollup/plugin-commonjs'); + +module.exports = [ + // ESM build + { + input: 'src/index.ts', + output: { + file: 'dist/index.mjs', + format: 'esm', + sourcemap: true, + }, + external: (id) => { + // Don't externalize relative imports (starts with . or /) + if (id.startsWith('.') || id.startsWith('/')) return false; + // Don't externalize absolute paths (local files) + if (id.includes('/') && !id.startsWith('@')) return false; + // Externalize all npm packages (including scoped ones) + return true; + }, + plugins: [ + resolve({ + extensions: ['.js', '.jsx', '.ts', '.tsx'] + }), + commonjs(), + typescript({ + tsconfig: 'tsconfig.json', + declaration: false, + outDir: 'dist', + }), + ], + }, + // CommonJS build + { + input: 'src/index.ts', + output: { + file: 'dist/index.js', + format: 'cjs', + sourcemap: true, + }, + external: (id) => { + // Don't externalize relative imports (starts with . or /) + if (id.startsWith('.') || id.startsWith('/')) return false; + // Don't externalize absolute paths (local files) + if (id.includes('/') && !id.startsWith('@')) return false; + // Externalize all npm packages (including scoped ones) + return true; + }, + plugins: [ + resolve({ + extensions: ['.js', '.jsx', '.ts', '.tsx'] + }), + commonjs(), + typescript({ + tsconfig: 'tsconfig.json', + declaration: false, + outDir: 'dist', + }), + ], + }, +]; \ No newline at end of file diff --git a/packages/core/icons/tsconfig.build.json b/packages/core/icons/tsconfig.build.json new file mode 100644 index 00000000..4f424202 --- /dev/null +++ b/packages/core/icons/tsconfig.build.json @@ -0,0 +1,11 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "declaration": true, + "declarationDir": "dist", + "emitDeclarationOnly": true, + "outDir": "dist", + "skipLibCheck": true + }, + "exclude": ["dist", "node_modules"] +} \ No newline at end of file diff --git a/packages/core/icons/tsup.config.ts b/packages/core/icons/tsup.config.ts deleted file mode 100644 index 108499a4..00000000 --- a/packages/core/icons/tsup.config.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { defineConfig } from 'tsup'; - -export default defineConfig({ - entry: ['src/index.ts'], - format: ['cjs', 'esm'], - clean: true, - sourcemap: true, - outDir: 'dist', - external: [ - // Keep all dependencies external for library builds - /^@vjs-10\//, - /^[^.]/, - ], - // Generate TypeScript declarations with custom config - dts: { - compilerOptions: { - composite: false, - incremental: false, - }, - }, -}); \ No newline at end of file diff --git a/packages/html/html-icons/package.json b/packages/html/html-icons/package.json index 0ae27fbf..f8b255e1 100644 --- a/packages/html/html-icons/package.json +++ b/packages/html/html-icons/package.json @@ -16,7 +16,7 @@ "dist" ], "scripts": { - "build": "tsup", + "build": "rollup -c && tsc --project tsconfig.build.json", "test": "echo \"No tests yet\"", "clean": "rm -rf dist" }, @@ -33,6 +33,11 @@ "@vjs-10/icons": "*" }, "devDependencies": { + "rollup": "^4.0.0", + "@rollup/plugin-typescript": "^11.0.0", + "@rollup/plugin-node-resolve": "^15.0.0", + "@rollup/plugin-commonjs": "^25.0.0", + "tslib": "^2.6.0", "typescript": "^5.3.0" }, "publishConfig": { diff --git a/packages/html/html-icons/rollup.config.js b/packages/html/html-icons/rollup.config.js new file mode 100644 index 00000000..0fe567ba --- /dev/null +++ b/packages/html/html-icons/rollup.config.js @@ -0,0 +1,62 @@ +const typescript = require('@rollup/plugin-typescript'); +const resolve = require('@rollup/plugin-node-resolve'); +const commonjs = require('@rollup/plugin-commonjs'); + +module.exports = [ + // ESM build + { + input: 'src/index.ts', + output: { + file: 'dist/index.mjs', + format: 'esm', + sourcemap: true, + }, + external: (id) => { + // Don't externalize relative imports (starts with . or /) + if (id.startsWith('.') || id.startsWith('/')) return false; + // Don't externalize absolute paths (local files) + if (id.includes('/') && !id.startsWith('@')) return false; + // Externalize all npm packages (including scoped ones) + return true; + }, + plugins: [ + resolve({ + extensions: ['.js', '.jsx', '.ts', '.tsx'] + }), + commonjs(), + typescript({ + tsconfig: 'tsconfig.json', + declaration: false, + outDir: 'dist', + }), + ], + }, + // CommonJS build + { + input: 'src/index.ts', + output: { + file: 'dist/index.js', + format: 'cjs', + sourcemap: true, + }, + external: (id) => { + // Don't externalize relative imports (starts with . or /) + if (id.startsWith('.') || id.startsWith('/')) return false; + // Don't externalize absolute paths (local files) + if (id.includes('/') && !id.startsWith('@')) return false; + // Externalize all npm packages (including scoped ones) + return true; + }, + plugins: [ + resolve({ + extensions: ['.js', '.jsx', '.ts', '.tsx'] + }), + commonjs(), + typescript({ + tsconfig: 'tsconfig.json', + declaration: false, + outDir: 'dist', + }), + ], + }, +]; \ No newline at end of file diff --git a/packages/html/html-icons/tsconfig.build.json b/packages/html/html-icons/tsconfig.build.json new file mode 100644 index 00000000..4f424202 --- /dev/null +++ b/packages/html/html-icons/tsconfig.build.json @@ -0,0 +1,11 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "declaration": true, + "declarationDir": "dist", + "emitDeclarationOnly": true, + "outDir": "dist", + "skipLibCheck": true + }, + "exclude": ["dist", "node_modules"] +} \ No newline at end of file diff --git a/packages/html/html-icons/tsup.config.ts b/packages/html/html-icons/tsup.config.ts deleted file mode 100644 index 108499a4..00000000 --- a/packages/html/html-icons/tsup.config.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { defineConfig } from 'tsup'; - -export default defineConfig({ - entry: ['src/index.ts'], - format: ['cjs', 'esm'], - clean: true, - sourcemap: true, - outDir: 'dist', - external: [ - // Keep all dependencies external for library builds - /^@vjs-10\//, - /^[^.]/, - ], - // Generate TypeScript declarations with custom config - dts: { - compilerOptions: { - composite: false, - incremental: false, - }, - }, -}); \ No newline at end of file diff --git a/packages/html/html/package.json b/packages/html/html/package.json index 55cdf1d2..e3942d09 100644 --- a/packages/html/html/package.json +++ b/packages/html/html/package.json @@ -16,7 +16,7 @@ "dist" ], "scripts": { - "build": "tsup", + "build": "rollup -c && tsc --project tsconfig.build.json", "test": "echo \"No tests yet\"", "clean": "rm -rf dist" }, @@ -34,6 +34,11 @@ "@vjs-10/html-media-store": "*" }, "devDependencies": { + "rollup": "^4.0.0", + "@rollup/plugin-typescript": "^11.0.0", + "@rollup/plugin-node-resolve": "^15.0.0", + "@rollup/plugin-commonjs": "^25.0.0", + "tslib": "^2.6.0", "typescript": "^5.3.0" }, "publishConfig": { diff --git a/packages/html/html/rollup.config.js b/packages/html/html/rollup.config.js new file mode 100644 index 00000000..0fe567ba --- /dev/null +++ b/packages/html/html/rollup.config.js @@ -0,0 +1,62 @@ +const typescript = require('@rollup/plugin-typescript'); +const resolve = require('@rollup/plugin-node-resolve'); +const commonjs = require('@rollup/plugin-commonjs'); + +module.exports = [ + // ESM build + { + input: 'src/index.ts', + output: { + file: 'dist/index.mjs', + format: 'esm', + sourcemap: true, + }, + external: (id) => { + // Don't externalize relative imports (starts with . or /) + if (id.startsWith('.') || id.startsWith('/')) return false; + // Don't externalize absolute paths (local files) + if (id.includes('/') && !id.startsWith('@')) return false; + // Externalize all npm packages (including scoped ones) + return true; + }, + plugins: [ + resolve({ + extensions: ['.js', '.jsx', '.ts', '.tsx'] + }), + commonjs(), + typescript({ + tsconfig: 'tsconfig.json', + declaration: false, + outDir: 'dist', + }), + ], + }, + // CommonJS build + { + input: 'src/index.ts', + output: { + file: 'dist/index.js', + format: 'cjs', + sourcemap: true, + }, + external: (id) => { + // Don't externalize relative imports (starts with . or /) + if (id.startsWith('.') || id.startsWith('/')) return false; + // Don't externalize absolute paths (local files) + if (id.includes('/') && !id.startsWith('@')) return false; + // Externalize all npm packages (including scoped ones) + return true; + }, + plugins: [ + resolve({ + extensions: ['.js', '.jsx', '.ts', '.tsx'] + }), + commonjs(), + typescript({ + tsconfig: 'tsconfig.json', + declaration: false, + outDir: 'dist', + }), + ], + }, +]; \ No newline at end of file diff --git a/packages/html/html/tsconfig.build.json b/packages/html/html/tsconfig.build.json new file mode 100644 index 00000000..4f424202 --- /dev/null +++ b/packages/html/html/tsconfig.build.json @@ -0,0 +1,11 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "declaration": true, + "declarationDir": "dist", + "emitDeclarationOnly": true, + "outDir": "dist", + "skipLibCheck": true + }, + "exclude": ["dist", "node_modules"] +} \ No newline at end of file diff --git a/packages/html/html/tsup.config.ts b/packages/html/html/tsup.config.ts deleted file mode 100644 index 108499a4..00000000 --- a/packages/html/html/tsup.config.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { defineConfig } from 'tsup'; - -export default defineConfig({ - entry: ['src/index.ts'], - format: ['cjs', 'esm'], - clean: true, - sourcemap: true, - outDir: 'dist', - external: [ - // Keep all dependencies external for library builds - /^@vjs-10\//, - /^[^.]/, - ], - // Generate TypeScript declarations with custom config - dts: { - compilerOptions: { - composite: false, - incremental: false, - }, - }, -}); \ No newline at end of file diff --git a/packages/react/react-icons/package.json b/packages/react/react-icons/package.json index e8fe596b..e9d62c39 100644 --- a/packages/react/react-icons/package.json +++ b/packages/react/react-icons/package.json @@ -16,7 +16,7 @@ "dist" ], "scripts": { - "build": "tsup", + "build": "rollup -c && tsc --project tsconfig.build.json", "test": "echo \"No tests yet\"", "clean": "rm -rf dist" }, @@ -35,6 +35,11 @@ "react": ">=16.8.0" }, "devDependencies": { + "rollup": "^4.0.0", + "@rollup/plugin-typescript": "^11.0.0", + "@rollup/plugin-node-resolve": "^15.0.0", + "@rollup/plugin-commonjs": "^25.0.0", + "tslib": "^2.6.0", "typescript": "^5.3.0", "@types/react": "^18.0.0", "react": "^18.0.0" diff --git a/packages/react/react-icons/rollup.config.js b/packages/react/react-icons/rollup.config.js new file mode 100644 index 00000000..0fe567ba --- /dev/null +++ b/packages/react/react-icons/rollup.config.js @@ -0,0 +1,62 @@ +const typescript = require('@rollup/plugin-typescript'); +const resolve = require('@rollup/plugin-node-resolve'); +const commonjs = require('@rollup/plugin-commonjs'); + +module.exports = [ + // ESM build + { + input: 'src/index.ts', + output: { + file: 'dist/index.mjs', + format: 'esm', + sourcemap: true, + }, + external: (id) => { + // Don't externalize relative imports (starts with . or /) + if (id.startsWith('.') || id.startsWith('/')) return false; + // Don't externalize absolute paths (local files) + if (id.includes('/') && !id.startsWith('@')) return false; + // Externalize all npm packages (including scoped ones) + return true; + }, + plugins: [ + resolve({ + extensions: ['.js', '.jsx', '.ts', '.tsx'] + }), + commonjs(), + typescript({ + tsconfig: 'tsconfig.json', + declaration: false, + outDir: 'dist', + }), + ], + }, + // CommonJS build + { + input: 'src/index.ts', + output: { + file: 'dist/index.js', + format: 'cjs', + sourcemap: true, + }, + external: (id) => { + // Don't externalize relative imports (starts with . or /) + if (id.startsWith('.') || id.startsWith('/')) return false; + // Don't externalize absolute paths (local files) + if (id.includes('/') && !id.startsWith('@')) return false; + // Externalize all npm packages (including scoped ones) + return true; + }, + plugins: [ + resolve({ + extensions: ['.js', '.jsx', '.ts', '.tsx'] + }), + commonjs(), + typescript({ + tsconfig: 'tsconfig.json', + declaration: false, + outDir: 'dist', + }), + ], + }, +]; \ No newline at end of file diff --git a/packages/react/react-icons/tsconfig.build.json b/packages/react/react-icons/tsconfig.build.json new file mode 100644 index 00000000..4f424202 --- /dev/null +++ b/packages/react/react-icons/tsconfig.build.json @@ -0,0 +1,11 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "declaration": true, + "declarationDir": "dist", + "emitDeclarationOnly": true, + "outDir": "dist", + "skipLibCheck": true + }, + "exclude": ["dist", "node_modules"] +} \ No newline at end of file diff --git a/packages/react/react-icons/tsup.config.ts b/packages/react/react-icons/tsup.config.ts deleted file mode 100644 index a4bebd83..00000000 --- a/packages/react/react-icons/tsup.config.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { defineConfig } from 'tsup'; - -export default defineConfig({ - entry: ['src/index.ts'], - format: ['cjs', 'esm'], - clean: true, - sourcemap: true, - outDir: 'dist', - external: [ - // Keep all dependencies external for library builds - /^@vjs-10\//, - /^[^.]/, - ], - // Generate TypeScript declarations with custom config - dts: { - compilerOptions: { - composite: false, - incremental: false, - }, - }, -});