@visulima/packem-rollup 1.0.0-alpha.26 → 1.0.0-alpha.28
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 +28 -0
- package/LICENSE.md +228 -183
- package/dist/index.d.ts +24 -58
- package/dist/plugins/cache-plugin.d.ts +11 -0
- package/dist/plugins/chunk-splitter/gather.d.ts +8 -0
- package/dist/plugins/chunk-splitter/index.d.ts +6 -0
- package/dist/plugins/chunk-splitter/parse/index.d.ts +4 -0
- package/dist/plugins/chunk-splitter/parse/types.d.ts +24 -0
- package/dist/plugins/cjs-interop.d.ts +3 -7
- package/dist/plugins/copy.d.ts +12 -7
- package/dist/plugins/data-uri.d.ts +21 -8
- package/dist/plugins/debarrel.d.ts +4 -8
- package/dist/{packem_shared/browserslist-to-esbuild-DY9HwYtp.d.ts → plugins/esbuild/browserslist-to-esbuild.d.ts} +1 -2
- package/dist/plugins/esbuild/esbuild-plugin.d.ts +3 -0
- package/dist/plugins/esbuild/index.d.ts +3 -42
- package/dist/plugins/esbuild/types.d.ts +39 -0
- package/dist/plugins/esbuild/utils/get-render-chunk.d.ts +14 -0
- package/dist/plugins/esbuild/utils/optimize-deps.d.ts +3 -0
- package/dist/plugins/esbuild/utils/warn.d.ts +4 -0
- package/dist/plugins/esm-shim-cjs-syntax.d.ts +6 -10
- package/dist/plugins/fix-dts-default-cjs-exports.d.ts +24 -7
- package/dist/plugins/fix-dynamic-import-extension.d.ts +3 -0
- package/dist/plugins/isolated-declarations/index.d.ts +5 -10
- package/dist/plugins/isolated-declarations/index.js +2 -2
- package/dist/plugins/isolated-declarations/utils/extend-string.d.ts +2 -0
- package/dist/plugins/isolated-declarations/utils/fix-dts-default-cjs-exports.d.ts +35 -0
- package/dist/plugins/isolated-declarations/utils/lowest-common-ancestor.d.ts +2 -0
- package/dist/plugins/isolated-declarations/utils/split-tsconfig-path-key.d.ts +2 -0
- package/dist/plugins/json.d.ts +4 -7
- package/dist/plugins/json.js +1 -1
- package/dist/plugins/jsx-remove-attributes.d.ts +3 -7
- package/dist/plugins/jsx-remove-attributes.js +1 -1
- package/dist/plugins/license.d.ts +3 -7
- package/dist/plugins/metafile.d.ts +3 -0
- package/dist/plugins/minify-html-literals/index.d.ts +36 -91
- package/dist/plugins/minify-html-literals/index.js +2 -2
- package/dist/plugins/minify-html-literals/lib/minify-html-literals.d.ts +200 -0
- package/dist/plugins/minify-html-literals/lib/models.d.ts +25 -0
- package/dist/plugins/minify-html-literals/lib/parse-literals.d.ts +13 -0
- package/dist/plugins/minify-html-literals/lib/strategy.d.ts +69 -0
- package/dist/plugins/minify-html-literals/lib/typescript.d.ts +23 -0
- package/dist/plugins/native-modules-plugin.d.ts +12 -7
- package/dist/plugins/native-modules-plugin.js +1 -1
- package/dist/plugins/oxc/index.d.ts +4 -45
- package/dist/plugins/oxc/isolated-declarations-oxc-transformer.d.ts +4 -0
- package/dist/plugins/oxc/oxc-resolve-plugin.d.ts +4 -0
- package/dist/plugins/oxc/oxc-transformer-plugin.d.ts +3 -0
- package/dist/plugins/oxc/types.d.ts +16 -0
- package/dist/plugins/preserve-directives.d.ts +11 -8
- package/dist/plugins/raw.d.ts +4 -8
- package/dist/plugins/require-cjs-transformer.d.ts +35 -9
- package/dist/plugins/resolve-file-url.d.ts +3 -0
- package/dist/plugins/shebang.d.ts +6 -10
- package/dist/plugins/source-maps.d.ts +4 -8
- package/dist/plugins/sucrase/index.d.ts +8 -36
- package/dist/plugins/swc/index.d.ts +3 -43
- package/dist/plugins/swc/isolated-declarations-swc-transformer.d.ts +3 -0
- package/dist/plugins/swc/swc-plugin.d.ts +3 -0
- package/dist/plugins/swc/types.d.ts +6 -0
- package/dist/plugins/typescript/index.d.ts +8 -46
- package/dist/plugins/typescript/isolated-declarations-typescript-transformer.d.ts +4 -0
- package/dist/plugins/typescript/patch-typescript-types.d.ts +13 -0
- package/dist/plugins/typescript/resolve-tsconfig-paths-plugin.d.ts +11 -0
- package/dist/plugins/typescript/resolve-tsconfig-root-dirs.d.ts +24 -0
- package/dist/plugins/typescript/resolve-typescript-mjs-cjs.d.ts +10 -0
- package/dist/plugins/url.d.ts +63 -8
- package/dist/types.d.ts +133 -0
- package/dist/utils/chunks/create-split-chunks.d.ts +11 -0
- package/dist/utils/chunks/get-custom-module-layer.d.ts +2 -0
- package/dist/utils/chunks/get-module-layer.d.ts +10 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/is-pure-cjs.d.ts +9 -0
- package/package.json +10 -10
- package/dist/packem_shared/types-BiZanzz1.d.ts +0 -4226
package/dist/index.d.ts
CHANGED
|
@@ -1,58 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
|
|
6
|
-
export {
|
|
7
|
-
export {
|
|
8
|
-
export {
|
|
9
|
-
export {
|
|
10
|
-
export {
|
|
11
|
-
export {
|
|
12
|
-
export {
|
|
13
|
-
export {
|
|
14
|
-
export {
|
|
15
|
-
export {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
import '@visulima/package';
|
|
26
|
-
import './plugins/isolated-declarations/index.js';
|
|
27
|
-
import './plugins/jsx-remove-attributes.js';
|
|
28
|
-
import './plugins/license.js';
|
|
29
|
-
import './plugins/minify-html-literals/index.js';
|
|
30
|
-
import 'magic-string';
|
|
31
|
-
import 'html-minifier-next';
|
|
32
|
-
import './plugins/native-modules-plugin.js';
|
|
33
|
-
import 'oxc-resolver';
|
|
34
|
-
import 'oxc-transform';
|
|
35
|
-
import './plugins/raw.js';
|
|
36
|
-
import './plugins/require-cjs-transformer.js';
|
|
37
|
-
import './plugins/shebang.js';
|
|
38
|
-
import './plugins/source-maps.js';
|
|
39
|
-
import 'sucrase';
|
|
40
|
-
import './plugins/url.js';
|
|
41
|
-
|
|
42
|
-
declare const cachePlugin: (plugin: Plugin, cache: FileCache, subDirectory?: string) => Plugin;
|
|
43
|
-
|
|
44
|
-
declare const chunkSplitter: () => Plugin;
|
|
45
|
-
|
|
46
|
-
declare const fixDynamicImportExtension: () => Plugin;
|
|
47
|
-
|
|
48
|
-
declare const metafilePlugin: () => Plugin;
|
|
49
|
-
|
|
50
|
-
declare const resolveFileUrl: () => Plugin;
|
|
51
|
-
|
|
52
|
-
declare const createSplitChunks: (dependencyGraphMap: Map<string, Set<[string, string]>>, entryFiles: (BuildContextBuildAssetAndChunk | BuildContextBuildEntry)[]) => GetManualChunk;
|
|
53
|
-
|
|
54
|
-
declare const getCustomModuleLayer: (moduleId: string) => string | undefined;
|
|
55
|
-
|
|
56
|
-
declare const getModuleLayer: (moduleMeta: CustomPluginOptions) => any;
|
|
57
|
-
|
|
58
|
-
export { cachePlugin as cachingPlugin, chunkSplitter, createSplitChunks, fixDynamicImportExtension, getCustomModuleLayer, getModuleLayer, metafilePlugin, resolveFileUrl as resolveFileUrlPlugin };
|
|
1
|
+
export { default as cachingPlugin } from "./plugins/cache-plugin.d.ts";
|
|
2
|
+
export { default as chunkSplitter } from "./plugins/chunk-splitter/index.d.ts";
|
|
3
|
+
export { default as browserslistToEsbuild } from "./plugins/esbuild/browserslist-to-esbuild.d.ts";
|
|
4
|
+
export { default as fixDynamicImportExtension } from "./plugins/fix-dynamic-import-extension.d.ts";
|
|
5
|
+
export { default as metafilePlugin } from "./plugins/metafile.d.ts";
|
|
6
|
+
export { default as resolveFileUrlPlugin } from "./plugins/resolve-file-url.d.ts";
|
|
7
|
+
export type { ExtendedRollupNodeResolveOptions, IsolatedDeclarationsResult, IsolatedDeclarationsTransformer, PackemRollupOptions, RollupPlugins, TransformerFn, TransformerName } from "./types.d.ts";
|
|
8
|
+
export { default as createSplitChunks } from "./utils/chunks/create-split-chunks.d.ts";
|
|
9
|
+
export { default as getCustomModuleLayer } from "./utils/chunks/get-custom-module-layer.d.ts";
|
|
10
|
+
export { default as getModuleLayer } from "./utils/chunks/get-module-layer.d.ts";
|
|
11
|
+
export type { Alias, ResolverObject as AliasResolverObject, ResolvedAlias, RollupAliasOptions } from "@rollup/plugin-alias";
|
|
12
|
+
export { default as alias } from "@rollup/plugin-alias";
|
|
13
|
+
export type { RollupCommonJSOptions } from "@rollup/plugin-commonjs";
|
|
14
|
+
export { default as commonjs } from "@rollup/plugin-commonjs";
|
|
15
|
+
export type { RollupDynamicImportVariablesOptions } from "@rollup/plugin-dynamic-import-vars";
|
|
16
|
+
export { default as dynamicImportVars } from "@rollup/plugin-dynamic-import-vars";
|
|
17
|
+
export { default as inject, type RollupInjectOptions } from "@rollup/plugin-inject";
|
|
18
|
+
export { default as nodeResolve, type RollupNodeResolveOptions } from "@rollup/plugin-node-resolve";
|
|
19
|
+
export { default as replace, type RollupReplaceOptions } from "@rollup/plugin-replace";
|
|
20
|
+
export { type RollupWasmOptions, default as wasm } from "@rollup/plugin-wasm";
|
|
21
|
+
export { default as polyfillNode, type NodePolyfillsOptions as RollupNodePolyfillsOptions } from "rollup-plugin-polyfill-node";
|
|
22
|
+
export { PluginPure, type PureAnnotationsOptions as RollupPureAnnotationsOptions } from "rollup-plugin-pure";
|
|
23
|
+
export type { PluginVisualizerOptions as RollupPluginVisualizerOptions } from "rollup-plugin-visualizer";
|
|
24
|
+
export { default as visualizer } from "rollup-plugin-visualizer";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { FileCache } from "@visulima/packem-share/utils";
|
|
2
|
+
import type { Plugin } from "rollup";
|
|
3
|
+
/**
|
|
4
|
+
* Wrap a Rollup plugin to add caching to various hooks.
|
|
5
|
+
* @param plugin
|
|
6
|
+
* @param cache
|
|
7
|
+
* @param subDirectory
|
|
8
|
+
* @returns
|
|
9
|
+
*/
|
|
10
|
+
declare const cachePlugin: (plugin: Plugin, cache: FileCache, subDirectory?: string) => Plugin;
|
|
11
|
+
export default cachePlugin;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ModuleInfo, PluginContext } from "rollup";
|
|
2
|
+
interface ExportInfo {
|
|
3
|
+
exportedName: string;
|
|
4
|
+
id: string;
|
|
5
|
+
sourceName: string;
|
|
6
|
+
}
|
|
7
|
+
declare const gatherExports: (context: PluginContext, module_: ModuleInfo) => AsyncGenerator<ExportInfo>;
|
|
8
|
+
export default gatherExports;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export interface BarrelReExport {
|
|
2
|
+
from: "other";
|
|
3
|
+
source: string;
|
|
4
|
+
type: "barrel";
|
|
5
|
+
}
|
|
6
|
+
export interface ExportBinding {
|
|
7
|
+
exportedName: string;
|
|
8
|
+
importedName: string;
|
|
9
|
+
}
|
|
10
|
+
export interface NamedReExport {
|
|
11
|
+
bindings: ExportBinding[];
|
|
12
|
+
from: "other";
|
|
13
|
+
source: string;
|
|
14
|
+
type: "named";
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Modified copy of https://github.com/cprecioso/rollup-plugin-chunk-per-export/blob/main/src/parse/types.ts
|
|
18
|
+
*/
|
|
19
|
+
export interface NamedSelfExport {
|
|
20
|
+
exportedName: string;
|
|
21
|
+
from: "self";
|
|
22
|
+
type: "named";
|
|
23
|
+
}
|
|
24
|
+
export type ParsedExportInfo = BarrelReExport | NamedReExport | NamedSelfExport;
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import { Plugin } from
|
|
2
|
-
|
|
3
|
-
interface CJSInteropOptions {
|
|
1
|
+
import type { Plugin } from "rollup";
|
|
2
|
+
export interface CJSInteropOptions {
|
|
4
3
|
addDefaultProperty?: boolean;
|
|
5
4
|
}
|
|
6
|
-
declare const cjsInteropPlugin: ({ addDefaultProperty, logger, }: CJSInteropOptions & {
|
|
5
|
+
export declare const cjsInteropPlugin: ({ addDefaultProperty, logger, }: CJSInteropOptions & {
|
|
7
6
|
logger: Console;
|
|
8
7
|
}) => Plugin;
|
|
9
|
-
|
|
10
|
-
export { cjsInteropPlugin };
|
|
11
|
-
export type { CJSInteropOptions };
|
package/dist/plugins/copy.d.ts
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
|
-
import { Plugin } from
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import type { Plugin } from "rollup";
|
|
2
|
+
export type CopyPluginOptions = {
|
|
3
|
+
/**
|
|
4
|
+
* Copy items once. Useful in watch mode.
|
|
5
|
+
* @default false
|
|
6
|
+
*/
|
|
4
7
|
copyOnce?: boolean;
|
|
5
8
|
exactFileNames?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Remove the directory structure of copied files.
|
|
11
|
+
* @default true
|
|
12
|
+
*/
|
|
6
13
|
flatten?: boolean;
|
|
7
14
|
targets: MultipleTargetsDesc;
|
|
8
15
|
};
|
|
@@ -12,7 +19,5 @@ type SingleTargetDesc = {
|
|
|
12
19
|
exclude?: string[] | string;
|
|
13
20
|
src: string[] | string;
|
|
14
21
|
};
|
|
15
|
-
declare const copyPlugin: (options: CopyPluginOptions, logger: Console) => Plugin;
|
|
16
|
-
|
|
17
|
-
export { copyPlugin };
|
|
18
|
-
export type { CopyPluginOptions };
|
|
22
|
+
export declare const copyPlugin: (options: CopyPluginOptions, logger: Console) => Plugin;
|
|
23
|
+
export {};
|
|
@@ -1,12 +1,25 @@
|
|
|
1
|
-
import { FilterPattern } from
|
|
2
|
-
import { Plugin } from
|
|
3
|
-
|
|
4
|
-
type DataUriPluginOptions = {
|
|
1
|
+
import type { FilterPattern } from "@rollup/pluginutils";
|
|
2
|
+
import type { Plugin } from "rollup";
|
|
3
|
+
export type DataUriPluginOptions = {
|
|
5
4
|
exclude?: FilterPattern;
|
|
6
5
|
include?: FilterPattern;
|
|
6
|
+
/** Encode spaces for use in srcset attribute */
|
|
7
7
|
srcset?: boolean;
|
|
8
8
|
};
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Data URI plugin that converts files to data URIs for inline embedding.
|
|
11
|
+
*
|
|
12
|
+
* Query parameters:
|
|
13
|
+
* - ?data-uri - Basic data URI conversion
|
|
14
|
+
* - ?data-uri and encoding=css - Use CSS-optimized SVG encoding
|
|
15
|
+
* - ?data-uri and encoding=tiny - Use tiny SVG encoding (default)
|
|
16
|
+
* - ?data-uri and srcset - Encode spaces as %20 for srcset compatibility
|
|
17
|
+
*
|
|
18
|
+
* Examples:
|
|
19
|
+
* - ./icon.svg?data-uri - Tiny SVG encoding
|
|
20
|
+
* - ./icon.svg?data-uri and encoding=css - CSS-optimized SVG encoding
|
|
21
|
+
* - ./icon.svg?data-uri and srcset - Tiny SVG with srcset compatibility
|
|
22
|
+
* - ./icon.svg?data-uri and encoding=css and srcset - CSS encoding with srcset compatibility
|
|
23
|
+
*/
|
|
24
|
+
export declare const dataUriPlugin: (options?: DataUriPluginOptions) => Plugin;
|
|
25
|
+
export default dataUriPlugin;
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import { FilterPattern } from
|
|
2
|
-
import { Plugin } from
|
|
3
|
-
|
|
4
|
-
interface DebarrelPluginOptions {
|
|
1
|
+
import type { FilterPattern } from "@rollup/pluginutils";
|
|
2
|
+
import type { Plugin } from "rollup";
|
|
3
|
+
export interface DebarrelPluginOptions {
|
|
5
4
|
include?: FilterPattern;
|
|
6
5
|
possibleBarrelFiles?: (RegExp | string)[];
|
|
7
6
|
}
|
|
8
|
-
declare const debarrelPlugin: (options: DebarrelPluginOptions, logger: Console) => Plugin;
|
|
9
|
-
|
|
10
|
-
export { debarrelPlugin };
|
|
11
|
-
export type { DebarrelPluginOptions };
|
|
7
|
+
export declare const debarrelPlugin: (options: DebarrelPluginOptions, logger: Console) => Plugin;
|
|
@@ -1,42 +1,3 @@
|
|
|
1
|
-
export {
|
|
2
|
-
|
|
3
|
-
export
|
|
4
|
-
import '@rollup/plugin-alias';
|
|
5
|
-
import '@rollup/plugin-commonjs';
|
|
6
|
-
import '@rollup/plugin-json';
|
|
7
|
-
import '@rollup/plugin-node-resolve';
|
|
8
|
-
import '@rollup/plugin-replace';
|
|
9
|
-
import '@rollup/plugin-wasm';
|
|
10
|
-
import '@rollup/pluginutils';
|
|
11
|
-
import 'rollup';
|
|
12
|
-
import 'rollup-plugin-dts';
|
|
13
|
-
import 'rollup-plugin-polyfill-node';
|
|
14
|
-
import 'rollup-plugin-pure';
|
|
15
|
-
import 'rollup-plugin-visualizer';
|
|
16
|
-
import '../cjs-interop.js';
|
|
17
|
-
import '../copy.js';
|
|
18
|
-
import '../data-uri.js';
|
|
19
|
-
import '../debarrel.js';
|
|
20
|
-
import 'esbuild';
|
|
21
|
-
import '../esm-shim-cjs-syntax.js';
|
|
22
|
-
import '@visulima/package';
|
|
23
|
-
import '../isolated-declarations/index.js';
|
|
24
|
-
import '@visulima/packem-share/types';
|
|
25
|
-
import '../jsx-remove-attributes.js';
|
|
26
|
-
import '../license.js';
|
|
27
|
-
import '../minify-html-literals/index.js';
|
|
28
|
-
import 'magic-string';
|
|
29
|
-
import 'html-minifier-next';
|
|
30
|
-
import '../native-modules-plugin.js';
|
|
31
|
-
import 'oxc-resolver';
|
|
32
|
-
import 'oxc-transform';
|
|
33
|
-
import '../raw.js';
|
|
34
|
-
import '../require-cjs-transformer.js';
|
|
35
|
-
import '../shebang.js';
|
|
36
|
-
import '../source-maps.js';
|
|
37
|
-
import 'sucrase';
|
|
38
|
-
import '../url.js';
|
|
39
|
-
|
|
40
|
-
declare const _default: TransformerFn;
|
|
41
|
-
|
|
42
|
-
export { _default as esbuildPlugin };
|
|
1
|
+
export { default as browserslistToEsbuild } from "./browserslist-to-esbuild.d.ts";
|
|
2
|
+
export { default as esbuildPlugin } from "./esbuild-plugin.d.ts";
|
|
3
|
+
export type * from "./types.d.ts";
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Modified copy of https://github.com/egoist/rollup-plugin-esbuild/blob/dev/src/index.ts
|
|
3
|
+
*
|
|
4
|
+
* MIT License
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) 2020 EGOIST
|
|
7
|
+
*/
|
|
8
|
+
import type { FilterPattern } from "@rollup/pluginutils";
|
|
9
|
+
import type { BuildOptions as EsbuildOptions, Loader, TransformOptions } from "esbuild";
|
|
10
|
+
type MarkOptional<Type, Keys extends keyof Type> = Type extends Type ? Omit<Type, Keys> & Partial<Pick<Type, Keys>> : never;
|
|
11
|
+
export type EsbuildPluginConfig = Options & {
|
|
12
|
+
logger: Console;
|
|
13
|
+
};
|
|
14
|
+
export type Optimized = Map<string, {
|
|
15
|
+
file: string;
|
|
16
|
+
}>;
|
|
17
|
+
export type OptimizeDepsOptions = {
|
|
18
|
+
cwd: string;
|
|
19
|
+
esbuildOptions?: EsbuildOptions;
|
|
20
|
+
exclude?: string[];
|
|
21
|
+
include: string[];
|
|
22
|
+
sourceMap: boolean;
|
|
23
|
+
};
|
|
24
|
+
export type OptimizeDepsResult = {
|
|
25
|
+
cacheDir: string;
|
|
26
|
+
optimized: Optimized;
|
|
27
|
+
};
|
|
28
|
+
export type Options = Omit<TransformOptions, "loader" | "sourcemap"> & {
|
|
29
|
+
exclude?: FilterPattern;
|
|
30
|
+
include?: FilterPattern;
|
|
31
|
+
/**
|
|
32
|
+
* Map extension to esbuild loader
|
|
33
|
+
* Note that each entry (the extension) needs to start with a dot
|
|
34
|
+
*/
|
|
35
|
+
loaders?: Record<string, Loader | false>;
|
|
36
|
+
optimizeDeps?: MarkOptional<OptimizeDepsOptions, "cwd" | "sourceMap">;
|
|
37
|
+
sourceMap?: boolean;
|
|
38
|
+
};
|
|
39
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Modified copy of https://github.com/egoist/rollup-plugin-esbuild/blob/dev/src/minify.ts
|
|
3
|
+
*
|
|
4
|
+
* MIT License
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) 2020 EGOIST
|
|
7
|
+
*/
|
|
8
|
+
import type { TransformOptions } from "esbuild";
|
|
9
|
+
import type { Plugin } from "rollup";
|
|
10
|
+
type Options = Omit<TransformOptions, "sourcemap"> & {
|
|
11
|
+
sourceMap?: boolean;
|
|
12
|
+
};
|
|
13
|
+
declare const getRenderChunk: ({ sourceMap, ...options }: Options) => Plugin["renderChunk"];
|
|
14
|
+
export default getRenderChunk;
|
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
import { FilterPattern } from
|
|
2
|
-
import { PackageJson } from
|
|
3
|
-
import { Plugin } from
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
interface EsmShimCjsSyntaxOptions {
|
|
1
|
+
import type { FilterPattern } from "@rollup/pluginutils";
|
|
2
|
+
import type { PackageJson } from "@visulima/package";
|
|
3
|
+
import type { Plugin } from "rollup";
|
|
4
|
+
export declare const GLOBAL_REQUIRE_REGEX: RegExp;
|
|
5
|
+
export interface EsmShimCjsSyntaxOptions {
|
|
7
6
|
exclude?: FilterPattern;
|
|
8
7
|
include?: FilterPattern;
|
|
9
8
|
}
|
|
10
|
-
declare const esmShimCjsSyntaxPlugin: (packageJson: PackageJson, options: EsmShimCjsSyntaxOptions) => Plugin;
|
|
11
|
-
|
|
12
|
-
export { GLOBAL_REQUIRE_REGEX, esmShimCjsSyntaxPlugin };
|
|
13
|
-
export type { EsmShimCjsSyntaxOptions };
|
|
9
|
+
export declare const esmShimCjsSyntaxPlugin: (packageJson: PackageJson, options: EsmShimCjsSyntaxOptions) => Plugin;
|
|
@@ -1,9 +1,26 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import type { Plugin, RenderedChunk } from "rollup";
|
|
2
|
+
export type FixDtsDefaultCjsExportsPluginOptions = {
|
|
3
|
+
/**
|
|
4
|
+
* A function to determine if a chunk should be processed by this plugin.
|
|
5
|
+
* Defaults to processing .d.ts, .d.cts, or .d.mts files that are entry chunks and have exports.
|
|
6
|
+
* @param info The Rollup RenderedChunk object.
|
|
7
|
+
* @returns True if the chunk should be processed, false otherwise.
|
|
8
|
+
*/
|
|
4
9
|
matcher?: (info: RenderedChunk) => boolean;
|
|
5
10
|
};
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export
|
|
9
|
-
|
|
11
|
+
/**
|
|
12
|
+
* A Rollup plugin to fix default exports in TypeScript declaration files (.d.ts)
|
|
13
|
+
* to ensure they are CJS compatible (using `export = ...` and namespaces).
|
|
14
|
+
* This is particularly useful for libraries that want to support both ESM and CJS consumers correctly.
|
|
15
|
+
*
|
|
16
|
+
* The plugin handles various scenarios:
|
|
17
|
+
* - `export { MyClass as default };`
|
|
18
|
+
* - `export { default } from 'some-module';`
|
|
19
|
+
* - `export { name as default } from 'some-module';`
|
|
20
|
+
* - `export default from 'some-module';` (an mlly quirk)
|
|
21
|
+
* - Combinations with named exports (value and type exports), creating namespaces where appropriate.
|
|
22
|
+
* - Pure type-only exports like `export { type Foo, type Bar };`
|
|
23
|
+
* @param options Optional configuration for the plugin.
|
|
24
|
+
* @returns The Rollup plugin object.
|
|
25
|
+
*/
|
|
26
|
+
export declare const fixDtsDefaultCjsExportsPlugin: (options?: FixDtsDefaultCjsExportsPluginOptions) => Plugin;
|
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
import { FilterPattern } from
|
|
2
|
-
import { BuildContext } from
|
|
3
|
-
import { Plugin } from
|
|
4
|
-
|
|
5
|
-
type IsolatedDeclarationsOptions = {
|
|
1
|
+
import type { FilterPattern } from "@rollup/pluginutils";
|
|
2
|
+
import type { BuildContext } from "@visulima/packem-share/types";
|
|
3
|
+
import type { Plugin } from "rollup";
|
|
4
|
+
export type IsolatedDeclarationsOptions = {
|
|
6
5
|
exclude?: FilterPattern;
|
|
7
6
|
ignoreErrors?: boolean;
|
|
8
|
-
include?: FilterPattern;
|
|
9
7
|
};
|
|
10
|
-
declare const isolatedDeclarationsPlugin: <T extends Record<string, any>>(sourceDirectory: string, context: BuildContext<T>) => Plugin;
|
|
11
|
-
|
|
12
|
-
export { isolatedDeclarationsPlugin };
|
|
13
|
-
export type { IsolatedDeclarationsOptions };
|
|
8
|
+
export declare const isolatedDeclarationsPlugin: <T extends Record<string, any>>(sourceDirectory: string, context: BuildContext<T>) => Plugin;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var
|
|
1
|
+
var U=Object.defineProperty;var x=(t,e)=>U(t,"name",{value:e,configurable:!0});import{createFilter as X}from"@rollup/pluginutils";import{readFile as W}from"@visulima/fs";import{EXCLUDE_REGEXP as _,ENDING_REGEX as E}from"@visulima/packem-share/constants";import{getDtsExtension as L}from"@visulima/packem-share/utils";import{dirname as S,toNamespacedPath as D,sep as A,extname as J,isAbsolute as q,relative as C,join as k,basename as O}from"@visulima/path";import{parse as z}from"oxc-parser";import{_ as B}from"../../packem_shared/fix-dts-default-cjs-exports-BQc0nwIG.js";var H=Object.defineProperty,Q=x((t,e)=>H(t,"name",{value:e,configurable:!0}),"e");const P=/^([\w-]+):/,K=Q(t=>{if(!t||typeof t!="string")throw new Error("Invalid key: Key must be a non-empty string.");const e=[],c=P.exec(t);c&&(e.push(c[1]),t=t.replace(P,""));const n=t.split("/");for(const p of n)(p.includes("*")||p)&&e.push(p);return e},"splitTsconfigPathKey");var V=Object.defineProperty,Y=x((t,e)=>V(t,"name",{value:e,configurable:!0}),"h");const Z=Y((t,e)=>{const c=t.replace(/^\.\//,""),n=e.replace(/^\.\//,"");if(n.startsWith(c))return t+n.slice(c.length);if(t.endsWith(e))return t;const p=K(t),d=K(e);let l=p.length-1,r=d.length-1;for(;l>=0&&r>=0&&p[l]===d[r];)l--,r--;let a=p.slice(0,l).join("/");const f=d.slice(r).join("/");return(!a.startsWith(".")||a==="")&&(a=`./${a}`),a+(f?`/${f}`:"")},"extendString");var ee=Object.defineProperty,te=x((t,e)=>ee(t,"name",{value:e,configurable:!0}),"s");const re=te((...t)=>{if(t.length===0)return"";if(t.length===1)return S(t[0]);t=t.map(p=>D(p).split(A).join("/"));const[e,...c]=t;let n=e.split("/");for(const p of c){const d=p.split("/",n.length);let l=0;for(const r of d)if(r===n[l])l+=1;else{n=n.slice(0,l);break}n=n.slice(0,l)}return(n.length<=1&&n[0]===""?`/${n[0]}`:n.join("/")).split("/").join(A)},"lowestCommonAncestor");var ie=Object.defineProperty,j=x((t,e)=>ie(t,"name",{value:e,configurable:!0}),"g");const I=j((t,e)=>`${t}
|
|
2
2
|
//# sourceMappingURL=${O(e)}.map
|
|
3
|
-
`,"appendMapUrl"),
|
|
3
|
+
`,"appendMapUrl"),R=j((t,e,c)=>JSON.stringify({file:O(c),mappings:t,names:[],sourceRoot:"",sources:[C(S(c),e)],version:3}),"generateDtsMap"),fe=j((t,e)=>{const c=X(/\.(?:[mc]?ts|[jt]sx?)$/,e.options.rollup.isolatedDeclarations?.exclude||_);let n=Object.create(null);const p=j((r,a)=>{n[r.replace(E,"")]={...a,ext:J(r)}},"addOutput");let d=[];e.tsconfig?.config.compilerOptions&&(d=Object.entries(e.tsconfig.config.compilerOptions.paths??{}).map(([r])=>r.endsWith("*")?new RegExp(`^${r.replace("*","(.*)")}$`):new RegExp(`^${r}$`)));async function l(r,a){if(!c(a))return;e.logger.debug({message:`Processing file: ${a}`,prefix:"packem:isolated-declarations"});let f;try{f=(await z(a,r)).program}catch(s){e.logger.debug({message:s.message,prefix:"packem:isolated-declarations"})}if(f){const s=f.body.filter(i=>(i.type==="ImportDeclaration"||i.type==="ExportAllDeclaration"||i.type==="ExportNamedDeclaration")&&i.source);for await(const i of s){if(O(i.source.value).includes("."))continue;const o=await this.resolve(i.source.value,a);if(!(!o||o.external)&&(o.id.endsWith(".ts")||o.id.endsWith(".cts")||o.id.endsWith(".mts")||o.id.endsWith(".tsx")||o.id.endsWith(".ctsx")||o.id.endsWith(".mtsx"))){const g=o.id.replace(`${t}/`,"");let u=i.source.value;d.some($=>$.test(i.source.value))&&!i.source.value.startsWith(".")&&(u=`./${i.source.value}`),r=r.replaceAll(`from "${i.source.value}"`,`from "${Z(u,g)}"`)}}}const{errors:b,map:w,sourceText:m}=await e.options.isolatedDeclarationTransformer(a,r,e.options.sourcemap,e.tsconfig?.config?.compilerOptions);if(b.length>0){if(e.options.rollup.isolatedDeclarations.ignoreErrors){this.warn(b[0]);return}return this.error(b[0])}if(p(a,{map:w,source:m}),!f)return;const h=f.body.filter(s=>!("source"in s)||!s.source?!1:"importKind"in s&&s.importKind==="type"||"exportKind"in s&&s.exportKind==="type"?!0:s.type==="ImportDeclaration"?s.specifiers&&s.specifiers.every(i=>i.type==="ImportSpecifier"&&i.importKind==="type"):s.type==="ExportNamedDeclaration"&&s.specifiers&&s.specifiers.every(i=>i.exportKind==="type"));for await(const s of h){if(!s.source)continue;const i=await this.resolve(s.source.value,a);if(!i)return;const o=i.id;if(c(o)&&!n[o.replace(E,"")])try{const g=await W(o);await l.call(this,g,o)}catch{}}}return x(l,"N"),j(l,"transform"),{buildStart(){n=Object.create(null)},name:"packem:isolated-declarations",async renderStart(r,{input:a}){const f=re(...Array.isArray(a)?a:Object.values(a));e.logger.debug({message:`Input base:${f}`,prefix:"packem:isolated-declarations"});const b=Array.isArray(a)?a:Object.values(a);for await(const m of b)if(c(m)&&!n[m.replace(E,"")])try{const h=await W(m);await l.call(this,h,m)}catch{}typeof r.entryFileNames=="function"&&(r.entryFileNames=r.entryFileNames({name:r.name}));const w=r.entryFileNames.replace(/\.(.)?[jt]sx?$/,(m,h)=>`.d.${h||""}ts`);for await(let[m,{ext:h,map:s,source:i}]of Object.entries(n)){let o;if(q(m)){if(!m.startsWith(t)){e.logger.debug({message:`Skipping file outside sourceDirectory: ${m}`,prefix:"packem:isolated-declarations"});continue}o=C(t,m)}else o=m.replace(`${t}/`,"");if(o.startsWith("/")&&(o=o.slice(1)),e.options.rollup.cjsInterop&&r.format==="cjs"){const y=B(i,{fileName:o,imports:[]},{warn:this.warn});y&&(i=y.code)}const g=i.includes("from '")?"'":'"',u=o+h;if((e.options.declaration===!0||e.options.declaration==="compatible")&&r.format==="cjs"){e.logger.debug({message:`Emit compatible dts file: ${o}`,prefix:"packem:isolated-declarations"});const y=w.replace("[name]",D(o)).replace(".cts",".ts");let v=i;e.options.sourcemap&&s&&(v=I(v.trim(),y),this.emitFile({fileName:`${y}.map`,originalFileName:u,source:R(s,u,k(r.dir,y)),type:"asset"})),this.emitFile({fileName:y,originalFileName:u,source:v.replaceAll(/(from\s)['|"]((.*)\..+|['|"].*)['|"];?/g,(F,N,M,T)=>`${N+g+(T||M)}.d.ts${g};`),type:"asset"})}e.logger.debug({message:`Emit dts file: ${o}`,prefix:"packem:isolated-declarations"});const $=w.replace("[name]",D(o));e.options.sourcemap&&s&&(i=I(i.trim(),$),this.emitFile({fileName:`${$}.map`,originalFileName:u,source:R(s,u,k(r.dir,$)),type:"asset"}));const G=L(e,r.format==="cjs"?"cjs":"esm");this.emitFile({fileName:$,originalFileName:u,source:i.replaceAll(/(from\s)['|"]((.*)\..+|['|"].*)['|"];?/g,(y,v,F,N)=>`${v+g+(N||F)}.${G}${g};`),type:"asset"})}},transform:l}},"isolatedDeclarationsPlugin");export{fe as isolatedDeclarationsPlugin};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { LoggingFunction, SourceMapInput } from "rollup";
|
|
2
|
+
/**
|
|
3
|
+
* Options for the plugin.
|
|
4
|
+
*/
|
|
5
|
+
type Options = {
|
|
6
|
+
/**
|
|
7
|
+
* Rollup's warning function.
|
|
8
|
+
*/
|
|
9
|
+
warn?: LoggingFunction;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Information about the code being processed.
|
|
13
|
+
*/
|
|
14
|
+
interface CodeInfo {
|
|
15
|
+
/**
|
|
16
|
+
* The name of the file.
|
|
17
|
+
*/
|
|
18
|
+
fileName: string;
|
|
19
|
+
/**
|
|
20
|
+
* A list of import specifiers in the file.
|
|
21
|
+
*/
|
|
22
|
+
imports: string[];
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Main internal function to transform ES module default exports in .d.ts files to be CJS compatible.
|
|
26
|
+
* @param code The code of the chunk.
|
|
27
|
+
* @param info Information about the file (name, imports).
|
|
28
|
+
* @param options Plugin options, including the warning function.
|
|
29
|
+
* @returns An object with the transformed code and a null map, or undefined if no transformation occurs or an error happens.
|
|
30
|
+
*/
|
|
31
|
+
declare const fixDtsDefaultCJSExports: (code: string, info: CodeInfo, options: Options) => {
|
|
32
|
+
code: string;
|
|
33
|
+
map: SourceMapInput | undefined;
|
|
34
|
+
} | undefined;
|
|
35
|
+
export default fixDtsDefaultCJSExports;
|
package/dist/plugins/json.d.ts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import { RollupJsonOptions } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
declare const JsonPlugin: (options: RollupJsonOptions) => Plugin;
|
|
6
|
-
|
|
7
|
-
export { JsonPlugin };
|
|
1
|
+
import type { RollupJsonOptions } from "@rollup/plugin-json";
|
|
2
|
+
import type { Plugin } from "rollup";
|
|
3
|
+
export type { RollupJsonOptions } from "@rollup/plugin-json";
|
|
4
|
+
export declare const JsonPlugin: (options: RollupJsonOptions) => Plugin;
|
package/dist/plugins/json.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var c=Object.defineProperty;var t=(r
|
|
1
|
+
var c=Object.defineProperty;var t=(o,r)=>c(o,"name",{value:r,configurable:!0});import i from"@rollup/plugin-json";var l=Object.defineProperty,d=t((o,r)=>l(o,"name",{value:r,configurable:!0}),"t");const n="export default ",m=d(o=>{const r=i(o);return{...r,name:"packem:json",transform:{filter:{id:/\.json$/},handler(s,a){const e=r.transform?.call(this,s,a);return e&&typeof e!="string"&&"code"in e&&e.code?.startsWith(n)&&(e.code=e.code.replace(n,"module.exports = ")),e}}}},"JsonPlugin");export{m as JsonPlugin};
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import { Plugin } from
|
|
2
|
-
|
|
3
|
-
type JSXRemoveAttributesPlugin = {
|
|
1
|
+
import type { Plugin } from "rollup";
|
|
2
|
+
export type JSXRemoveAttributesPlugin = {
|
|
4
3
|
attributes: string[];
|
|
5
4
|
};
|
|
6
|
-
declare const jsxRemoveAttributes: ({ attributes, logger }: JSXRemoveAttributesPlugin & {
|
|
5
|
+
export declare const jsxRemoveAttributes: ({ attributes, logger }: JSXRemoveAttributesPlugin & {
|
|
7
6
|
logger: Console;
|
|
8
7
|
}) => Plugin;
|
|
9
|
-
|
|
10
|
-
export { jsxRemoveAttributes };
|
|
11
|
-
export type { JSXRemoveAttributesPlugin };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var c=Object.defineProperty;var p=(e,a)=>c(e,"name",{value:a,configurable:!0});import{w as y}from"../packem_shared/index-Dq8IUFTs.js";import f from"magic-string";var b=Object.defineProperty,v=p((e,a)=>b(e,"name",{value:a,configurable:!0}),"l");const g=v(({attributes:e,logger:a})=>{if(!Array.isArray(e)||e.length===0)throw new Error("[packem:jsx-remove-attributes]: attributes must be a non-empty array of strings.");return{name:"packem:jsx-remove-attributes",transform:{filter:{id:/\.[tj]sx$/},async handler(i,u){let n;try{n=this.parse(i,{allowReturnOutsideFunction:!0})}catch(r){this.warn({code:"PARSE_ERROR",message:`[packem:jsx-remove-attributes]: failed to parse "${u}" and remove the jsx attribute.`}),a.warn(r);return}let l=!1;const o=new f(i);if(y(n,{enter(r){if(r.type==="CallExpression"&&r.callee.type==="Identifier"&&r.callee.name==="jsx"){const m=r.arguments.filter(s=>s.type==="ObjectExpression"&&Array.isArray(s.properties));for(const s of m)for(const t of s.properties)t.type==="Property"&&t.key.type==="Literal"&&t.value.type==="Literal"&&e.includes(t.key.value)&&(o.overwrite(t.start-2,t.end,""),l=!0)}}}),!!l)return{code:o.toString(),map:o.generateMap({hires:!0})}}}}},"jsxRemoveAttributes");export{g as jsxRemoveAttributes};
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { Plugin } from
|
|
2
|
-
|
|
3
|
-
interface LicenseOptions {
|
|
1
|
+
import type { Plugin } from "rollup";
|
|
2
|
+
export interface LicenseOptions {
|
|
4
3
|
dependenciesMarker?: string;
|
|
5
4
|
dependenciesTemplate?: (licenses: string[], dependencyLicenseTexts: string, packageName: string | undefined) => string;
|
|
6
5
|
dtsMarker?: string;
|
|
7
6
|
dtsTemplate?: (licenses: string[], dependencyLicenseTexts: string, packageName: string | undefined) => string;
|
|
8
7
|
path?: string;
|
|
9
8
|
}
|
|
10
|
-
declare const licensePlugin: ({ dtsMarker, licenseFilePath, licenseTemplate, logger, marker, mode, packageName, }: {
|
|
9
|
+
export declare const licensePlugin: ({ dtsMarker, licenseFilePath, licenseTemplate, logger, marker, mode, packageName, }: {
|
|
11
10
|
dtsMarker?: string;
|
|
12
11
|
licenseFilePath: string;
|
|
13
12
|
licenseTemplate: (licenses: string[], dependencyLicenseTexts: string, packageName: string | undefined) => string;
|
|
@@ -16,6 +15,3 @@ declare const licensePlugin: ({ dtsMarker, licenseFilePath, licenseTemplate, log
|
|
|
16
15
|
mode: "dependencies" | "types";
|
|
17
16
|
packageName: string | undefined;
|
|
18
17
|
}) => Plugin;
|
|
19
|
-
|
|
20
|
-
export { licensePlugin };
|
|
21
|
-
export type { LicenseOptions };
|