@vitus-labs/tools-rollup 2.0.0 → 2.2.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 CHANGED
@@ -1,5 +1,39 @@
1
1
  # Change Log
2
2
 
3
+ ## 2.2.0
4
+
5
+ ### Patch Changes
6
+
7
+ - [#119](https://github.com/vitus-labs/tools/pull/119) [`a1726d5`](https://github.com/vitus-labs/tools/commit/a1726d5b7e98368db23b0a03cddd6c0472549cea) Thanks [@vitbokisch](https://github.com/vitbokisch)! - Switch shared `@vitus-labs/tools-typescript/lib` tsconfig to `module: "NodeNext"` + `moduleResolution: "NodeNext"` + `rewriteRelativeImportExtensions: true`.
8
+
9
+ **Why**: The previous `Bundler` resolution was permissive about extensions. As a result, packages could ship source with extensionless relative imports (or just stale `.js` references) that built and typechecked cleanly but failed at runtime under Node's strict ESM resolver. This bit `@vitus-labs/tools-nextjs-images` (had to be pinned to 1.7.0 by a consumer) and `@vitus-labs/tools-nextjs`. Under NodeNext, missing extensions are a compile error — the bug class is now caught at build time instead of at the consumer's runtime.
10
+
11
+ **Source convention is now `.ts`/`.tsx` extensions**: `import x from './foo.ts'` in source, which TS rewrites to `./foo.js` at emit. This is the modern TS-ESM pattern (TS 5.7+). The previous `.js`-in-source convention still works — `rewriteRelativeImportExtensions` only rewrites `.ts`/`.tsx`, leaving `.js` untouched.
12
+
13
+ **Internal**: CJS rollup plugins (`rollup-plugin-filesize`, `rollup-plugin-typescript2`, `@rollup/plugin-replace`, `@rollup/plugin-terser`) are now loaded via `createRequire` to avoid CJS/ESM default-import friction under stricter NodeNext type-checking. Same runtime, cleaner type inference.
14
+
15
+ **Consumer migration** (if extending `@vitus-labs/tools-typescript/lib`): no action required if your source already uses `.js` extensions on relative imports. If you have extensionless relative imports, TS will now error and tell you the correct fix.
16
+
17
+ - Updated dependencies []:
18
+ - @vitus-labs/tools-core@2.2.0
19
+
20
+ ## 2.1.0
21
+
22
+ ### Patch Changes
23
+
24
+ - [#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.
25
+
26
+ **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.
27
+
28
+ **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`.
29
+
30
+ **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`.
31
+
32
+ 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`.
33
+
34
+ - Updated dependencies [[`a8659c5`](https://github.com/vitus-labs/tools/commit/a8659c5af954580e3b7ee98ae94e9ef84aa2f0ff)]:
35
+ - @vitus-labs/tools-core@2.1.0
36
+
3
37
  ## 2.0.0
4
38
 
5
39
  ### Patch Changes
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env node
2
- import { runBuild } from '../scripts/build.js';
2
+ import { runBuild } from "../scripts/build.js";
3
3
  runBuild();
4
4
  //# sourceMappingURL=run-build.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"run-build.js","sourceRoot":"","sources":["../../src/bin/run-build.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAE9C,QAAQ,EAAE,CAAA","sourcesContent":["#!/usr/bin/env node\nimport { runBuild } from '../scripts/build.js'\n\nrunBuild()\n"]}
1
+ {"version":3,"file":"run-build.js","sourceRoot":"","sources":["../../src/bin/run-build.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAE9C,QAAQ,EAAE,CAAA","sourcesContent":["#!/usr/bin/env node\nimport { runBuild } from '../scripts/build.ts'\n\nrunBuild()\n"]}
@@ -10,6 +10,7 @@ watcher.on('event', (_event) => {
10
10
  // END — finished building all bundles
11
11
  // ERROR — encountered an error while bundling
12
12
  });
13
+ export {};
13
14
  // stop watching
14
15
  // watcher.close()
15
16
  //# sourceMappingURL=run-watch.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"run-watch.js","sourceRoot":"","sources":["../../src/bin/run-watch.ts"],"names":[],"mappings":";AACA,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAA;AAEhC,MAAM,YAAY,GAAG,EAAE,CAAA;AACvB,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,CAAA;AAE1C,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,MAAW,EAAE,EAAE;IAClC,4BAA4B;IAC5B,+CAA+C;IAC/C,iDAAiD;IACjD,8CAA8C;IAC9C,iDAAiD;IACjD,uDAAuD;AACzD,CAAC,CAAC,CAAA;AAEF,gBAAgB;AAChB,kBAAkB","sourcesContent":["#!/usr/bin/env node\nconst rollup = require('rollup')\n\nconst watchOptions = {}\nconst watcher = rollup.watch(watchOptions)\n\nwatcher.on('event', (_event: any) => {\n // event.code can be one of:\n // START — the watcher is (re)starting\n // BUNDLE_START — building an individual bundle\n // BUNDLE_END — finished building a bundle\n // END — finished building all bundles\n // ERROR — encountered an error while bundling\n})\n\n// stop watching\n// watcher.close()\n"]}
1
+ {"version":3,"file":"run-watch.js","sourceRoot":"","sources":["../../src/bin/run-watch.ts"],"names":[],"mappings":";AACA,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAA;AAEhC,MAAM,YAAY,GAAG,EAAE,CAAA;AACvB,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,CAAA;AAE1C,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,MAAW,EAAE,EAAE;IAClC,4BAA4B;IAC5B,+CAA+C;IAC/C,iDAAiD;IACjD,8CAA8C;IAC9C,iDAAiD;IACjD,uDAAuD;AACzD,CAAC,CAAC,CAAA;;AAEF,gBAAgB;AAChB,kBAAkB","sourcesContent":["#!/usr/bin/env node\nconst rollup = require('rollup')\n\nconst watchOptions = {}\nconst watcher = rollup.watch(watchOptions)\n\nwatcher.on('event', (_event: any) => {\n // event.code can be one of:\n // START — the watcher is (re)starting\n // BUNDLE_START — building an individual bundle\n // BUNDLE_END — finished building a bundle\n // END — finished building all bundles\n // ERROR — encountered an error while bundling\n})\n\n// stop watching\n// watcher.close()\n"]}
@@ -1,5 +1,5 @@
1
1
  import { PKG, TS_CONFIG, VL_CONFIG } from '@vitus-labs/tools-core';
2
- import baseConfig from './baseConfig.js';
2
+ import baseConfig from "./baseConfig.js";
3
3
  const CONFIG_KEY = 'build';
4
4
  const CONFIG = VL_CONFIG(CONFIG_KEY).merge(baseConfig).config;
5
5
  const PLATFORMS = ['browser', 'node', 'web', 'native'];
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAClE,OAAO,UAAU,MAAM,iBAAiB,CAAA;AAExC,MAAM,UAAU,GAAG,OAAO,CAAA;AAE1B,MAAM,MAAM,GAAG,SAAS,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,MAAM,CAAA;AAE7D,MAAM,SAAS,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,CAAU,CAAA;AAE/D,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,SAAS,EAAE,CAAA","sourcesContent":["import { PKG, TS_CONFIG, VL_CONFIG } from '@vitus-labs/tools-core'\nimport baseConfig from './baseConfig.js'\n\nconst CONFIG_KEY = 'build'\n\nconst CONFIG = VL_CONFIG(CONFIG_KEY).merge(baseConfig).config\n\nconst PLATFORMS = ['browser', 'node', 'web', 'native'] as const\n\nexport { CONFIG, PKG, PLATFORMS, TS_CONFIG }\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAClE,OAAO,UAAU,MAAM,iBAAiB,CAAA;AAExC,MAAM,UAAU,GAAG,OAAO,CAAA;AAE1B,MAAM,MAAM,GAAG,SAAS,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,MAAM,CAAA;AAE7D,MAAM,SAAS,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,CAAU,CAAA;AAE/D,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,SAAS,EAAE,CAAA","sourcesContent":["import { PKG, TS_CONFIG, VL_CONFIG } from '@vitus-labs/tools-core'\nimport baseConfig from './baseConfig.ts'\n\nconst CONFIG_KEY = 'build'\n\nconst CONFIG = VL_CONFIG(CONFIG_KEY).merge(baseConfig).config\n\nconst PLATFORMS = ['browser', 'node', 'web', 'native'] as const\n\nexport { CONFIG, PKG, PLATFORMS, TS_CONFIG }\n"]}
package/lib/index.js CHANGED
@@ -1,3 +1,3 @@
1
- import { runBuild } from './scripts/build.js';
1
+ import { runBuild } from "./scripts/build.js";
2
2
  export { runBuild };
3
3
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAE7C,OAAO,EAAE,QAAQ,EAAE,CAAA","sourcesContent":["import { runBuild } from './scripts/build.js'\n\nexport { runBuild }\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAE7C,OAAO,EAAE,QAAQ,EAAE,CAAA","sourcesContent":["import { runBuild } from './scripts/build.ts'\n\nexport { runBuild }\n"]}
@@ -1,15 +1,15 @@
1
1
  import { createRequire } from 'node:module';
2
2
  import { nodeResolve } from '@rollup/plugin-node-resolve';
3
- import replace from '@rollup/plugin-replace';
4
- import terser from '@rollup/plugin-terser';
5
- import { swapGlobals } from '@vitus-labs/tools-core';
3
+ import { expandExternal, swapGlobals } from '@vitus-labs/tools-core';
6
4
  import { apiExtractor } from 'rollup-plugin-api-extractor';
7
- import filesize from 'rollup-plugin-filesize';
8
- import typescript from 'rollup-plugin-typescript2';
9
5
  import { visualizer } from 'rollup-plugin-visualizer';
10
- import { CONFIG, PKG, PLATFORMS } from '../config/index.js';
6
+ import { CONFIG, PKG, PLATFORMS } from "../config/index.js";
11
7
  const require = createRequire(import.meta.url);
12
8
  const tspCompiler = require('ts-patch/compiler');
9
+ const filesize = require('rollup-plugin-filesize');
10
+ const typescript = require('rollup-plugin-typescript2');
11
+ const replace = require('@rollup/plugin-replace');
12
+ const terser = require('@rollup/plugin-terser');
13
13
  const defineExtensions = (platform) => {
14
14
  const platformExtensions = [];
15
15
  if (PLATFORMS.includes(platform)) {
@@ -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,
@@ -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;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAA;AAC1D,OAAO,QAAQ,MAAM,wBAAwB,CAAA;AAC7C,OAAO,UAAU,MAAM,2BAA2B,CAAA;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AACrD,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAE3D,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAC9C,MAAM,WAAW,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAA;AAEhD,MAAM,gBAAgB,GAAG,CAAC,QAAgB,EAAE,EAAE;IAC5C,MAAM,kBAAkB,GAAa,EAAE,CAAA;IAEvC,IAAK,SAA+B,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;QACxD,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,IAAY,EAAE,EAAE;YACzC,kBAAkB,CAAC,IAAI,CAAC,IAAI,QAAQ,GAAG,IAAI,EAAE,CAAC,CAAA;QAChD,CAAC,CAAC,CAAA;IACJ,CAAC;IAED,OAAO,kBAAkB,CAAC,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAA;AACrD,CAAC,CAAA;AAED,MAAM,WA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OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS;YAC9D,IAAI,EAAE,CAAC,KAAK,EAAE,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;QAC3D,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 { 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],\n treeshake: {\n moduleSideEffects: false,\n propertyReadSideEffects: false,\n },\n plugins,\n }\n\n return buildOutput\n}\n\nexport default rollupConfig\n"]}
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,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAA;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AACrD,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,oBAAoB,C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G,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 { expandExternal, swapGlobals } from '@vitus-labs/tools-core'\nimport { apiExtractor } from 'rollup-plugin-api-extractor'\nimport { visualizer } from 'rollup-plugin-visualizer'\nimport { CONFIG, PKG, PLATFORMS } from '../config/index.ts'\n\nconst require = createRequire(import.meta.url)\nconst tspCompiler = require('ts-patch/compiler')\nconst filesize: typeof import('rollup-plugin-filesize').default = require('rollup-plugin-filesize')\nconst typescript: typeof import('rollup-plugin-typescript2').default = require('rollup-plugin-typescript2')\nconst replace: typeof import('@rollup/plugin-replace').default = require('@rollup/plugin-replace')\nconst terser: typeof import('@rollup/plugin-terser').default = require('@rollup/plugin-terser')\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"]}
@@ -1,4 +1,4 @@
1
- import { PKG } from '../config/index.js';
1
+ import { PKG } from "../config/index.js";
2
2
  const isESModuleOnly = PKG.type === 'module';
3
3
  const typesFilePath = PKG?.exports?.types || PKG.types || PKG.typings;
4
4
  const hasDifferentNativeBuild = () => {
@@ -1 +1 @@
1
- {"version":3,"file":"createBuildPipeline.js","sourceRoot":"","sources":["../../src/rollup/createBuildPipeline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAA;AAExC,MAAM,cAAc,GAAG,GAAG,CAAC,IAAI,KAAK,QAAQ,CAAA;AAC5C,MAAM,aAAa,GAAG,GAAG,EAAE,OAAO,EAAE,KAAK,IAAI,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,OAAO,CAAA;AAErE,MAAM,uBAAuB,GAAG,GAAG,EAAE;IACnC,OAAO,GAAG,CAAC,cAAc,CAAC,KAAK,GAAG,CAAC,MAAM,CAAA;AAC3C,CAAC,CAAA;AAED,MAAM,wBAAwB,GAAG,CAAC,IAAY,EAAE,EAAE;IAChD,IAAI,C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K,MAAM,IAAI,MAAM,KAAK,MAAM,EAAE,CAAC;gBAC9C,MAAM,CAAC,IAAI,CAAC;oBACV,GAAG,cAAc,CAAC,IAAI,CAAC;oBACvB,IAAI,EAAE,MAAM;oBACZ,QAAQ,EAAE,SAAS;iBACpB,CAAC,CAAA;YACJ,CAAC;QACH,CAAC,CAAC,CAAA;IACJ,CAAC,CACF,CAAA;IAED,OAAO,MAAM,CAAA;AACf,CAAC,CAAA;AAED,MAAM,mBAAmB,GAAG,GAAG,EAAE;IAC/B,MAAM,MAAM,GAAG;QACb,GAAG,wBAAwB,EAAE;QAC7B,GAAG,0BAA0B,EAAE;KAChC,CAAA;IAED,iDAAiD;IACjD,IAAI,aAAa,EAAE,CAAC;QAClB,MAAM,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,CAAA;IAC7C,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC,CAAA;AAED,eAAe,mBAAmB,CAAA","sourcesContent":["import { PKG } from '../config/index.js'\n\nconst isESModuleOnly = PKG.type === 'module'\nconst typesFilePath = PKG?.exports?.types || PKG.types || PKG.typings\n\nconst hasDifferentNativeBuild = () => {\n return PKG['react-native'] !== PKG.module\n}\n\nconst hasDifferentBrowserBuild = (type: string) => {\n if (!PKG.browser) return false\n\n return Object.entries(PKG.browser as Record<string, string>).some(\n ([key, value]) => {\n const source = key.substring(2)\n const output = value.substring(2)\n\n return source !== PKG[type] && source !== output\n },\n )\n}\n\nconst BUILD_VARIANTS: Record<\n string,\n { format: string; env: string; platform?: string }\n> = {\n main: {\n format: isESModuleOnly ? 'es' : 'cjs',\n env: 'development',\n platform: 'universal',\n },\n module: {\n format: 'es',\n env: 'development',\n platform: 'universal',\n },\n 'react-native': {\n format: 'es',\n env: 'development',\n platform: 'native',\n },\n 'umd:main': { format: 'umd', env: 'development' },\n unpkg: { format: 'umd', env: 'production' },\n}\n\nconst getExportsOptions = () => {\n const exportsOptions = PKG.exports\n\n if (!exportsOptions) return []\n\n if (typeof exportsOptions === 'string') {\n return [\n {\n file: PKG.exports,\n ...BUILD_VARIANTS.module,\n },\n ]\n }\n\n if (typeof exportsOptions === 'object') {\n const result: Record<string, any>[] = []\n\n if (exportsOptions.import) {\n result.push({\n file: exportsOptions.import,\n ...BUILD_VARIANTS.module,\n })\n }\n\n if (exportsOptions.require) {\n result.push({\n file: exportsOptions.require,\n ...BUILD_VARIANTS.main,\n })\n }\n\n if (exportsOptions.node) {\n result.push({\n file: exportsOptions.node,\n ...BUILD_VARIANTS.module,\n platform: 'node',\n })\n }\n\n if (exportsOptions.default) {\n result.push({\n file: exportsOptions.default,\n ...BUILD_VARIANTS.module,\n })\n }\n\n return result\n }\n\n return []\n}\n\nconst createBasicBuildVariants = () => {\n let result: Record<string, any>[] = []\n\n if (isESModuleOnly) result = [...getExportsOptions()]\n\n Object.keys(BUILD_VARIANTS).forEach((key) => {\n const PKGOutDir = PKG[key]\n\n if (PKGOutDir) {\n const hasBrowserBuild = hasDifferentBrowserBuild(key)\n const hasNativeBuild = hasDifferentNativeBuild()\n\n // create a helper function for adding a build variant to an array\n const add = (props = {}) => {\n result.push({ ...BUILD_VARIANTS[key], file: PKGOutDir, ...props })\n }\n\n if (key === 'react-native') {\n // add a separate RN build only if output path differs from module path\n if (hasNativeBuild) {\n add()\n }\n } else if (hasBrowserBuild) {\n // if has a different browser build, set default platform to node\n // as there is going to be created a separate browser build as well\n add({ platform: 'node' })\n } else {\n add()\n }\n }\n })\n\n return result\n}\n\nconst createBrowserBuildVariants = () => {\n const result: Record<string, any>[] = []\n if (!PKG.browser) return result\n\n Object.entries(PKG.browser as Record<string, string>).forEach(\n ([key, value]) => {\n const source = key.substring(2) // strip './' from the beginning of path\n const output = value.substring(2) // strip './' from the beginning of path\n\n Object.keys(BUILD_VARIANTS).forEach((item) => {\n if (PKG[item] === source && source !== output) {\n result.push({\n ...BUILD_VARIANTS[item],\n file: output,\n platform: 'browser',\n })\n }\n })\n },\n )\n\n return result\n}\n\nconst createBuildPipeline = () => {\n const result = [\n ...createBasicBuildVariants(),\n ...createBrowserBuildVariants(),\n ]\n\n // add generate typings for the first bundle only\n if (typesFilePath) {\n result[0] = { ...result[0], typesFilePath }\n }\n\n return result\n}\n\nexport default createBuildPipeline\n"]}
1
+ {"version":3,"file":"createBuildPipeline.js","sourceRoot":"","sources":["../../src/rollup/createBuildPipeline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAA;AAExC,MAAM,cAAc,GAAG,GAAG,CAAC,IAAI,KAAK,QAAQ,CAAA;AAC5C,MAAM,aAAa,GAAG,GAAG,EAAE,OAAO,EAAE,KAAK,IAAI,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,OAAO,CAAA;AAErE,MAAM,uBAAuB,GAAG,GAAG,EAAE;IACnC,OAAO,GAAG,CAAC,cAAc,CAAC,KAAK,GAAG,CAAC,MAAM,CAAA;AAC3C,CAAC,CAAA;AAED,MAAM,wBAAwB,GAAG,CAAC,IAAY,EAAE,EAAE;IAChD,IAAI,CAAC,GAAG,CAAC,OAAO;QAAE,OAAO,KAAK,CAAA;IAE9B,OAAO,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,OAAiC,CAAC,CAAC,IAAI,CAC/D,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;QACf,MAAM,MAAM,GAAG,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAA;QAC/B,MAAM,MAAM,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAA;QAEjC,OAAO,MAAM,KAAK,GAAG,CAAC,IAAI,CAAC,IAAI,MAAM,KAAK,MAAM,CAAA;IAClD,CAAC,CACF,CAAA;AACH,CAAC,CAAA;AAED,MAAM,cAAc,GAGhB;IACF,IAAI,EAAE;QACJ,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK;QACrC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A;IAC7C,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC,CAAA;AAED,eAAe,mBAAmB,CAAA","sourcesContent":["import { PKG } from '../config/index.ts'\n\nconst isESModuleOnly = PKG.type === 'module'\nconst typesFilePath = PKG?.exports?.types || PKG.types || PKG.typings\n\nconst hasDifferentNativeBuild = () => {\n return PKG['react-native'] !== PKG.module\n}\n\nconst hasDifferentBrowserBuild = (type: string) => {\n if (!PKG.browser) return false\n\n return Object.entries(PKG.browser as Record<string, string>).some(\n ([key, value]) => {\n const source = key.substring(2)\n const output = value.substring(2)\n\n return source !== PKG[type] && source !== output\n },\n )\n}\n\nconst BUILD_VARIANTS: Record<\n string,\n { format: string; env: string; platform?: string }\n> = {\n main: {\n format: isESModuleOnly ? 'es' : 'cjs',\n env: 'development',\n platform: 'universal',\n },\n module: {\n format: 'es',\n env: 'development',\n platform: 'universal',\n },\n 'react-native': {\n format: 'es',\n env: 'development',\n platform: 'native',\n },\n 'umd:main': { format: 'umd', env: 'development' },\n unpkg: { format: 'umd', env: 'production' },\n}\n\nconst getExportsOptions = () => {\n const exportsOptions = PKG.exports\n\n if (!exportsOptions) return []\n\n if (typeof exportsOptions === 'string') {\n return [\n {\n file: PKG.exports,\n ...BUILD_VARIANTS.module,\n },\n ]\n }\n\n if (typeof exportsOptions === 'object') {\n const result: Record<string, any>[] = []\n\n if (exportsOptions.import) {\n result.push({\n file: exportsOptions.import,\n ...BUILD_VARIANTS.module,\n })\n }\n\n if (exportsOptions.require) {\n result.push({\n file: exportsOptions.require,\n ...BUILD_VARIANTS.main,\n })\n }\n\n if (exportsOptions.node) {\n result.push({\n file: exportsOptions.node,\n ...BUILD_VARIANTS.module,\n platform: 'node',\n })\n }\n\n if (exportsOptions.default) {\n result.push({\n file: exportsOptions.default,\n ...BUILD_VARIANTS.module,\n })\n }\n\n return result\n }\n\n return []\n}\n\nconst createBasicBuildVariants = () => {\n let result: Record<string, any>[] = []\n\n if (isESModuleOnly) result = [...getExportsOptions()]\n\n Object.keys(BUILD_VARIANTS).forEach((key) => {\n const PKGOutDir = PKG[key]\n\n if (PKGOutDir) {\n const hasBrowserBuild = hasDifferentBrowserBuild(key)\n const hasNativeBuild = hasDifferentNativeBuild()\n\n // create a helper function for adding a build variant to an array\n const add = (props = {}) => {\n result.push({ ...BUILD_VARIANTS[key], file: PKGOutDir, ...props })\n }\n\n if (key === 'react-native') {\n // add a separate RN build only if output path differs from module path\n if (hasNativeBuild) {\n add()\n }\n } else if (hasBrowserBuild) {\n // if has a different browser build, set default platform to node\n // as there is going to be created a separate browser build as well\n add({ platform: 'node' })\n } else {\n add()\n }\n }\n })\n\n return result\n}\n\nconst createBrowserBuildVariants = () => {\n const result: Record<string, any>[] = []\n if (!PKG.browser) return result\n\n Object.entries(PKG.browser as Record<string, string>).forEach(\n ([key, value]) => {\n const source = key.substring(2) // strip './' from the beginning of path\n const output = value.substring(2) // strip './' from the beginning of path\n\n Object.keys(BUILD_VARIANTS).forEach((item) => {\n if (PKG[item] === source && source !== output) {\n result.push({\n ...BUILD_VARIANTS[item],\n file: output,\n platform: 'browser',\n })\n }\n })\n },\n )\n\n return result\n}\n\nconst createBuildPipeline = () => {\n const result = [\n ...createBasicBuildVariants(),\n ...createBrowserBuildVariants(),\n ]\n\n // add generate typings for the first bundle only\n if (typesFilePath) {\n result[0] = { ...result[0], typesFilePath }\n }\n\n return result\n}\n\nexport default createBuildPipeline\n"]}
@@ -1,4 +1,4 @@
1
- import config from './config.js';
2
- import createBuildPipeline from './createBuildPipeline.js';
1
+ import config from "./config.js";
2
+ import createBuildPipeline from "./createBuildPipeline.js";
3
3
  export { config, createBuildPipeline };
4
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/rollup/index.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAA;AAChC,OAAO,mBAAmB,MAAM,0BAA0B,CAAA;AAE1D,OAAO,EAAE,MAAM,EAAE,mBAAmB,EAAE,CAAA","sourcesContent":["import config from './config.js'\nimport createBuildPipeline from './createBuildPipeline.js'\n\nexport { config, createBuildPipeline }\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/rollup/index.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAA;AAChC,OAAO,mBAAmB,MAAM,0BAA0B,CAAA;AAE1D,OAAO,EAAE,MAAM,EAAE,mBAAmB,EAAE,CAAA","sourcesContent":["import config from './config.ts'\nimport createBuildPipeline from './createBuildPipeline.ts'\n\nexport { config, createBuildPipeline }\n"]}
@@ -1,8 +1,8 @@
1
1
  import chalk from 'chalk';
2
2
  import { rimraf } from 'rimraf';
3
3
  import { rollup } from 'rollup';
4
- import { CONFIG } from '../config/index.js';
5
- import { createBuildPipeline, config as rollupConfig } from '../rollup/index.js';
4
+ import { CONFIG } from "../config/index.js";
5
+ import { createBuildPipeline, config as rollupConfig } from "../rollup/index.js";
6
6
  const { log } = console;
7
7
  const allBuilds = createBuildPipeline();
8
8
  const allBuildsCount = allBuilds.length;
@@ -1 +1 @@
1
- {"version":3,"file":"build.js","sourceRoot":"","sources":["../../src/scripts/build.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,IAAI,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEhF,MAAM,EAAE,GAAG,EAAE,GAAG,OAAO,CAAA;AACvB,MAAM,SAAS,GAAG,mBAAmB,EAAE,CAAA;AACvC,MAAM,cAAc,GAAG,SAAS,CAAC,MAAM,CAAA;AAEvC,MAAM,YAAY,GAA2B;IAC3C,GAAG,EAAE,UAAU;IACf,EAAE,EAAE,WA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,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,CAAA;IACvE,CAAC,CAAC,CAAA;AACN,CAAC,CAAA;AAED,OAAO,EAAE,QAAQ,EAAE,CAAA","sourcesContent":["import chalk from 'chalk'\nimport { rimraf } from 'rimraf'\nimport { rollup } from 'rollup'\nimport { CONFIG } from '../config/index.js'\nimport { createBuildPipeline, config as rollupConfig } from '../rollup/index.js'\n\nconst { log } = console\nconst allBuilds = createBuildPipeline()\nconst allBuildsCount = allBuilds.length\n\nconst MODULE_TYPES: Record<string, string> = {\n cjs: 'CommonJS',\n es: 'ES Module',\n umd: 'UMD module',\n}\n\n// --------------------------------------------------------\n// BUILD rollup\n// --------------------------------------------------------\nasync function build({\n inputOptions,\n outputOptions,\n}: {\n inputOptions: any\n outputOptions: any\n}) {\n const bundle = await rollup(inputOptions)\n\n await bundle.write(outputOptions)\n}\n\n// --------------------------------------------------------\n// SERIALIZE ALL BUILDS\n// --------------------------------------------------------\nconst createBuilds = async () => {\n let p = Promise.resolve() // Q() in q\n\n // serialize builds\n allBuilds.forEach((item, i) => {\n const { output, ...input } = rollupConfig(item)\n const type = output.format\n\n p = p.then(() => {\n log(\n chalk.green(`🚧 Creating a build ${i + 1}/${allBuildsCount}`),\n chalk.gray(`(format: ${MODULE_TYPES[type]})`),\n )\n\n return build({ inputOptions: input, outputOptions: output }).catch(\n (e) => {\n log(\n `${chalk.bold.bgRed.white('⚠️ ERROR')} ${chalk.red(\n `Build ${i + 1}/${allBuildsCount} failed`,\n )}`,\n )\n log(chalk.gray(` Format: ${MODULE_TYPES[type]}`))\n log(chalk.gray(` File: ${output.file}`))\n log(e)\n throw e\n },\n )\n })\n })\n\n return p\n}\n\nconst runBuild = async () => {\n // --------------------------------------------------------\n // (1) delete build folder first\n // --------------------------------------------------------\n log(\n `${chalk.bold.bgBlue.black('[1/4]')} ${chalk.blue(\n '✂️ Cleaning up old build folder...',\n )}`,\n )\n\n rimraf.sync(`${process.cwd()}/${CONFIG.outputDir}`)\n\n log(\n `${chalk.bold.bgBlue.black('[2/4]')} ${chalk.blue('☑️ Old build removed')}`,\n )\n\n // --------------------------------------------------------\n // (2) build\n // --------------------------------------------------------\n log(\n `${chalk.bold.bgBlue.black('[3/4]')} ${chalk.blue(\n `💪 Generating ${allBuildsCount} builds in total...`,\n )}`,\n )\n\n log('\\n')\n\n await Promise.resolve()\n .then(() => createBuilds())\n .then(() => {\n log(`${chalk.bold.bgBlue.black('[4/4]')} ${chalk.blue('🎉 Done!')}`)\n })\n}\n\nexport { runBuild }\n"]}
1
+ {"version":3,"file":"build.js","sourceRoot":"","sources":["../../src/scripts/build.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,IAAI,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEhF,MAAM,EAAE,GAAG,EAAE,GAAG,OAAO,CAAA;AACvB,MAAM,SAAS,GAAG,mBAAmB,EAAE,CAAA;AACvC,MAAM,cAAc,GAAG,SAAS,CAAC,MAAM,CAAA;AAEvC,MAAM,YAAY,GAA2B;IAC3C,GAAG,EAAE,UAAU;IACf,EAAE,EAAE,WAAW;IACf,GAAG,EAAE,YAAY;CAClB,CAAA;AAED,2DAA2D;AAC3D,eAAe;AACf,2DAA2D;AAC3D,KAAK,UAAU,KAAK,CAAC,EACnB,YAAY,EACZ,aAAa,GAId;IACC,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC,CAAA;IAEzC,MAAM,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,CAAA;AACnC,CAAC;AAED,2DAA2D;AAC3D,uBAAuB;AACvB,2DAA2D;AAC3D,MAAM,YAAY,GAAG,KA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,EAAE;IAC1B,2DAA2D;IAC3D,gCAAgC;IAChC,2DAA2D;IAC3D,GAAG,CACD,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,KAAK,CAAC,IAAI,CAC/C,qCAAqC,CACtC,EAAE,CACJ,CAAA;IAED,MAAM,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,GAAG,EAAE,IAAI,MAAM,CAAC,SAAS,EAAE,CAAC,CAAA;IAEnD,GAAG,CACD,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,uBAAuB,CAAC,EAAE,CAC7E,CAAA;IAED,2DAA2D;IAC3D,YAAY;IACZ,2DAA2D;IAC3D,GAAG,CACD,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,KAAK,CAAC,IAAI,CAC/C,kBAAkB,cAAc,qBAAqB,CACtD,EAAE,CACJ,CAAA;IAED,GAAG,CAAC,IAAI,CAAC,CAAA;IAET,MAAM,OAAO,CAAC,OAAO,EAAE;SACpB,IAAI,CAAC,GAAG,EAAE,CAAC,YAAY,EAAE,CAAC;SAC1B,IAAI,CAAC,GAAG,EAAE;QACT,GAAG,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,CAAA;IACvE,CAAC,CAAC,CAAA;AACN,CAAC,CAAA;AAED,OAAO,EAAE,QAAQ,EAAE,CAAA","sourcesContent":["import chalk from 'chalk'\nimport { rimraf } from 'rimraf'\nimport { rollup } from 'rollup'\nimport { CONFIG } from '../config/index.ts'\nimport { createBuildPipeline, config as rollupConfig } from '../rollup/index.ts'\n\nconst { log } = console\nconst allBuilds = createBuildPipeline()\nconst allBuildsCount = allBuilds.length\n\nconst MODULE_TYPES: Record<string, string> = {\n cjs: 'CommonJS',\n es: 'ES Module',\n umd: 'UMD module',\n}\n\n// --------------------------------------------------------\n// BUILD rollup\n// --------------------------------------------------------\nasync function build({\n inputOptions,\n outputOptions,\n}: {\n inputOptions: any\n outputOptions: any\n}) {\n const bundle = await rollup(inputOptions)\n\n await bundle.write(outputOptions)\n}\n\n// --------------------------------------------------------\n// SERIALIZE ALL BUILDS\n// --------------------------------------------------------\nconst createBuilds = async () => {\n let p = Promise.resolve() // Q() in q\n\n // serialize builds\n allBuilds.forEach((item, i) => {\n const { output, ...input } = rollupConfig(item)\n const type = output.format\n\n p = p.then(() => {\n log(\n chalk.green(`🚧 Creating a build ${i + 1}/${allBuildsCount}`),\n chalk.gray(`(format: ${MODULE_TYPES[type]})`),\n )\n\n return build({ inputOptions: input, outputOptions: output }).catch(\n (e) => {\n log(\n `${chalk.bold.bgRed.white('⚠️ ERROR')} ${chalk.red(\n `Build ${i + 1}/${allBuildsCount} failed`,\n )}`,\n )\n log(chalk.gray(` Format: ${MODULE_TYPES[type]}`))\n log(chalk.gray(` File: ${output.file}`))\n log(e)\n throw e\n },\n )\n })\n })\n\n return p\n}\n\nconst runBuild = async () => {\n // --------------------------------------------------------\n // (1) delete build folder first\n // --------------------------------------------------------\n log(\n `${chalk.bold.bgBlue.black('[1/4]')} ${chalk.blue(\n '✂️ Cleaning up old build folder...',\n )}`,\n )\n\n rimraf.sync(`${process.cwd()}/${CONFIG.outputDir}`)\n\n log(\n `${chalk.bold.bgBlue.black('[2/4]')} ${chalk.blue('☑️ Old build removed')}`,\n )\n\n // --------------------------------------------------------\n // (2) build\n // --------------------------------------------------------\n log(\n `${chalk.bold.bgBlue.black('[3/4]')} ${chalk.blue(\n `💪 Generating ${allBuildsCount} builds in total...`,\n )}`,\n )\n\n log('\\n')\n\n await Promise.resolve()\n .then(() => createBuilds())\n .then(() => {\n log(`${chalk.bold.bgBlue.black('[4/4]')} ${chalk.blue('🎉 Done!')}`)\n })\n}\n\nexport { runBuild }\n"]}
@@ -1,3 +1,3 @@
1
- import { runBuild } from './scripts/build.js';
1
+ import { runBuild } from './scripts/build.ts';
2
2
  export { runBuild };
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -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: any[];
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;;;;;;;;;;;;;;;;;;;;;;;;CA8BrB,CAAA;AAED,eAAe,YAAY,CAAA"}
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"}
@@ -1,4 +1,4 @@
1
- import config from './config.js';
2
- import createBuildPipeline from './createBuildPipeline.js';
1
+ import config from './config.ts';
2
+ import createBuildPipeline from './createBuildPipeline.ts';
3
3
  export { config, createBuildPipeline };
4
4
  //# sourceMappingURL=index.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vitus-labs/tools-rollup",
3
- "version": "2.0.0",
3
+ "version": "2.2.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env node
2
- import { runBuild } from '../scripts/build.js'
2
+ import { runBuild } from '../scripts/build.ts'
3
3
 
4
4
  runBuild()
@@ -1,5 +1,5 @@
1
1
  import { describe, expect, it } from 'vitest'
2
- import baseConfig from './baseConfig'
2
+ import baseConfig from './baseConfig.ts'
3
3
 
4
4
  describe('baseConfig', () => {
5
5
  it('should have correct directory settings', () => {
@@ -1,5 +1,5 @@
1
1
  import { PKG, TS_CONFIG, VL_CONFIG } from '@vitus-labs/tools-core'
2
- import baseConfig from './baseConfig.js'
2
+ import baseConfig from './baseConfig.ts'
3
3
 
4
4
  const CONFIG_KEY = 'build'
5
5
 
package/src/index.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { runBuild } from './scripts/build.js'
1
+ import { runBuild } from './scripts/build.ts'
2
2
 
3
3
  export { runBuild }
@@ -43,35 +43,52 @@ const {
43
43
  vi.mock('@rollup/plugin-node-resolve', () => ({
44
44
  nodeResolve: mockNodeResolve,
45
45
  }))
46
- vi.mock('@rollup/plugin-replace', () => ({ default: mockReplace }))
47
- vi.mock('@rollup/plugin-terser', () => ({ default: mockTerser }))
48
- vi.mock('rollup-plugin-typescript2', () => ({ default: mockTypescript }))
49
46
  vi.mock('rollup-plugin-api-extractor', () => ({
50
47
  apiExtractor: mockApiExtractor,
51
48
  }))
52
- vi.mock('rollup-plugin-filesize', () => ({ default: mockFilesize }))
53
49
  vi.mock('rollup-plugin-visualizer', () => ({ visualizer: mockVisualizer }))
54
50
 
51
+ // CJS plugins are loaded via createRequire — dispatch on package name.
55
52
  vi.mock('node:module', () => ({
56
- createRequire: vi.fn(() => vi.fn(() => ({}))),
53
+ createRequire: vi.fn(
54
+ () => (id: string) =>
55
+ ({
56
+ 'rollup-plugin-filesize': mockFilesize,
57
+ 'rollup-plugin-typescript2': mockTypescript,
58
+ '@rollup/plugin-replace': mockReplace,
59
+ '@rollup/plugin-terser': mockTerser,
60
+ 'ts-patch/compiler': {},
61
+ })[id] ?? {},
62
+ ),
57
63
  }))
58
64
 
59
65
  vi.mock('@vitus-labs/tools-core', () => ({
60
66
  swapGlobals: (globals: Record<string, string>) =>
61
67
  Object.fromEntries(Object.entries(globals).map(([k, v]) => [v, k])),
68
+ expandExternal: (id: string | RegExp): string | RegExp => {
69
+ if (id instanceof RegExp) return id
70
+ const escaped = id.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
71
+ return new RegExp(`^${escaped}(\\/|$)`)
72
+ },
62
73
  }))
63
74
 
64
- vi.mock('../config/index.js', () => ({
75
+ vi.mock('../config/index.ts', () => ({
65
76
  CONFIG: mockConfig,
66
77
  PKG: mockPKG,
67
78
  PLATFORMS: ['browser', 'node', 'web', 'native'],
68
79
  }))
69
80
 
70
- import rollupConfig from './config.js'
81
+ import rollupConfig from './config.ts'
71
82
 
72
83
  const defaultConfig = { ...mockConfig }
73
84
  const defaultPKG = { ...mockPKG }
74
85
 
86
+ const matchesExternal = (
87
+ externals: (string | RegExp)[] | undefined,
88
+ id: string,
89
+ ): boolean =>
90
+ (externals ?? []).some((e) => (typeof e === 'string' ? e === id : e.test(id)))
91
+
75
92
  describe('rollupConfig', () => {
76
93
  beforeEach(() => {
77
94
  vi.clearAllMocks()
@@ -91,8 +108,9 @@ describe('rollupConfig', () => {
91
108
  expect(config.output.file).toBe('lib/index.js')
92
109
  expect(config.output.format).toBe('es')
93
110
  expect(config.output.sourcemap).toBe(true)
94
- expect(config.external).toContain('react')
95
- expect(config.external).toContain('react/jsx-runtime')
111
+ expect(matchesExternal(config.external, 'react')).toBe(true)
112
+ expect(matchesExternal(config.external, 'react/jsx-runtime')).toBe(true)
113
+ expect(matchesExternal(config.external, 'react/jsx-dev-runtime')).toBe(true)
96
114
  })
97
115
 
98
116
  it('should set named exports for CJS format', () => {
@@ -1,16 +1,16 @@
1
1
  import { createRequire } from 'node:module'
2
2
  import { nodeResolve } from '@rollup/plugin-node-resolve'
3
- import replace from '@rollup/plugin-replace'
4
- import terser from '@rollup/plugin-terser'
5
- import { swapGlobals } from '@vitus-labs/tools-core'
3
+ import { expandExternal, swapGlobals } from '@vitus-labs/tools-core'
6
4
  import { apiExtractor } from 'rollup-plugin-api-extractor'
7
- import filesize from 'rollup-plugin-filesize'
8
- import typescript from 'rollup-plugin-typescript2'
9
5
  import { visualizer } from 'rollup-plugin-visualizer'
10
- import { CONFIG, PKG, PLATFORMS } from '../config/index.js'
6
+ import { CONFIG, PKG, PLATFORMS } from '../config/index.ts'
11
7
 
12
8
  const require = createRequire(import.meta.url)
13
9
  const tspCompiler = require('ts-patch/compiler')
10
+ const filesize: typeof import('rollup-plugin-filesize').default = require('rollup-plugin-filesize')
11
+ const typescript: typeof import('rollup-plugin-typescript2').default = require('rollup-plugin-typescript2')
12
+ const replace: typeof import('@rollup/plugin-replace').default = require('@rollup/plugin-replace')
13
+ const terser: typeof import('@rollup/plugin-terser').default = require('@rollup/plugin-terser')
14
14
 
15
15
  const defineExtensions = (platform: string) => {
16
16
  const platformExtensions: string[] = []
@@ -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,
@@ -14,7 +14,7 @@ const { mockPKG } = vi.hoisted(() => ({
14
14
  } as Record<string, any>,
15
15
  }))
16
16
 
17
- vi.mock('../config/index.js', () => ({
17
+ vi.mock('../config/index.ts', () => ({
18
18
  PKG: mockPKG,
19
19
  CONFIG: {},
20
20
  PLATFORMS: ['browser', 'node', 'web', 'native'],
@@ -1,4 +1,4 @@
1
- import { PKG } from '../config/index.js'
1
+ import { PKG } from '../config/index.ts'
2
2
 
3
3
  const isESModuleOnly = PKG.type === 'module'
4
4
  const typesFilePath = PKG?.exports?.types || PKG.types || PKG.typings
@@ -1,4 +1,4 @@
1
- import config from './config.js'
2
- import createBuildPipeline from './createBuildPipeline.js'
1
+ import config from './config.ts'
2
+ import createBuildPipeline from './createBuildPipeline.ts'
3
3
 
4
4
  export { config, createBuildPipeline }
@@ -15,11 +15,11 @@ const {
15
15
  vi.mock('rollup', () => ({ rollup: mockRollup }))
16
16
  vi.mock('rimraf', () => ({ rimraf: { sync: vi.fn() } }))
17
17
 
18
- vi.mock('../config/index.js', () => ({
18
+ vi.mock('../config/index.ts', () => ({
19
19
  CONFIG: { outputDir: 'lib' },
20
20
  }))
21
21
 
22
- vi.mock('../rollup/index.js', () => ({
22
+ vi.mock('../rollup/index.ts', () => ({
23
23
  createBuildPipeline: mockCreateBuildPipeline,
24
24
  config: mockRollupConfig,
25
25
  }))
@@ -1,8 +1,8 @@
1
1
  import chalk from 'chalk'
2
2
  import { rimraf } from 'rimraf'
3
3
  import { rollup } from 'rollup'
4
- import { CONFIG } from '../config/index.js'
5
- import { createBuildPipeline, config as rollupConfig } from '../rollup/index.js'
4
+ import { CONFIG } from '../config/index.ts'
5
+ import { createBuildPipeline, config as rollupConfig } from '../rollup/index.ts'
6
6
 
7
7
  const { log } = console
8
8
  const allBuilds = createBuildPipeline()