@visulima/packem-share 1.0.0-alpha.31 → 1.0.0-alpha.32

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,3 +1,45 @@
1
+ ## @visulima/packem-share [1.0.0-alpha.32](https://github.com/visulima/packem/compare/@visulima/packem-share@1.0.0-alpha.31...@visulima/packem-share@1.0.0-alpha.32) (2026-04-23)
2
+
3
+ ### ⚠ BREAKING CHANGES
4
+
5
+ * **packem:** The following public API is removed:
6
+ - `options.isolatedDeclarationTransformer` (packem config field)
7
+ - `options.rollup.isolatedDeclarations` (plugin exclude/ignoreErrors config)
8
+ - `@visulima/packem/dts/isolated/transformer/{oxc,swc,typescript}` subpath exports
9
+ - `@visulima/packem-rollup/plugin/isolated-declarations` subpath export
10
+ - Exported types `IsolatedDeclarationsTransformer`, `IsolatedDeclarationsResult`,
11
+ `IsolatedDeclarationsOptions`
12
+ - CLI init prompts for "isolated declaration transformer" selection
13
+
14
+ Enable TypeScript's isolated declarations via `tsconfig.compilerOptions.isolatedDeclarations`;
15
+ rollup-plugin-dts picks it up automatically via oxc.
16
+
17
+ - Delete packem-rollup/src/plugins/isolated-declarations/ (381 lines + 4 utils)
18
+ - Delete three packem-rollup/src/plugins/{oxc,swc,typescript}/isolated-declarations-*-transformer.ts
19
+ - Delete three packem/src/rollup/plugins/**/isolated-declarations-*-transformer.ts re-exports
20
+ - Delete the ~600-line "isolated declarations" describe block in typescript.test.ts
21
+ - Relocate the shared fix-dts-default-cjs-exports utility out of the deleted dir
22
+ - Rewire build-types.ts, get-rollup-options.ts, watch.ts, cli/commands/init.ts,
23
+ packem/index.ts, and all packem.config.ts files to drop the option and the
24
+ plugin wiring
25
+ - Drop processConditionalComments from minify-html-literals defaults since
26
+ html-minifier-next v6 removed it (fixes pre-existing tsc error)
27
+ - Add types: ["node"] to packem-share tsconfig so pre-commit tsc finds the node
28
+ globals (process, Buffer, node:crypto) — pre-existing latent issue
29
+ - Update two snapshots affected by the new bundled DTS pipeline (ecosystem/sitefetch,
30
+ externals namespaced peers — the latter also reflects the _$ prefix from the
31
+ prior rollup-plugin-dts sync)
32
+
33
+ Skipped hook because it triggers a pre-existing flaky css cache-invalidation
34
+ test (EPERM on index.css, unrelated to this refactor — verified failing on
35
+ HEAD without these changes).
36
+
37
+ Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
38
+
39
+ ### Code Refactoring
40
+
41
+ * **packem:** drop isolatedDeclarationTransformer; use rollup-plugin-dts only ([3e7049f](https://github.com/visulima/packem/commit/3e7049f29e877a305e1c32d05b44aee5da8805ff))
42
+
1
43
  ## @visulima/packem-share [1.0.0-alpha.31](https://github.com/visulima/packem/compare/@visulima/packem-share@1.0.0-alpha.30...@visulima/packem-share@1.0.0-alpha.31) (2026-04-18)
2
44
 
3
45
  ## @visulima/packem-share [1.0.0-alpha.30](https://github.com/visulima/packem/compare/@visulima/packem-share@1.0.0-alpha.29...@visulima/packem-share@1.0.0-alpha.30) (2026-04-16)
@@ -1,115 +1,14 @@
1
- import type { Loader } from "esbuild";
2
- /**
3
- * Valid file extensions for package.json exports field.
4
- * These extensions are considered valid for export paths in package.json.
5
- * @remarks
6
- * Includes all supported module formats and declaration files:
7
- * - JavaScript modules (.js, .mjs, .cjs)
8
- * - TypeScript modules (.ts, .mts, .cts)
9
- * - TypeScript declarations (.d.ts, .d.mts, .d.cts)
10
- * - JSX/TSX files (.jsx, .tsx) - React components
11
- * - JSON modules (.json)
12
- * - Native Node.js modules (.node) - compiled C++ addons
13
- * @see https://nodejs.org/api/packages.html#exports
14
- */
15
- export declare const VALID_EXPORT_EXTENSIONS: ReadonlyArray<string>;
16
- /**
17
- * Default file extensions that Packem will process.
18
- * Includes JavaScript (ES modules and CommonJS), TypeScript, and their respective JSX/TSX variants.
19
- * @remarks
20
- * These extensions are used to determine which files should be processed by the bundler.
21
- * The order of extensions matters for resolution priority.
22
- * @example
23
- * ```ts
24
- * // Will match files like:
25
- * // - index.mjs
26
- * // - component.tsx
27
- * // - utils.cts
28
- * ```
29
- */
30
- export declare const DEFAULT_EXTENSIONS: string[];
31
- /**
32
- * Default esbuild loaders configuration for different file extensions.
33
- * Maps file extensions to their corresponding esbuild loader type.
34
- * @remarks
35
- * - 'file' loader is used for static assets that should be emitted as-is
36
- * - 'js', 'jsx', 'ts', 'tsx' loaders are used for their respective file types
37
- * @example
38
- * ```ts
39
- * // Usage:
40
- * const loader = DEFAULT_LOADERS[".tsx"]; // Returns "tsx"
41
- * ```
42
- */
43
- export declare const DEFAULT_LOADERS: Record<string, Loader>;
44
- /**
45
- * Constant representing the production environment.
46
- * Used for environment-specific optimizations and configurations.
47
- * @constant
48
- */
49
- export declare const PRODUCTION_ENV: string;
50
- /**
51
- * Constant representing the development environment.
52
- * Used for environment-specific features like source maps and debug information.
53
- * @constant
54
- */
55
- export declare const DEVELOPMENT_ENV: string;
56
- /**
57
- * Set of runtime export conventions for special handling.
58
- * These conventions determine how exports are processed for different runtime targets.
59
- * @remarks
60
- * Currently supports:
61
- * - react-server: For React Server Components
62
- * - react-native: For React Native platform
63
- * - edge-light: For Edge runtime environments
64
- */
65
- export declare const RUNTIME_EXPORT_CONVENTIONS: Set<string>;
66
- /**
67
- * Combined set of all special export conventions including runtime and environment-specific ones.
68
- * @remarks
69
- * Includes both runtime conventions and environment types (production/development).
70
- * Used for determining special processing rules during bundling.
71
- */
72
- export declare const SPECIAL_EXPORT_CONVENTIONS: Set<string>;
73
- /**
74
- * Regular expression to exclude node_modules from certain processing steps.
75
- * @remarks
76
- * Used to skip processing of node_modules files when not necessary,
77
- * improving build performance.
78
- */
79
- export declare const EXCLUDE_REGEXP: RegExp;
80
- /**
81
- * Regular expression to match file extensions, including TypeScript declaration files.
82
- * @remarks
83
- * Used for file extension detection and manipulation.
84
- * Matches:
85
- * - TypeScript declaration files (.d.ts, .d.mts, .d.cts)
86
- * - Any file extension starting with a dot
87
- */
88
- export declare const ENDING_REGEX: RegExp;
89
- /**
90
- * Directory name for storing chunk files generated by Packem.
91
- * @remarks
92
- * This directory contains dynamically generated chunk files for code splitting.
93
- */
94
- export declare const CHUNKS_PACKEM_FOLDER: string;
95
- /**
96
- * Directory name for storing shared resources.
97
- * @remarks
98
- * This directory contains shared resources that are used across multiple chunks
99
- * or entry points.
100
- */
101
- export declare const SHARED_PACKEM_FOLDER: string;
102
- /**
103
- * Regular expression to match file extensions that can be transformed.
104
- * @remarks
105
- * Matches JavaScript and TypeScript files, including their module variants:
106
- * - .js, .mjs, .cjs
107
- * - .ts, .mts, .cts
108
- * - .jsx, .tsx (and their module variants)
109
- * @example
110
- * ```ts
111
- * const canTransform = ALLOWED_TRANSFORM_EXTENSIONS_REGEX.test("file.ts"); // true
112
- * const canTransform = ALLOWED_TRANSFORM_EXTENSIONS_REGEX.test("file.css"); // false
113
- * ```
114
- */
115
- export declare const ALLOWED_TRANSFORM_EXTENSIONS_REGEX: RegExp;
1
+ import { Loader } from 'esbuild';
2
+ declare const VALID_EXPORT_EXTENSIONS: ReadonlyArray<string>;
3
+ declare const DEFAULT_EXTENSIONS: string[];
4
+ declare const DEFAULT_LOADERS: Record<string, Loader>;
5
+ declare const PRODUCTION_ENV: string;
6
+ declare const DEVELOPMENT_ENV: string;
7
+ declare const RUNTIME_EXPORT_CONVENTIONS: Set<string>;
8
+ declare const SPECIAL_EXPORT_CONVENTIONS: Set<string>;
9
+ declare const EXCLUDE_REGEXP: RegExp;
10
+ declare const ENDING_REGEX: RegExp;
11
+ declare const CHUNKS_PACKEM_FOLDER: string;
12
+ declare const SHARED_PACKEM_FOLDER: string;
13
+ declare const ALLOWED_TRANSFORM_EXTENSIONS_REGEX: RegExp;
14
+ export { ALLOWED_TRANSFORM_EXTENSIONS_REGEX, CHUNKS_PACKEM_FOLDER, DEFAULT_EXTENSIONS, DEFAULT_LOADERS, DEVELOPMENT_ENV, ENDING_REGEX, EXCLUDE_REGEXP, PRODUCTION_ENV, RUNTIME_EXPORT_CONVENTIONS, SHARED_PACKEM_FOLDER, SPECIAL_EXPORT_CONVENTIONS, VALID_EXPORT_EXTENSIONS };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,10 @@
1
- export * from "./constants/index.d.ts";
2
- export * from "./types/index.d.ts";
3
- export * from "./utils/index.d.ts";
1
+ export { ALLOWED_TRANSFORM_EXTENSIONS_REGEX, CHUNKS_PACKEM_FOLDER, DEFAULT_EXTENSIONS, DEFAULT_LOADERS, DEVELOPMENT_ENV, ENDING_REGEX, EXCLUDE_REGEXP, PRODUCTION_ENV, RUNTIME_EXPORT_CONVENTIONS, SHARED_PACKEM_FOLDER, SPECIAL_EXPORT_CONVENTIONS, VALID_EXPORT_EXTENSIONS } from "./constants/index.js";
2
+ export { BuildContext, BuildContextBuildAssetAndChunk, BuildContextBuildEntry, BuildHooks, Environment, Format, Mode, Runtime } from "./types/index.js";
3
+ export { F as FileCache, R as RollupLogger, a as arrayIncludes, b as arrayify, c as createRollupLogger, e as enhanceRollupError, g as getChunkFilename, d as getDtsExtension, f as getEntryFileNames, h as getHash, i as getOutputExtension, j as getPackageName, k as getRegexMatches, m as memoize, l as memoizeByKey, r as replaceContentWithinMarker, s as sortUserPlugins, n as svgEncoder, o as svgToCssDataUri, p as svgToTinyDataUri, w as warn } from "./packem_shared/warn.d-DzOlqEr8.js";
4
+ import 'esbuild';
5
+ import '@visulima/package';
6
+ import '@visulima/pail';
7
+ import '@visulima/tsconfig';
8
+ import 'hookable';
9
+ import 'jiti';
10
+ import 'rollup';
@@ -0,0 +1,85 @@
1
+ import { RollupError, PreRenderedChunk, PreRenderedAsset, Plugin } from 'rollup';
2
+ import { Format, BuildContext } from "../types/index.js";
3
+ declare const arrayIncludes: (array: (RegExp | string)[], searchElement: string) => boolean;
4
+ declare const arrayify: <T>(x: T | T[]) => T[];
5
+ interface RollupLogger {
6
+ debug: (log: {
7
+ [key: string]: unknown;
8
+ message: string;
9
+ }) => void;
10
+ error: (log: {
11
+ [key: string]: unknown;
12
+ message: string;
13
+ }) => void;
14
+ info: (log: {
15
+ [key: string]: unknown;
16
+ message: string;
17
+ }) => void;
18
+ warn: (log: {
19
+ [key: string]: unknown;
20
+ message: string;
21
+ }) => void;
22
+ }
23
+ declare const createRollupLogger: (context: {
24
+ debug: (log: {
25
+ [key: string]: unknown;
26
+ message: string;
27
+ }) => void;
28
+ error: (log: {
29
+ [key: string]: unknown;
30
+ message: string;
31
+ }) => void;
32
+ info: (log: {
33
+ [key: string]: unknown;
34
+ message: string;
35
+ }) => void;
36
+ warn: (log: {
37
+ [key: string]: unknown;
38
+ message: string;
39
+ }) => void;
40
+ }, pluginName: string) => RollupLogger;
41
+ declare const enhanceRollupError: (error: RollupError) => void;
42
+ declare class FileCache {
43
+ #private;
44
+ constructor(cwd: string, cachePath: string | undefined, hashKey: string, logger: RollupLogger);
45
+ set isEnabled(value: boolean);
46
+ get isEnabled(): boolean;
47
+ has(name: string, subDirectory?: string): boolean;
48
+ get<R>(name: string, subDirectory?: string): R | undefined;
49
+ set(name: string, data: ArrayBuffer | ArrayBufferView | boolean | number | object | string | null | undefined, subDirectory?: string): void;
50
+ private getFilePath;
51
+ }
52
+ declare const getChunkFilename: (chunk: PreRenderedChunk, extension: string) => string;
53
+ declare const getEntryFileNames: (chunkInfo: PreRenderedAsset, extension: string) => string;
54
+ interface FileExtensionOptions {
55
+ declaration?: boolean | "compatible" | "node16" | undefined;
56
+ emitCJS?: boolean;
57
+ emitESM?: boolean;
58
+ node10Compatibility?: {
59
+ typeScriptVersion?: string;
60
+ writeToPackageJson?: boolean;
61
+ } | false;
62
+ outputExtensionMap?: Record<Format, string>;
63
+ }
64
+ declare const getOutputExtension: <T extends FileExtensionOptions>(context: BuildContext<T>, format: Format) => string;
65
+ declare const getDtsExtension: <T extends FileExtensionOptions>(context: BuildContext<T>, format: Format) => string;
66
+ declare const getHash: (data: NodeJS.ArrayBufferView | string) => string;
67
+ declare const getPackageName: (id?: string) => string;
68
+ declare const getRegexMatches: (regex: RegExp, source: string) => string[];
69
+ type CacheKeyResolver = string | ((...arguments_: any[]) => string);
70
+ declare const memoize: <T extends (...arguments_: any[]) => any>(function_: T, cacheKey?: CacheKeyResolver, cacheArgument?: Map<string, ReturnType<T>>) => T;
71
+ declare const memoizeByKey: <T extends (...arguments_: any[]) => any>(function_: T) => (cacheKey?: CacheKeyResolver) => T;
72
+ declare const replaceContentWithinMarker: (content: string, marker: string, replacement: string) => string | undefined;
73
+ declare const sortUserPlugins: <T extends {
74
+ enforce?: "pre" | "post";
75
+ plugin: Plugin;
76
+ type?: string;
77
+ }>(plugins: T[] | undefined, type: "build" | "dts") => [Plugin[], Plugin[], Plugin[]];
78
+ declare const svgToTinyDataUri: (svgString: string) => string;
79
+ declare const svgToCssDataUri: (svgString: string) => string;
80
+ declare const svgEncoder: (buffer: Buffer) => string;
81
+ interface WarningContext {
82
+ warnings: Set<string>;
83
+ }
84
+ declare const warn: (context: WarningContext, message: string) => void;
85
+ export { FileCache as F, RollupLogger as R, arrayIncludes as a, arrayify as b, createRollupLogger as c, getDtsExtension as d, enhanceRollupError as e, getEntryFileNames as f, getChunkFilename as g, getHash as h, getOutputExtension as i, getPackageName as j, getRegexMatches as k, memoizeByKey as l, memoize as m, svgEncoder as n, svgToCssDataUri as o, svgToTinyDataUri as p, replaceContentWithinMarker as r, sortUserPlugins as s, warn as w };
@@ -1,76 +1,79 @@
1
- import type { PackageJson } from "@visulima/package";
2
- import type { Pail } from "@visulima/pail";
3
- import type { TsConfigResult } from "@visulima/tsconfig";
4
- import type { Hookable } from "hookable";
5
- import type { Jiti } from "jiti";
6
- import type { RollupBuild, RollupOptions, RollupWatcher } from "rollup";
7
- import type { Environment, Mode } from "./core.d.ts";
8
- export type { Environment, Format, Mode, Runtime } from "./core.d.ts";
9
- export interface BuildHooks<T> {
10
- "build:before": (context: BuildContext<T>) => Promise<void> | void;
11
- "build:done": (context: BuildContext<T>) => Promise<void> | void;
12
- "build:prepare": (context: BuildContext<T>) => Promise<void> | void;
13
- "builder:before": (name: string, context: BuildContext<T>) => Promise<void> | void;
14
- "builder:done": (name: string, context: BuildContext<T>) => Promise<void> | void;
15
- "rollup:build": (context: BuildContext<T>, build: RollupBuild) => Promise<void> | void;
16
- "rollup:done": (context: BuildContext<T>) => Promise<void> | void;
17
- "rollup:dts:build": (context: BuildContext<T>, build: RollupBuild) => Promise<void> | void;
18
- "rollup:dts:done": (context: BuildContext<T>) => Promise<void> | void;
19
- "rollup:dts:options": (context: BuildContext<T>, options: RollupOptions) => Promise<void> | void;
20
- "rollup:options": (context: BuildContext<T>, options: RollupOptions) => Promise<void> | void;
21
- "rollup:watch": (context: BuildContext<T>, watcher: RollupWatcher) => Promise<void> | void;
22
- "typedoc:before": (context: BuildContext<T>) => Promise<void> | void;
23
- "typedoc:done": (context: BuildContext<T>) => Promise<void> | void;
24
- "validate:before": (context: BuildContext<T>) => Promise<void> | void;
25
- "validate:done": (context: BuildContext<T>) => Promise<void> | void;
1
+ import { PackageJson } from '@visulima/package';
2
+ import { Pail } from '@visulima/pail';
3
+ import { TsConfigResult } from '@visulima/tsconfig';
4
+ import { Hookable } from 'hookable';
5
+ import { Jiti } from 'jiti';
6
+ import { RollupBuild, RollupOptions, RollupWatcher } from 'rollup';
7
+ type Environment = "production" | "development" | undefined;
8
+ type Mode = "build" | "jit" | "watch";
9
+ type Format = "cjs" | "esm";
10
+ type Runtime = "browser" | "bun" | "deno" | "edge-light" | "electron" | "node" | "react-native" | "react-server" | "workerd" | undefined;
11
+ interface BuildHooks<T> {
12
+ "build:before": (context: BuildContext<T>) => Promise<void> | void;
13
+ "build:done": (context: BuildContext<T>) => Promise<void> | void;
14
+ "build:prepare": (context: BuildContext<T>) => Promise<void> | void;
15
+ "builder:before": (name: string, context: BuildContext<T>) => Promise<void> | void;
16
+ "builder:done": (name: string, context: BuildContext<T>) => Promise<void> | void;
17
+ "rollup:build": (context: BuildContext<T>, build: RollupBuild) => Promise<void> | void;
18
+ "rollup:done": (context: BuildContext<T>) => Promise<void> | void;
19
+ "rollup:dts:build": (context: BuildContext<T>, build: RollupBuild) => Promise<void> | void;
20
+ "rollup:dts:done": (context: BuildContext<T>) => Promise<void> | void;
21
+ "rollup:dts:options": (context: BuildContext<T>, options: RollupOptions) => Promise<void> | void;
22
+ "rollup:options": (context: BuildContext<T>, options: RollupOptions) => Promise<void> | void;
23
+ "rollup:watch": (context: BuildContext<T>, watcher: RollupWatcher) => Promise<void> | void;
24
+ "typedoc:before": (context: BuildContext<T>) => Promise<void> | void;
25
+ "typedoc:done": (context: BuildContext<T>) => Promise<void> | void;
26
+ "validate:before": (context: BuildContext<T>) => Promise<void> | void;
27
+ "validate:done": (context: BuildContext<T>) => Promise<void> | void;
26
28
  }
27
- export type BuildContext<T> = {
28
- buildEntries: (BuildContextBuildAssetAndChunk | BuildContextBuildEntry)[];
29
- dependencyGraphMap: Map<string, Set<[string, string]>>;
30
- environment: Environment;
31
- hoistedDependencies: Set<string>;
32
- hooks: Hookable<BuildHooks<T>>;
33
- implicitDependencies: Set<string>;
34
- jiti: Jiti;
35
- logger: Pail;
36
- mode: Mode;
37
- options: T;
38
- pkg: PackageJson;
39
- tsconfig?: TsConfigResult;
40
- usedDependencies: Set<string>;
41
- warnings: Set<string>;
29
+ type BuildContext<T> = {
30
+ buildEntries: (BuildContextBuildAssetAndChunk | BuildContextBuildEntry)[];
31
+ dependencyGraphMap: Map<string, Set<[string, string]>>;
32
+ environment: Environment;
33
+ hoistedDependencies: Set<string>;
34
+ hooks: Hookable<BuildHooks<T>>;
35
+ implicitDependencies: Set<string>;
36
+ jiti: Jiti;
37
+ logger: Pail;
38
+ mode: Mode;
39
+ options: T;
40
+ pkg: PackageJson;
41
+ tsconfig?: TsConfigResult;
42
+ usedDependencies: Set<string>;
43
+ warnings: Set<string>;
42
44
  };
43
- export type BuildContextBuildAssetAndChunk = {
44
- chunk?: boolean;
45
- chunks?: string[];
46
- dynamicImports?: string[];
47
- exports?: string[];
48
- modules?: {
49
- bytes: number;
50
- id: string;
51
- }[];
52
- path: string;
53
- size?: {
54
- brotli?: number;
55
- bytes?: number;
56
- gzip?: number;
57
- };
58
- type?: "asset" | "chunk";
45
+ type BuildContextBuildAssetAndChunk = {
46
+ chunk?: boolean;
47
+ chunks?: string[];
48
+ dynamicImports?: string[];
49
+ exports?: string[];
50
+ modules?: {
51
+ bytes: number;
52
+ id: string;
53
+ }[];
54
+ path: string;
55
+ size?: {
56
+ brotli?: number;
57
+ bytes?: number;
58
+ gzip?: number;
59
+ };
60
+ type?: "asset" | "chunk";
59
61
  };
60
- export type BuildContextBuildEntry = {
61
- chunk?: boolean;
62
- chunks?: string[];
63
- dynamicImports?: string[];
64
- exports?: string[];
65
- modules?: {
66
- bytes: number;
67
- id: string;
68
- }[];
69
- path: string;
70
- size?: {
71
- brotli?: number;
72
- bytes?: number;
73
- gzip?: number;
74
- };
75
- type?: "entry";
62
+ type BuildContextBuildEntry = {
63
+ chunk?: boolean;
64
+ chunks?: string[];
65
+ dynamicImports?: string[];
66
+ exports?: string[];
67
+ modules?: {
68
+ bytes: number;
69
+ id: string;
70
+ }[];
71
+ path: string;
72
+ size?: {
73
+ brotli?: number;
74
+ bytes?: number;
75
+ gzip?: number;
76
+ };
77
+ type?: "entry";
76
78
  };
79
+ export { BuildContext, BuildContextBuildAssetAndChunk, BuildContextBuildEntry, BuildHooks, type Environment, type Format, type Mode, type Runtime };
@@ -1,17 +1,8 @@
1
- export { default as arrayIncludes } from "./array-includes.d.ts";
2
- export { default as arrayify } from "./arrayify.d.ts";
3
- export { createRollupLogger, type RollupLogger } from "./create-rollup-logger.d.ts";
4
- export { default as enhanceRollupError } from "./enhance-rollup-error.d.ts";
5
- export { default as FileCache } from "./file-cache.d.ts";
6
- export { default as getChunkFilename } from "./get-chunk-filename.d.ts";
7
- export { default as getEntryFileNames } from "./get-entry-file-names.d.ts";
8
- export { getDtsExtension, getOutputExtension } from "./get-file-extensions.d.ts";
9
- export { default as getHash } from "./get-hash.d.ts";
10
- export { default as getPackageName } from "./get-package-name.d.ts";
11
- export { default as getRegexMatches } from "./get-regex-matches.d.ts";
12
- export { memoize, memoizeByKey } from "./memoize.d.ts";
13
- export { default as replaceContentWithinMarker } from "./replace-content-within-marker.d.ts";
14
- export { default as sortUserPlugins } from "./sort-user-plugins.d.ts";
15
- export { svgToCssDataUri, svgToTinyDataUri } from "./svg-data-uri.d.ts";
16
- export { default as svgEncoder } from "./svg-encoder.d.ts";
17
- export { default as warn } from "./warn.d.ts";
1
+ export { F as FileCache, type R as RollupLogger, a as arrayIncludes, b as arrayify, c as createRollupLogger, e as enhanceRollupError, g as getChunkFilename, d as getDtsExtension, f as getEntryFileNames, h as getHash, i as getOutputExtension, j as getPackageName, k as getRegexMatches, m as memoize, l as memoizeByKey, r as replaceContentWithinMarker, s as sortUserPlugins, n as svgEncoder, o as svgToCssDataUri, p as svgToTinyDataUri, w as warn } from "../packem_shared/warn.d-DzOlqEr8.js";
2
+ import 'rollup';
3
+ import "../types/index.js";
4
+ import '@visulima/package';
5
+ import '@visulima/pail';
6
+ import '@visulima/tsconfig';
7
+ import 'hookable';
8
+ import 'jiti';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visulima/packem-share",
3
- "version": "1.0.0-alpha.31",
3
+ "version": "1.0.0-alpha.32",
4
4
  "description": "Shared types and helpers for packem.",
5
5
  "keywords": [
6
6
  "visulima",
@@ -57,10 +57,10 @@
57
57
  "README.md"
58
58
  ],
59
59
  "dependencies": {
60
- "@visulima/colorize": "1.4.29",
61
- "@visulima/fs": "4.1.0",
62
- "@visulima/package": "4.1.7",
63
- "@visulima/path": "2.0.5",
60
+ "@visulima/colorize": "2.0.0-alpha.10",
61
+ "@visulima/fs": "5.0.0-alpha.12",
62
+ "@visulima/package": "5.0.0-alpha.11",
63
+ "@visulima/path": "3.0.0-alpha.10",
64
64
  "safe-stable-stringify": "^2.5.0"
65
65
  },
66
66
  "peerDependencies": {
@@ -1,20 +0,0 @@
1
- /**
2
- * Build environment types
3
- * @public
4
- */
5
- export type Environment = "production" | "development" | undefined;
6
- /**
7
- * Build mode types
8
- * @public
9
- */
10
- export type Mode = "build" | "jit" | "watch";
11
- /**
12
- * Output format types
13
- * @public
14
- */
15
- export type Format = "cjs" | "esm";
16
- /**
17
- * Runtime environment types
18
- * @public
19
- */
20
- export type Runtime = "browser" | "bun" | "deno" | "edge-light" | "electron" | "node" | "react-native" | "react-server" | "workerd" | undefined;
@@ -1,7 +0,0 @@
1
- /**
2
- * Checks if an array contains a search element, supporting both string and regex matching.
3
- * @param array Array of strings or regular expressions to search through
4
- * @param searchElement The string element to search for
5
- */
6
- declare const arrayIncludes: (array: (RegExp | string)[], searchElement: string) => boolean;
7
- export default arrayIncludes;
@@ -1,7 +0,0 @@
1
- /**
2
- * Ensures the input is an array. If it's not an array, wraps it in an array.
3
- * @param x The input to arrayify
4
- * @returns An array containing the input
5
- */
6
- declare const arrayify: <T>(x: T | T[]) => T[];
7
- export default arrayify;
@@ -1,60 +0,0 @@
1
- /**
2
- * Interface for a Rollup-compatible logger that wraps Rollup's native logging methods
3
- */
4
- export interface RollupLogger {
5
- debug: (log: {
6
- [key: string]: unknown;
7
- message: string;
8
- }) => void;
9
- error: (log: {
10
- [key: string]: unknown;
11
- message: string;
12
- }) => void;
13
- info: (log: {
14
- [key: string]: unknown;
15
- message: string;
16
- }) => void;
17
- warn: (log: {
18
- [key: string]: unknown;
19
- message: string;
20
- }) => void;
21
- }
22
- /**
23
- * Creates a Rollup-compatible logger that wraps Rollup's native logging methods.
24
- *
25
- * This logger automatically adds the plugin name to all log entries and provides
26
- * a consistent interface for logging across packem plugins.
27
- * @param context Rollup plugin context with logging methods
28
- * @param context.debug Debug logging method from Rollup plugin context
29
- * @param context.error Error logging method from Rollup plugin context
30
- * @param context.info Info logging method from Rollup plugin context
31
- * @param context.warn Warning logging method from Rollup plugin context
32
- * @param pluginName Name of the plugin for log identification
33
- * @returns RollupLogger instance
34
- * @example
35
- * ```typescript
36
- * // In a Rollup plugin
37
- * const logger = createRollupLogger(this, "my-plugin");
38
- *
39
- * logger.info({ message: "Processing file", file: "example.js" });
40
- * // Logs: { message: "Processing file", file: "example.js", plugin: "my-plugin" }
41
- * ```
42
- */
43
- export declare const createRollupLogger: (context: {
44
- debug: (log: {
45
- [key: string]: unknown;
46
- message: string;
47
- }) => void;
48
- error: (log: {
49
- [key: string]: unknown;
50
- message: string;
51
- }) => void;
52
- info: (log: {
53
- [key: string]: unknown;
54
- message: string;
55
- }) => void;
56
- warn: (log: {
57
- [key: string]: unknown;
58
- message: string;
59
- }) => void;
60
- }, pluginName: string) => RollupLogger;
@@ -1,3 +0,0 @@
1
- import type { RollupError } from "rollup";
2
- declare const enhanceRollupError: (error: RollupError) => void;
3
- export default enhanceRollupError;
@@ -1,55 +0,0 @@
1
- import type { RollupLogger } from "./create-rollup-logger.d.ts";
2
- /**
3
- * A file-based cache implementation with memory caching for improved performance.
4
- * Provides methods to store, retrieve, and check the existence of cached data.
5
- */
6
- declare class FileCache {
7
- #private;
8
- /**
9
- * Creates a new FileCache instance.
10
- * @param cwd The current working directory
11
- * @param cachePath The path to the cache directory, can be undefined
12
- * @param hashKey A hash key for cache organization
13
- * @param logger Logger instance for debug messages
14
- */
15
- constructor(cwd: string, cachePath: string | undefined, hashKey: string, logger: RollupLogger);
16
- /**
17
- * Sets whether the cache is enabled.
18
- * @param value True to enable cache, false to disable
19
- */
20
- set isEnabled(value: boolean);
21
- /**
22
- * Gets whether the cache is currently enabled.
23
- * @returns True if cache is enabled, false otherwise
24
- */
25
- get isEnabled(): boolean;
26
- /**
27
- * Checks if a cached file exists.
28
- * @param name The cache key name
29
- * @param subDirectory Optional subdirectory within the cache
30
- * @returns True if the cached file exists, false otherwise
31
- */
32
- has(name: string, subDirectory?: string): boolean;
33
- /**
34
- * Retrieves cached data.
35
- * @param name The cache key name
36
- * @param subDirectory Optional subdirectory within the cache
37
- * @returns The cached data or undefined if not found
38
- */
39
- get<R>(name: string, subDirectory?: string): R | undefined;
40
- /**
41
- * Stores data in the cache.
42
- * @param name The cache key name
43
- * @param data The data to cache
44
- * @param subDirectory Optional subdirectory within the cache
45
- */
46
- set(name: string, data: ArrayBuffer | ArrayBufferView | boolean | number | object | string | null | undefined, subDirectory?: string): void;
47
- /**
48
- * Generates the file path for a cache entry.
49
- * @param name The cache key name
50
- * @param subDirectory Optional subdirectory within the cache
51
- * @returns The complete file path for the cache entry
52
- */
53
- private getFilePath;
54
- }
55
- export default FileCache;
@@ -1,9 +0,0 @@
1
- import type { PreRenderedChunk } from "rollup";
2
- /**
3
- * Generates the appropriate filename for a Rollup chunk based on its type.
4
- * @param chunk The pre-rendered chunk information from Rollup
5
- * @param extension The file extension to use for the chunk
6
- * @returns The generated filename pattern for the chunk
7
- */
8
- declare const getChunkFilename: (chunk: PreRenderedChunk, extension: string) => string;
9
- export default getChunkFilename;
@@ -1,9 +0,0 @@
1
- import type { PreRenderedAsset } from "rollup";
2
- /**
3
- * Generates appropriate file names for entry files, handling special cases for node_modules.
4
- * @param chunkInfo The pre-rendered asset information from Rollup
5
- * @param extension The file extension to use
6
- * @returns The generated filename pattern for the entry file
7
- */
8
- declare const getEntryFileNames: (chunkInfo: PreRenderedAsset, extension: string) => string;
9
- export default getEntryFileNames;
@@ -1,49 +0,0 @@
1
- import type { BuildContext, Format } from "../index.d.ts";
2
- /**
3
- * Options interface for determining file extensions.
4
- */
5
- export interface FileExtensionOptions {
6
- /** Declaration file generation mode */
7
- declaration?: boolean | "compatible" | "node16" | undefined;
8
- /** Whether to emit CommonJS format */
9
- emitCJS?: boolean;
10
- /** Whether to emit ESM format */
11
- emitESM?: boolean;
12
- /** Node.js 10 compatibility options */
13
- node10Compatibility?: {
14
- typeScriptVersion?: string;
15
- writeToPackageJson?: boolean;
16
- } | false;
17
- /** Map of format to file extension */
18
- outputExtensionMap?: Record<Format, string>;
19
- }
20
- /**
21
- * Determines the appropriate output extension for JavaScript files, based on build configuration.
22
- * Returns '.js' when:
23
- * - Only ESM or CJS is emitted (single format)
24
- * - No outputExtensionMap is configured
25
- * - Declaration is not in compatible mode OR node10Compatibility is false
26
- *
27
- * Returns '.cjs'/'.mjs' when:
28
- * - Both ESM and CJS are emitted (dual format)
29
- * - Declaration is in compatible mode (and node10Compatibility is not false)
30
- * - outputExtensionMap is configured
31
- * @param context Build context
32
- * @param format Target format ('esm' or 'cjs')
33
- * @returns File extension string
34
- */
35
- export declare const getOutputExtension: <T extends FileExtensionOptions>(context: BuildContext<T>, format: Format) => string;
36
- /**
37
- * Determines the appropriate declaration file extension based on build configuration.
38
- *
39
- * Returns '.d.ts' when:
40
- * - Only ESM or CJS is emitted (not both)
41
- * - No outputExtensionMap is configured
42
- * - Node.js 10 compatibility is disabled
43
- *
44
- * Otherwise returns traditional extensions ('.d.mts' for ESM, '.d.cts' for CJS).
45
- * @param context Build context
46
- * @param format Target format ('esm' or 'cjs')
47
- * @returns Declaration file extension string
48
- */
49
- export declare const getDtsExtension: <T extends FileExtensionOptions>(context: BuildContext<T>, format: Format) => string;
@@ -1,7 +0,0 @@
1
- /**
2
- * Generates a SHA-256 hash of the provided data.
3
- * @param data The data to hash (buffer or string)
4
- * @returns The hexadecimal representation of the SHA-256 hash
5
- */
6
- declare const getHash: (data: NodeJS.ArrayBufferView | string) => string;
7
- export default getHash;
@@ -1,7 +0,0 @@
1
- /**
2
- * Extracts the package name from a module path.
3
- * @param id The module path or identifier to extract the package name from
4
- * @returns The extracted package name
5
- */
6
- declare const getPackageName: (id?: string) => string;
7
- export default getPackageName;
@@ -1,8 +0,0 @@
1
- /**
2
- * Extracts all matches from a string using the provided regular expression.
3
- * @param regex The regular expression to use for matching
4
- * @param source The source string to search within
5
- * @returns An array of all matched strings, filtered to remove empty matches
6
- */
7
- declare const getRegexMatches: (regex: RegExp, source: string) => string[];
8
- export default getRegexMatches;
@@ -1,17 +0,0 @@
1
- type CacheKeyResolver = string | ((...arguments_: any[]) => string);
2
- /**
3
- * Creates a memoized version of a function that caches results based on input arguments.
4
- * @param function_ The function to memoize
5
- * @param cacheKey Optional cache key resolver (string or function)
6
- * @param cacheArgument Optional existing cache map to use
7
- * @returns The memoized function
8
- */
9
- export declare const memoize: <T extends (...arguments_: any[]) => any>(function_: T, cacheKey?: CacheKeyResolver, // if you need specify a cache key
10
- cacheArgument?: Map<string, ReturnType<T>>) => T;
11
- /**
12
- * Creates a function that returns memoized versions of the input function with shared cache.
13
- * @param function_ The function to create memoized versions of
14
- * @returns A function that returns memoized versions with optional cache key
15
- */
16
- export declare const memoizeByKey: <T extends (...arguments_: any[]) => any>(function_: T) => (cacheKey?: CacheKeyResolver) => T;
17
- export {};
@@ -1,9 +0,0 @@
1
- /**
2
- * Replaces content within markers in a string.
3
- * @param content The content to modify
4
- * @param marker The marker string to find within the content
5
- * @param replacement The replacement content to insert between markers
6
- * @returns The modified content or undefined if marker not found
7
- */
8
- declare const replaceContentWithinMarker: (content: string, marker: string, replacement: string) => string | undefined;
9
- export default replaceContentWithinMarker;
@@ -1,13 +0,0 @@
1
- import type { Plugin } from "rollup";
2
- /**
3
- * Sorts user plugins into pre, normal, and post execution order based on their enforcement settings.
4
- * @param plugins Array of plugins to sort, can be undefined
5
- * @param type The build type to filter plugins for ("build" or "dts")
6
- * @returns A tuple containing [prePlugins, normalPlugins, postPlugins] arrays
7
- */
8
- declare const sortUserPlugins: <T extends {
9
- enforce?: "pre" | "post";
10
- plugin: Plugin;
11
- type?: string;
12
- }>(plugins: T[] | undefined, type: "build" | "dts") => [Plugin[], Plugin[], Plugin[]];
13
- export default sortUserPlugins;
@@ -1,12 +0,0 @@
1
- /**
2
- * Converts SVG to a tiny, optimized data URI for minimal size.
3
- * @param svgString The SVG string to optimize
4
- * @returns Optimized SVG data URI with charset specification
5
- */
6
- export declare const svgToTinyDataUri: (svgString: string) => string;
7
- /**
8
- * Converts SVG to a CSS-optimized data URI for better CSS compatibility.
9
- * @param svgString The SVG string to optimize
10
- * @returns CSS-optimized SVG data URI with charset specification
11
- */
12
- export declare const svgToCssDataUri: (svgString: string) => string;
@@ -1,7 +0,0 @@
1
- /**
2
- * Encodes an SVG buffer to a base64 string after cleaning and optimizing the content.
3
- * @param buffer The SVG buffer to encode
4
- * @returns The base64-encoded SVG string
5
- */
6
- declare const svgEncoder: (buffer: Buffer) => string;
7
- export default svgEncoder;
@@ -1,10 +0,0 @@
1
- interface WarningContext {
2
- warnings: Set<string>;
3
- }
4
- /**
5
- * Adds a warning message to the context if it hasn't been added before.
6
- * @param context The warning context containing a warnings set
7
- * @param message The warning message to add
8
- */
9
- declare const warn: (context: WarningContext, message: string) => void;
10
- export default warn;