@vitus-labs/tools-rollup 1.15.5 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +41 -0
- package/lib/rollup/config.js +2 -2
- package/lib/rollup/config.js.map +1 -1
- package/lib/types/rollup/config.d.ts +1 -1
- package/lib/types/rollup/config.d.ts.map +1 -1
- package/package.json +9 -9
- package/src/rollup/config.test.ts +14 -2
- package/src/rollup/config.ts +4 -2
- package/tsconfig.json +1 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,46 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 2.1.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#114](https://github.com/vitus-labs/tools/pull/114) [`a8659c5`](https://github.com/vitus-labs/tools/commit/a8659c5af954580e3b7ee98ae94e9ef84aa2f0ff) Thanks [@vitbokisch](https://github.com/vitbokisch)! - Three bug fixes for build-time configuration handling. All three previously produced wrong-but-successful builds — externals not applied, bundles ballooning silently.
|
|
8
|
+
|
|
9
|
+
**1. Throw on `vl-tools.config.mjs` load failure** — a malformed config (syntax error, throwing top-level code) used to print a stderr warning and silently fall back to defaults. Now throws with the file path and underlying parse error.
|
|
10
|
+
|
|
11
|
+
**2. Subpath imports of declared deps now externalize** — listing `echarts` in dependencies/peerDependencies previously externalized the bare import only; `echarts/core`, `echarts/charts/BarChart`, etc. got bundled. Each declared dep is now expanded into a regex matching the bare name and any subpath. The `expandExternal` helper lives in `@vitus-labs/tools-core` and is reused by both `tools-rolldown` and `tools-rollup`.
|
|
12
|
+
|
|
13
|
+
**3. `optionalDependencies` now externalized by default** — only `dependencies` + `peerDependencies` were considered before. Packages putting heavy renderers (pdfmake, docx, exceljs) in `optionalDependencies` ended up bundling them. If you actually want an optional dep bundled, move it to `dependencies`.
|
|
14
|
+
|
|
15
|
+
The combined effect: declared deps in any of the three dep fields, including their subpaths, are now correctly externalized. The pre-existing `expandExternal` in `tools-rolldown` (added in v2.0.1) has been removed in favor of the canonical implementation in `tools-core`.
|
|
16
|
+
|
|
17
|
+
- Updated dependencies [[`a8659c5`](https://github.com/vitus-labs/tools/commit/a8659c5af954580e3b7ee98ae94e9ef84aa2f0ff)]:
|
|
18
|
+
- @vitus-labs/tools-core@2.1.0
|
|
19
|
+
|
|
20
|
+
## 2.0.0
|
|
21
|
+
|
|
22
|
+
### Patch Changes
|
|
23
|
+
|
|
24
|
+
- [#110](https://github.com/vitus-labs/tools/pull/110) [`e837583`](https://github.com/vitus-labs/tools/commit/e8375834e2c55ebecc9bc5bf476c6e157dae23a8) Thanks [@vitbokisch](https://github.com/vitbokisch)! - Bulk dependency updates and TypeScript 6 migration.
|
|
25
|
+
|
|
26
|
+
**Breaking (typescript)**: TypeScript peer dep bumped from `^5.9.3` to `^6.0.3`. Consumers must upgrade to TypeScript 6.
|
|
27
|
+
|
|
28
|
+
**Notable internal updates**:
|
|
29
|
+
|
|
30
|
+
- `@modelcontextprotocol/sdk` 1.27 → 1.29, `zod` 3 → 4 (mcp)
|
|
31
|
+
- `vite` 7 → 8, `storybook` 10.2 → 10.3 (storybook)
|
|
32
|
+
- `rolldown` rc.9 → rc.17, `rolldown-plugin-dts` 0.22 → 0.23 (rolldown)
|
|
33
|
+
- `rollup` 4.59 → 4.60 (rollup)
|
|
34
|
+
- `next` 16.1 → 16.2 (nextjs, nextjs-images)
|
|
35
|
+
- `vitest` 4.1.0 → 4.1.5 (vitest)
|
|
36
|
+
|
|
37
|
+
**Storybook peer deps restored**: Earlier auto-update inadvertently narrowed `react`, `react-dom`, `react-native`, and `react-native-web` peer ranges. Restored to original wide ranges.
|
|
38
|
+
|
|
39
|
+
Other packages received patch-level dev dep bumps and a TypeScript 6 baseUrl cleanup in tsconfigs (no consumer-facing change).
|
|
40
|
+
|
|
41
|
+
- Updated dependencies [[`e837583`](https://github.com/vitus-labs/tools/commit/e8375834e2c55ebecc9bc5bf476c6e157dae23a8)]:
|
|
42
|
+
- @vitus-labs/tools-core@2.0.0
|
|
43
|
+
|
|
3
44
|
## 1.15.5
|
|
4
45
|
|
|
5
46
|
### Patch Changes
|
package/lib/rollup/config.js
CHANGED
|
@@ -2,7 +2,7 @@ import { createRequire } from 'node:module';
|
|
|
2
2
|
import { nodeResolve } from '@rollup/plugin-node-resolve';
|
|
3
3
|
import replace from '@rollup/plugin-replace';
|
|
4
4
|
import terser from '@rollup/plugin-terser';
|
|
5
|
-
import { swapGlobals } from '@vitus-labs/tools-core';
|
|
5
|
+
import { expandExternal, swapGlobals } from '@vitus-labs/tools-core';
|
|
6
6
|
import { apiExtractor } from 'rollup-plugin-api-extractor';
|
|
7
7
|
import filesize from 'rollup-plugin-filesize';
|
|
8
8
|
import typescript from 'rollup-plugin-typescript2';
|
|
@@ -123,7 +123,7 @@ const rollupConfig = ({ file, format, env, typesFilePath, platform, }) => {
|
|
|
123
123
|
interop: 'compat',
|
|
124
124
|
systemNullSetters: false,
|
|
125
125
|
},
|
|
126
|
-
external: [...PKG.externalDependencies, ...CONFIG.external],
|
|
126
|
+
external: [...PKG.externalDependencies, ...CONFIG.external].map(expandExternal),
|
|
127
127
|
treeshake: {
|
|
128
128
|
moduleSideEffects: false,
|
|
129
129
|
propertyReadSideEffects: false,
|
package/lib/rollup/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/rollup/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AACzD,OAAO,OAAO,MAAM,wBAAwB,CAAA;AAC5C,OAAO,MAAM,MAAM,uBAAuB,CAAA;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/rollup/config.ts"],"names":[],"m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,MAAM,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS;YACnE,QAAQ,EAAE,IAAI;YACd,aAAa,EAAE;gBACb,oBAAoB,EAAE,KAAK;aAC5B;YACD,OAAO,EAAE,QAAQ;YACjB,iBAAiB,EAAE,KAAK;SACzB;QACD,QAAQ,EAAE,CAAC,GAAG,GAAG,CAAC,oBAAoB,EAAE,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,GAAG,CAC7D,cAAc,CACf;QACD,SAAS,EAAE;YACT,iBAAiB,EAAE,KAAK;YACxB,uBAAuB,EAAE,KAAK;SAC/B;QACD,OAAO;KACR,CAAA;IAED,OAAO,WAAW,CAAA;AACpB,CAAC,CAAA;AAED,eAAe,YAAY,CAAA","sourcesContent":["import { createRequire } from 'node:module'\nimport { nodeResolve } from '@rollup/plugin-node-resolve'\nimport replace from '@rollup/plugin-replace'\nimport terser from '@rollup/plugin-terser'\nimport { expandExternal, swapGlobals } from '@vitus-labs/tools-core'\nimport { apiExtractor } from 'rollup-plugin-api-extractor'\nimport filesize from 'rollup-plugin-filesize'\nimport typescript from 'rollup-plugin-typescript2'\nimport { visualizer } from 'rollup-plugin-visualizer'\nimport { CONFIG, PKG, PLATFORMS } from '../config/index.js'\n\nconst require = createRequire(import.meta.url)\nconst tspCompiler = require('ts-patch/compiler')\n\nconst defineExtensions = (platform: string) => {\n const platformExtensions: string[] = []\n\n if ((PLATFORMS as readonly string[]).includes(platform)) {\n CONFIG.extensions.forEach((item: string) => {\n platformExtensions.push(`.${platform}${item}`)\n })\n }\n\n return platformExtensions.concat(CONFIG.extensions)\n}\n\nconst loadPlugins = ({\n env,\n platform,\n file,\n typesFilePath,\n}: {\n env: string\n platform: string\n file: string\n typesFilePath?: string\n}) => {\n const extensions = defineExtensions(platform)\n const plugins = [nodeResolve({ extensions, browser: platform === 'browser' })]\n\n if (CONFIG.typescript) {\n const tsConfig: Record<string, any> = {\n typescript: tspCompiler,\n exclude: CONFIG.exclude,\n useTsconfigDeclarationDir: true,\n clean: true,\n tsconfigDefaults: {\n exclude: CONFIG.exclude,\n include: CONFIG.include,\n declarationMap: false,\n declaration: false,\n compilerOptions: {\n types: ['@vitus-labs/tools-rollup'],\n plugins: [\n { transform: 'typescript-transform-paths' },\n {\n transform: 'typescript-transform-paths',\n afterDeclarations: true,\n },\n ],\n },\n },\n }\n\n if (typesFilePath) {\n tsConfig.tsconfigDefaults.compilerOptions.declarationMap = true\n tsConfig.tsconfigDefaults.compilerOptions.declaration = true\n tsConfig.tsconfigDefaults.compilerOptions.declarationDir = CONFIG.typesDir\n }\n\n plugins.push(typescript(tsConfig))\n\n if (typesFilePath) {\n plugins.push(\n apiExtractor({\n cleanUpRollup: true,\n configuration: {\n mainEntryPointFilePath: `<projectFolder>/${CONFIG.typesDir}/index.d.ts`,\n projectFolder: process.cwd(),\n compiler: {\n tsconfigFilePath: '<projectFolder>/tsconfig.json',\n skipLibCheck: true,\n },\n dtsRollup: {\n enabled: true,\n untrimmedFilePath: `<projectFolder>${typesFilePath}`,\n },\n },\n }),\n )\n }\n }\n\n if (CONFIG.replaceGlobals) {\n const replaceOptions: Record<string, string> = {\n __VERSION__: JSON.stringify(PKG.version),\n __NODE__: JSON.stringify(platform === 'node'),\n __WEB__: JSON.stringify(\n ['node', 'browser', 'universal'].includes(platform),\n ),\n __BROWSER__: JSON.stringify(platform === 'browser'),\n __NATIVE__: JSON.stringify(platform === 'native'),\n __CLIENT__: JSON.stringify(['native', 'browser'].includes(platform)),\n }\n\n if (env === 'production') {\n replaceOptions['process.env.NODE_ENV'] = JSON.stringify(env)\n }\n\n plugins.push(replace({ preventAssignment: true, values: replaceOptions }))\n }\n\n // generate visualised graphs in dist folder\n\n if (CONFIG.visualise) {\n const filePath = file.split('/')\n const fileName = filePath.pop()\n\n const visualiserOptions = {\n title: `${PKG.name} - ${fileName}`,\n filename: `${filePath.join('/')}/${\n CONFIG.visualise.outputDir\n }/${fileName}.html`,\n template: CONFIG.visualise.template,\n gzipSize: CONFIG.visualise.gzipSize,\n }\n\n plugins.push(visualizer(visualiserOptions))\n }\n\n if (env === 'production') {\n plugins.push(terser())\n }\n\n if (CONFIG.filesize) {\n plugins.push(filesize())\n }\n\n return plugins\n}\n\nconst rollupConfig = ({\n file,\n format,\n env,\n typesFilePath,\n platform,\n}: Record<string, any>) => {\n const plugins = loadPlugins({ file, env, typesFilePath, platform })\n\n const buildOutput = {\n makeAbsoluteExternalsRelative: true,\n preserveEntrySignatures: 'strict',\n input: CONFIG.sourceDir,\n output: {\n file,\n format,\n globals: swapGlobals(CONFIG.globals),\n sourcemap: true,\n exports: ['cjs', 'umd'].includes(format) ? 'named' : undefined,\n name: ['umd', 'iife'].includes(format) ? PKG.bundleName : undefined,\n esModule: true,\n generatedCode: {\n reservedNamesAsProps: false,\n },\n interop: 'compat',\n systemNullSetters: false,\n },\n external: [...PKG.externalDependencies, ...CONFIG.external].map(\n expandExternal,\n ),\n treeshake: {\n moduleSideEffects: false,\n propertyReadSideEffects: false,\n },\n plugins,\n }\n\n return buildOutput\n}\n\nexport default rollupConfig\n"]}
|
|
@@ -16,7 +16,7 @@ declare const rollupConfig: ({ file, format, env, typesFilePath, platform, }: Re
|
|
|
16
16
|
interop: string;
|
|
17
17
|
systemNullSetters: boolean;
|
|
18
18
|
};
|
|
19
|
-
external:
|
|
19
|
+
external: (string | RegExp)[];
|
|
20
20
|
treeshake: {
|
|
21
21
|
moduleSideEffects: boolean;
|
|
22
22
|
propertyReadSideEffects: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/rollup/config.ts"],"names":[],"mappings":"AA6IA,QAAA,MAAM,YAAY,GAAI,iDAMnB,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/rollup/config.ts"],"names":[],"mappings":"AA6IA,QAAA,MAAM,YAAY,GAAI,iDAMnB,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;;;;;;;;;;;;;;;;;;;;;;;;CAgCrB,CAAA;AAED,eAAe,YAAY,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitus-labs/tools-rollup",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -37,23 +37,23 @@
|
|
|
37
37
|
"access": "public"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@microsoft/api-extractor": "^7.
|
|
40
|
+
"@microsoft/api-extractor": "^7.58.7",
|
|
41
41
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
42
42
|
"@rollup/plugin-replace": "^6.0.3",
|
|
43
43
|
"@rollup/plugin-terser": "^1.0.0",
|
|
44
44
|
"@rollup/plugin-typescript": "^12.3.0",
|
|
45
|
-
"@types/node": "^25.
|
|
46
|
-
"@vitus-labs/tools-core": "^
|
|
45
|
+
"@types/node": "^25.6.0",
|
|
46
|
+
"@vitus-labs/tools-core": "^2.0.0",
|
|
47
47
|
"chalk": "^5.6.2",
|
|
48
48
|
"find-up": "^8.0.0",
|
|
49
|
-
"lodash-es": "^4.
|
|
49
|
+
"lodash-es": "^4.18.1",
|
|
50
50
|
"rimraf": "^6.1.3",
|
|
51
|
-
"rollup": "^4.
|
|
51
|
+
"rollup": "^4.60.2",
|
|
52
52
|
"rollup-plugin-api-extractor": "^0.2.5",
|
|
53
53
|
"rollup-plugin-filesize": "^10.0.0",
|
|
54
54
|
"rollup-plugin-tsconfig-paths": "^1.5.2",
|
|
55
55
|
"rollup-plugin-typescript-paths": "^1.5.0",
|
|
56
|
-
"rollup-plugin-typescript2": "^0.
|
|
56
|
+
"rollup-plugin-typescript2": "^0.37.0",
|
|
57
57
|
"rollup-plugin-visualizer": "^7.0.1",
|
|
58
58
|
"ts-patch": "^3.3.0",
|
|
59
59
|
"tslib": "^2.8.1",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"@types/lodash-es": "^4.17.12",
|
|
64
|
-
"@vitus-labs/tools-typescript": "^
|
|
65
|
-
"typescript": "^
|
|
64
|
+
"@vitus-labs/tools-typescript": "^2.0.0",
|
|
65
|
+
"typescript": "^6.0.3"
|
|
66
66
|
}
|
|
67
67
|
}
|
|
@@ -59,6 +59,11 @@ vi.mock('node:module', () => ({
|
|
|
59
59
|
vi.mock('@vitus-labs/tools-core', () => ({
|
|
60
60
|
swapGlobals: (globals: Record<string, string>) =>
|
|
61
61
|
Object.fromEntries(Object.entries(globals).map(([k, v]) => [v, k])),
|
|
62
|
+
expandExternal: (id: string | RegExp): string | RegExp => {
|
|
63
|
+
if (id instanceof RegExp) return id
|
|
64
|
+
const escaped = id.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
|
65
|
+
return new RegExp(`^${escaped}(\\/|$)`)
|
|
66
|
+
},
|
|
62
67
|
}))
|
|
63
68
|
|
|
64
69
|
vi.mock('../config/index.js', () => ({
|
|
@@ -72,6 +77,12 @@ import rollupConfig from './config.js'
|
|
|
72
77
|
const defaultConfig = { ...mockConfig }
|
|
73
78
|
const defaultPKG = { ...mockPKG }
|
|
74
79
|
|
|
80
|
+
const matchesExternal = (
|
|
81
|
+
externals: (string | RegExp)[] | undefined,
|
|
82
|
+
id: string,
|
|
83
|
+
): boolean =>
|
|
84
|
+
(externals ?? []).some((e) => (typeof e === 'string' ? e === id : e.test(id)))
|
|
85
|
+
|
|
75
86
|
describe('rollupConfig', () => {
|
|
76
87
|
beforeEach(() => {
|
|
77
88
|
vi.clearAllMocks()
|
|
@@ -91,8 +102,9 @@ describe('rollupConfig', () => {
|
|
|
91
102
|
expect(config.output.file).toBe('lib/index.js')
|
|
92
103
|
expect(config.output.format).toBe('es')
|
|
93
104
|
expect(config.output.sourcemap).toBe(true)
|
|
94
|
-
expect(config.external
|
|
95
|
-
expect(config.external
|
|
105
|
+
expect(matchesExternal(config.external, 'react')).toBe(true)
|
|
106
|
+
expect(matchesExternal(config.external, 'react/jsx-runtime')).toBe(true)
|
|
107
|
+
expect(matchesExternal(config.external, 'react/jsx-dev-runtime')).toBe(true)
|
|
96
108
|
})
|
|
97
109
|
|
|
98
110
|
it('should set named exports for CJS format', () => {
|
package/src/rollup/config.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { createRequire } from 'node:module'
|
|
|
2
2
|
import { nodeResolve } from '@rollup/plugin-node-resolve'
|
|
3
3
|
import replace from '@rollup/plugin-replace'
|
|
4
4
|
import terser from '@rollup/plugin-terser'
|
|
5
|
-
import { swapGlobals } from '@vitus-labs/tools-core'
|
|
5
|
+
import { expandExternal, swapGlobals } from '@vitus-labs/tools-core'
|
|
6
6
|
import { apiExtractor } from 'rollup-plugin-api-extractor'
|
|
7
7
|
import filesize from 'rollup-plugin-filesize'
|
|
8
8
|
import typescript from 'rollup-plugin-typescript2'
|
|
@@ -166,7 +166,9 @@ const rollupConfig = ({
|
|
|
166
166
|
interop: 'compat',
|
|
167
167
|
systemNullSetters: false,
|
|
168
168
|
},
|
|
169
|
-
external: [...PKG.externalDependencies, ...CONFIG.external]
|
|
169
|
+
external: [...PKG.externalDependencies, ...CONFIG.external].map(
|
|
170
|
+
expandExternal,
|
|
171
|
+
),
|
|
170
172
|
treeshake: {
|
|
171
173
|
moduleSideEffects: false,
|
|
172
174
|
propertyReadSideEffects: false,
|
package/tsconfig.json
CHANGED
|
@@ -4,11 +4,7 @@
|
|
|
4
4
|
"noEmit": false,
|
|
5
5
|
"outDir": "lib",
|
|
6
6
|
"rootDir": "src",
|
|
7
|
-
"
|
|
8
|
-
"declarationDir": "./lib/types",
|
|
9
|
-
"paths": {
|
|
10
|
-
"~/*": ["src/*"]
|
|
11
|
-
}
|
|
7
|
+
"declarationDir": "./lib/types"
|
|
12
8
|
},
|
|
13
9
|
"include": ["typings", "src"],
|
|
14
10
|
"exclude": ["node_modules", "__stories__", "lib", "**/*.test.ts"]
|