@visulima/packem-rollup 1.0.0-alpha.27 → 1.0.0-alpha.29

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.
Files changed (71) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/LICENSE.md +228 -183
  3. package/dist/index.d.ts +24 -58
  4. package/dist/plugins/cache-plugin.d.ts +11 -0
  5. package/dist/plugins/chunk-splitter/gather.d.ts +8 -0
  6. package/dist/plugins/chunk-splitter/index.d.ts +6 -0
  7. package/dist/plugins/chunk-splitter/parse/index.d.ts +4 -0
  8. package/dist/plugins/chunk-splitter/parse/types.d.ts +24 -0
  9. package/dist/plugins/cjs-interop.d.ts +3 -7
  10. package/dist/plugins/copy.d.ts +12 -7
  11. package/dist/plugins/data-uri.d.ts +21 -8
  12. package/dist/plugins/debarrel.d.ts +4 -8
  13. package/dist/{packem_shared/browserslist-to-esbuild-DY9HwYtp.d.ts → plugins/esbuild/browserslist-to-esbuild.d.ts} +1 -2
  14. package/dist/plugins/esbuild/esbuild-plugin.d.ts +3 -0
  15. package/dist/plugins/esbuild/index.d.ts +3 -42
  16. package/dist/plugins/esbuild/types.d.ts +39 -0
  17. package/dist/plugins/esbuild/utils/get-render-chunk.d.ts +14 -0
  18. package/dist/plugins/esbuild/utils/optimize-deps.d.ts +3 -0
  19. package/dist/plugins/esbuild/utils/warn.d.ts +4 -0
  20. package/dist/plugins/esm-shim-cjs-syntax.d.ts +6 -10
  21. package/dist/plugins/fix-dts-default-cjs-exports.d.ts +24 -7
  22. package/dist/plugins/fix-dynamic-import-extension.d.ts +3 -0
  23. package/dist/plugins/isolated-declarations/index.d.ts +5 -9
  24. package/dist/plugins/isolated-declarations/index.js +2 -2
  25. package/dist/plugins/isolated-declarations/utils/extend-string.d.ts +2 -0
  26. package/dist/plugins/isolated-declarations/utils/fix-dts-default-cjs-exports.d.ts +35 -0
  27. package/dist/plugins/isolated-declarations/utils/lowest-common-ancestor.d.ts +2 -0
  28. package/dist/plugins/isolated-declarations/utils/split-tsconfig-path-key.d.ts +2 -0
  29. package/dist/plugins/json.d.ts +4 -7
  30. package/dist/plugins/jsx-remove-attributes.d.ts +3 -7
  31. package/dist/plugins/license.d.ts +3 -7
  32. package/dist/plugins/metafile.d.ts +3 -0
  33. package/dist/plugins/minify-html-literals/index.d.ts +36 -91
  34. package/dist/plugins/minify-html-literals/index.js +2 -2
  35. package/dist/plugins/minify-html-literals/lib/minify-html-literals.d.ts +200 -0
  36. package/dist/plugins/minify-html-literals/lib/models.d.ts +25 -0
  37. package/dist/plugins/minify-html-literals/lib/parse-literals.d.ts +13 -0
  38. package/dist/plugins/minify-html-literals/lib/strategy.d.ts +69 -0
  39. package/dist/plugins/minify-html-literals/lib/typescript.d.ts +23 -0
  40. package/dist/plugins/native-modules-plugin.d.ts +12 -7
  41. package/dist/plugins/oxc/index.d.ts +4 -45
  42. package/dist/plugins/oxc/isolated-declarations-oxc-transformer.d.ts +4 -0
  43. package/dist/plugins/oxc/oxc-resolve-plugin.d.ts +4 -0
  44. package/dist/plugins/oxc/oxc-transformer-plugin.d.ts +3 -0
  45. package/dist/plugins/oxc/types.d.ts +16 -0
  46. package/dist/plugins/preserve-directives.d.ts +11 -8
  47. package/dist/plugins/raw.d.ts +4 -8
  48. package/dist/plugins/require-cjs-transformer.d.ts +35 -9
  49. package/dist/plugins/resolve-file-url.d.ts +3 -0
  50. package/dist/plugins/shebang.d.ts +6 -10
  51. package/dist/plugins/source-maps.d.ts +4 -8
  52. package/dist/plugins/sucrase/index.d.ts +8 -36
  53. package/dist/plugins/swc/index.d.ts +3 -43
  54. package/dist/plugins/swc/isolated-declarations-swc-transformer.d.ts +3 -0
  55. package/dist/plugins/swc/swc-plugin.d.ts +3 -0
  56. package/dist/plugins/swc/types.d.ts +6 -0
  57. package/dist/plugins/typescript/index.d.ts +8 -46
  58. package/dist/plugins/typescript/isolated-declarations-typescript-transformer.d.ts +4 -0
  59. package/dist/plugins/typescript/patch-typescript-types.d.ts +13 -0
  60. package/dist/plugins/typescript/resolve-tsconfig-paths-plugin.d.ts +11 -0
  61. package/dist/plugins/typescript/resolve-tsconfig-root-dirs.d.ts +24 -0
  62. package/dist/plugins/typescript/resolve-typescript-mjs-cjs.d.ts +10 -0
  63. package/dist/plugins/url.d.ts +63 -8
  64. package/dist/types.d.ts +133 -0
  65. package/dist/utils/chunks/create-split-chunks.d.ts +11 -0
  66. package/dist/utils/chunks/get-custom-module-layer.d.ts +2 -0
  67. package/dist/utils/chunks/get-module-layer.d.ts +10 -0
  68. package/dist/utils/index.d.ts +4 -0
  69. package/dist/utils/is-pure-cjs.d.ts +9 -0
  70. package/package.json +9 -9
  71. package/dist/packem_shared/types-BiZanzz1.d.ts +0 -4226
@@ -1,17 +1,43 @@
1
- import { FilterPattern } from '@rollup/pluginutils';
2
- import { ResolvedId, Plugin } from 'rollup';
3
-
1
+ import type { FilterPattern } from "@rollup/pluginutils";
2
+ import type { Plugin, ResolvedId } from "rollup";
4
3
  type Awaitable<T> = T | Promise<T>;
5
- type TransformFunction = (id: string, importer: string, rollupResolve: (id: string, importer?: string) => Promise<ResolvedId | null>) => Awaitable<boolean | undefined | void>;
6
- interface Options {
4
+ /**
5
+ * @returns A boolean or a promise that resolves to a boolean,
6
+ * or `undefined` to let the plugin decide automatically.
7
+ */
8
+ export type TransformFunction = (
9
+ /**
10
+ * The module ID (path) being imported.
11
+ */
12
+ id: string,
13
+ /**
14
+ * The module ID (path) of the importer.
15
+ */
16
+ importer: string,
17
+ /**
18
+ * Rollup resolve function for better module resolution
19
+ */
20
+ rollupResolve: (id: string, importer?: string) => Promise<ResolvedId | null>) => Awaitable<boolean | undefined | void>;
21
+ export interface Options {
22
+ /**
23
+ * Whether to transform Node.js built-in modules (e.g., `fs`, `path`)
24
+ * to `process.getBuiltinModule()` calls when supported, which has the best performance.
25
+ * Falls back to `createRequire()` for older Node.js versions, Bun, and Deno.
26
+ *
27
+ * Note: `process.getBuiltinModule` is available since Node.js 20.16.0 and 22.3.0.
28
+ * For older versions, the plugin uses `createRequire()` as fallback.
29
+ */
7
30
  builtinNodeModules?: boolean;
8
31
  cwd?: string;
9
32
  exclude?: FilterPattern;
10
33
  include?: FilterPattern;
11
34
  order?: "pre" | "post" | undefined;
35
+ /**
36
+ * A function to determine whether a module should be transformed.
37
+ * Return `true` to force transformation, `false` to skip transformation,
38
+ * or `undefined` to let the plugin decide automatically.
39
+ */
12
40
  shouldTransform?: string[] | TransformFunction;
13
41
  }
14
- declare const requireCJSTransformerPlugin: (userOptions: Options, _logger: Console) => Plugin;
15
-
16
- export { requireCJSTransformerPlugin };
17
- export type { Options, TransformFunction };
42
+ export declare const requireCJSTransformerPlugin: (userOptions: Options, _logger: Console) => Plugin;
43
+ export {};
@@ -0,0 +1,3 @@
1
+ import type { Plugin } from "rollup";
2
+ declare const resolveFileUrl: () => Plugin;
3
+ export default resolveFileUrl;
@@ -1,13 +1,9 @@
1
- import { Plugin } from 'rollup';
2
-
3
- type ShebangOptions = {
1
+ import type { Plugin } from "rollup";
2
+ export type ShebangOptions = {
4
3
  replace: boolean;
5
4
  shebang: string;
6
5
  };
7
- declare const makeExecutable: (filePath: string) => Promise<void>;
8
- declare const shebangPlugin: (executablePaths: string[], options: ShebangOptions) => Plugin;
9
- declare const removeShebangPlugin: () => Plugin;
10
- declare const getShebang: (code: string, append?: string) => string;
11
-
12
- export { getShebang, makeExecutable, removeShebangPlugin, shebangPlugin };
13
- export type { ShebangOptions };
6
+ export declare const makeExecutable: (filePath: string) => Promise<void>;
7
+ export declare const shebangPlugin: (executablePaths: string[], options: ShebangOptions) => Plugin;
8
+ export declare const removeShebangPlugin: () => Plugin;
9
+ export declare const getShebang: (code: string, append?: string) => string;
@@ -1,11 +1,7 @@
1
- import { FilterPattern } from '@rollup/pluginutils';
2
- import { Plugin } from 'rollup';
3
-
4
- interface SourcemapsPluginOptions {
1
+ import type { FilterPattern } from "@rollup/pluginutils";
2
+ import type { Plugin } from "rollup";
3
+ export interface SourcemapsPluginOptions {
5
4
  exclude?: FilterPattern;
6
5
  include?: FilterPattern;
7
6
  }
8
- declare const sourcemapsPlugin: ({ exclude, include }?: SourcemapsPluginOptions) => Plugin;
9
-
10
- export { sourcemapsPlugin };
11
- export type { SourcemapsPluginOptions };
7
+ export declare const sourcemapsPlugin: ({ exclude, include }?: SourcemapsPluginOptions) => Plugin;
@@ -1,36 +1,8 @@
1
- import '@rollup/pluginutils';
2
- import 'sucrase';
3
- export { l as SucrasePluginConfig, s as sucrasePlugin } from '../../packem_shared/types-BiZanzz1.js';
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';
11
- import 'rollup-plugin-dts';
12
- import 'rollup-plugin-polyfill-node';
13
- import 'rollup-plugin-pure';
14
- import 'rollup-plugin-visualizer';
15
- import '../cjs-interop.js';
16
- import '../copy.js';
17
- import '../data-uri.js';
18
- import '../debarrel.js';
19
- import 'esbuild';
20
- import '../esm-shim-cjs-syntax.js';
21
- import '@visulima/package';
22
- import '../isolated-declarations/index.js';
23
- import '@visulima/packem-share/types';
24
- import '../jsx-remove-attributes.js';
25
- import '../license.js';
26
- import '../minify-html-literals/index.js';
27
- import 'magic-string';
28
- import 'html-minifier-next';
29
- import '../native-modules-plugin.js';
30
- import 'oxc-resolver';
31
- import 'oxc-transform';
32
- import '../raw.js';
33
- import '../require-cjs-transformer.js';
34
- import '../shebang.js';
35
- import '../source-maps.js';
36
- import '../url.js';
1
+ import type { FilterPattern } from "@rollup/pluginutils";
2
+ import type { Options } from "sucrase";
3
+ import type { TransformerFn as TransformerFunction } from "../../types.d.ts";
4
+ export interface SucrasePluginConfig extends Options {
5
+ exclude?: FilterPattern;
6
+ include?: FilterPattern;
7
+ }
8
+ export declare const sucrasePlugin: TransformerFunction;
@@ -1,43 +1,3 @@
1
- import { I as IsolatedDeclarationsResult, T as TransformerFn } from '../../packem_shared/types-BiZanzz1.js';
2
- export { S as SwcPluginConfig } from '../../packem_shared/types-BiZanzz1.js';
3
- import '@rollup/plugin-alias';
4
- import '@rollup/plugin-commonjs';
5
- import '@rollup/plugin-json';
6
- import '@rollup/plugin-node-resolve';
7
- import '@rollup/plugin-replace';
8
- import '@rollup/plugin-wasm';
9
- import '@rollup/pluginutils';
10
- import 'rollup';
11
- import 'rollup-plugin-dts';
12
- import 'rollup-plugin-polyfill-node';
13
- import 'rollup-plugin-pure';
14
- import 'rollup-plugin-visualizer';
15
- import '../cjs-interop.js';
16
- import '../copy.js';
17
- import '../data-uri.js';
18
- import '../debarrel.js';
19
- import 'esbuild';
20
- import '../esm-shim-cjs-syntax.js';
21
- import '@visulima/package';
22
- import '../isolated-declarations/index.js';
23
- import '@visulima/packem-share/types';
24
- import '../jsx-remove-attributes.js';
25
- import '../license.js';
26
- import '../minify-html-literals/index.js';
27
- import 'magic-string';
28
- import 'html-minifier-next';
29
- import '../native-modules-plugin.js';
30
- import 'oxc-resolver';
31
- import 'oxc-transform';
32
- import '../raw.js';
33
- import '../require-cjs-transformer.js';
34
- import '../shebang.js';
35
- import '../source-maps.js';
36
- import 'sucrase';
37
- import '../url.js';
38
-
39
- declare const isolatedDeclarationsSwcTransformer: (id: string, code: string, sourceMap?: boolean) => Promise<IsolatedDeclarationsResult>;
40
-
41
- declare const _default: TransformerFn;
42
-
43
- export { isolatedDeclarationsSwcTransformer, _default as swcPlugin };
1
+ export { default as isolatedDeclarationsSwcTransformer } from "./isolated-declarations-swc-transformer.d.ts";
2
+ export { default as swcPlugin } from "./swc-plugin.d.ts";
3
+ export type * from "./types.d.ts";
@@ -0,0 +1,3 @@
1
+ import type { IsolatedDeclarationsResult } from "../../types.d.ts";
2
+ declare const isolatedDeclarationsSwcTransformer: (id: string, code: string, sourceMap?: boolean) => Promise<IsolatedDeclarationsResult>;
3
+ export default isolatedDeclarationsSwcTransformer;
@@ -0,0 +1,3 @@
1
+ import type { TransformerFn as TransformerFunction } from "../../types.d.ts";
2
+ declare const _default: TransformerFunction;
3
+ export default _default;
@@ -0,0 +1,6 @@
1
+ import type { FilterPattern } from "@rollup/pluginutils";
2
+ import type { Options } from "@swc/types";
3
+ export type SwcPluginConfig = Exclude<Options, "configFile" | "exclude" | "filename" | "sourceMaps" | "swcrc"> & {
4
+ exclude?: FilterPattern;
5
+ include?: FilterPattern;
6
+ };
@@ -1,46 +1,8 @@
1
- import { TranspileOptions } from 'typescript';
2
- import { I as IsolatedDeclarationsResult, f as TsConfigResult } from '../../packem_shared/types-BiZanzz1.js';
3
- export { g as PatchTypesOptions, h as TsconfigPathsPluginOptions, p as patchTypescriptTypes, p as patchTypescriptTypesPlugin, r as resolveTsconfigPathsPlugin } from '../../packem_shared/types-BiZanzz1.js';
4
- import { Plugin } from 'rollup';
5
- import '@rollup/plugin-alias';
6
- import '@rollup/plugin-commonjs';
7
- import '@rollup/plugin-json';
8
- import '@rollup/plugin-node-resolve';
9
- import '@rollup/plugin-replace';
10
- import '@rollup/plugin-wasm';
11
- import '@rollup/pluginutils';
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 isolatedDeclarationsTypescriptTransformer: (id: string, code: string, sourceMap?: boolean, transformOptions?: TranspileOptions) => Promise<IsolatedDeclarationsResult>;
41
-
42
- declare const resolveTsconfigRootDirectories: (cwd: string, logger: Console, tsconfig: TsConfigResult) => Plugin;
43
-
44
- declare const resolveTypescriptMjsCts: () => Plugin;
45
-
46
- export { isolatedDeclarationsTypescriptTransformer, resolveTsconfigRootDirectories as resolveTsconfigRootDirectoriesPlugin, resolveTypescriptMjsCts as resolveTypescriptMjsCtsPlugin };
1
+ export { default as isolatedDeclarationsTypescriptTransformer } from "./isolated-declarations-typescript-transformer.d.ts";
2
+ export type { PatchTypesOptions } from "./patch-typescript-types.d.ts";
3
+ export { patchTypescriptTypes } from "./patch-typescript-types.d.ts";
4
+ export { patchTypescriptTypes as patchTypescriptTypesPlugin } from "./patch-typescript-types.d.ts";
5
+ export type { TsconfigPathsPluginOptions } from "./resolve-tsconfig-paths-plugin.d.ts";
6
+ export { resolveTsconfigPathsPlugin } from "./resolve-tsconfig-paths-plugin.d.ts";
7
+ export { default as resolveTsconfigRootDirectoriesPlugin } from "./resolve-tsconfig-root-dirs.d.ts";
8
+ export { default as resolveTypescriptMjsCtsPlugin } from "./resolve-typescript-mjs-cjs.d.ts";
@@ -0,0 +1,4 @@
1
+ import type { TranspileOptions } from "typescript";
2
+ import type { IsolatedDeclarationsResult } from "../../types.d.ts";
3
+ declare const isolatedDeclarationsTypescriptTransformer: (id: string, code: string, sourceMap?: boolean, transformOptions?: TranspileOptions) => Promise<IsolatedDeclarationsResult>;
4
+ export default isolatedDeclarationsTypescriptTransformer;
@@ -0,0 +1,13 @@
1
+ import type { Plugin } from "rollup";
2
+ export type PatchTypesOptions = {
3
+ identifierReplacements?: Record<string, Record<string, string>>;
4
+ };
5
+ /**
6
+ * Patch the types files before passing to dts plugin
7
+ *
8
+ * 1. Validate unallowed dependency imports
9
+ * 2. Replace confusing type names
10
+ * 3. Strip leftover internal types
11
+ * 4. Clean unnecessary comments
12
+ */
13
+ export declare const patchTypescriptTypes: (options: PatchTypesOptions, logger: Console) => Plugin;
@@ -0,0 +1,11 @@
1
+ import type { TsConfigResult } from "@visulima/tsconfig";
2
+ import type { Plugin } from "rollup";
3
+ export type TsconfigPathsPluginOptions = {
4
+ resolveAbsolutePath?: boolean;
5
+ };
6
+ /**
7
+ * Handles tsconfig.json or jsconfig.js "paths" option for webpack
8
+ * Largely based on how the TypeScript compiler handles it:
9
+ * https://github.com/microsoft/TypeScript/blob/1a9c8197fffe3dace5f8dca6633d450a88cba66d/src/compiler/moduleNameResolver.ts#L1362
10
+ */
11
+ export declare const resolveTsconfigPathsPlugin: (rootDirectory: string, tsconfig: TsConfigResult, logger: Console, pluginOptions: TsconfigPathsPluginOptions) => Plugin;
@@ -0,0 +1,24 @@
1
+ import type { TsConfigResult } from "@visulima/tsconfig";
2
+ import type { Plugin } from "rollup";
3
+ /**
4
+ * This plugin resolves module paths using the rootDirs configuration from the tsconfig.json file.
5
+ *
6
+ * Consider the following example configuration:
7
+ * @example
8
+ * ```json
9
+ * {
10
+ * "compilerOptions": {
11
+ * "rootDirs": ["lib"]
12
+ * }
13
+ * }
14
+ * ```
15
+ *
16
+ * This configuration will allow you to import modules from the `src` and `lib` directories.
17
+ *
18
+ * ```typescript
19
+ * import { foo } from "./foo.d.ts"; -> ./src/foo
20
+ * import { bar } from "./bar.d.ts"; // -> ./lib/bar
21
+ * ```
22
+ */
23
+ declare const resolveTsconfigRootDirectories: (cwd: string, logger: Console, tsconfig: TsConfigResult) => Plugin;
24
+ export default resolveTsconfigRootDirectories;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Modified copy of https://github.com/privatenumber/pkgroll/blob/develop/src/utils/rollup-plugins/resolve-typescript-mjs-cjs.ts
3
+ *
4
+ * MIT License
5
+ *
6
+ * Copyright (c) Hiroki Osame &lt;hiroki.osame@gmail.com>
7
+ */
8
+ import type { Plugin } from "rollup";
9
+ declare const resolveTypescriptMjsCts: () => Plugin;
10
+ export default resolveTypescriptMjsCts;
@@ -1,17 +1,72 @@
1
- import { FilterPattern } from '@rollup/pluginutils';
2
- import { Plugin } from 'rollup';
3
-
4
- interface UrlOptions {
1
+ import type { FilterPattern } from "@rollup/pluginutils";
2
+ import type { Plugin } from "rollup";
3
+ export interface UrlOptions {
4
+ /**
5
+ * The destination dir to copy assets, usually used to rebase the assets according to HTML files.
6
+ * @type {string}
7
+ */
5
8
  destDir?: string;
9
+ /**
10
+ * If false, will prevent files being emitted by this plugin. This is useful for when you are using Rollup to emit both a client-side and server-side bundle.
11
+ * @type {boolean}
12
+ * @default true
13
+ */
6
14
  emitFiles: boolean;
15
+ /**
16
+ * A picomatch pattern, or array of patterns, which specifies the files in the build the plugin
17
+ * should _ignore_.
18
+ *
19
+ * By default, no files are ignored.
20
+ * @type {FilterPattern}
21
+ */
7
22
  exclude?: FilterPattern;
23
+ /**
24
+ * If emitFiles is true, this option can be used to rename the emitted files. It accepts the following string replacements:
25
+ * [hash] - The hash value of the file's contents
26
+ * [name] - The name of the imported file (without its file extension)
27
+ * [extname] - The extension of the imported file (including the leading .)
28
+ * [dirname] - The parent directory name of the imported file (including trailing /)
29
+ * @type {string}
30
+ * @default [hash][extname]
31
+ */
8
32
  fileName: string;
33
+ /**
34
+ * A picomatch pattern, or array of patterns, which specifies the files in the build the plugin
35
+ * should operate on.
36
+ * By default, the png,jpg,jpeg,gif,svg,webp files are targeted.
37
+ * @type {FilterPattern}
38
+ */
9
39
  include?: FilterPattern;
40
+ /**
41
+ * The file size limit for inline files.
42
+ * If a file exceeds this limit, it will be copied to the destination folder and the hashed filename will be provided instead.
43
+ * If limit is set to 0 all files will be copied.
44
+ * @type {number}
45
+ * @default 14336 (14kb)
46
+ */
10
47
  limit: number;
48
+ /**
49
+ * A string which will be added in front of filenames when they are not inlined but are copied.
50
+ * @type {string}
51
+ */
11
52
  publicPath?: string;
53
+ /**
54
+ * When using the [dirname] replacement in fileName, use this directory as the source directory from which to create the file path rather than the parent directory of the imported file. For example:
55
+ * @example
56
+ * ```js
57
+ * src/path/to/file.js
58
+ *
59
+ * import png from './image.d.ts';
60
+ * rollup.config.js
61
+ *
62
+ * url({
63
+ * fileName: '[dirname][hash][extname]',
64
+ * sourceDir: path.join(__dirname, 'src')
65
+ * });
66
+ *
67
+ * Emitted File: path/to/image.png
68
+ * ```
69
+ */
12
70
  sourceDir?: string;
13
71
  }
14
- declare const urlPlugin: ({ destDir: destinationDirectory, emitFiles, exclude, fileName, include, limit, publicPath, sourceDir: sourceDirectory, }: UrlOptions) => Plugin;
15
-
16
- export { urlPlugin };
17
- export type { UrlOptions };
72
+ export declare const urlPlugin: ({ destDir: destinationDirectory, emitFiles, exclude, fileName, include, limit, publicPath, sourceDir: sourceDirectory, }: UrlOptions) => Plugin;
@@ -0,0 +1,133 @@
1
+ import type { RollupAliasOptions } from "@rollup/plugin-alias";
2
+ import type { RollupCommonJSOptions } from "@rollup/plugin-commonjs";
3
+ import type { RollupJsonOptions } from "@rollup/plugin-json";
4
+ import type { RollupNodeResolveOptions } from "@rollup/plugin-node-resolve";
5
+ import type { RollupReplaceOptions } from "@rollup/plugin-replace";
6
+ import type { RollupWasmOptions } from "@rollup/plugin-wasm";
7
+ import type { FilterPattern } from "@rollup/pluginutils";
8
+ import type { OutputOptions, Plugin, RollupOptions } from "rollup";
9
+ import type { Options as RollupDtsOptions } from "rollup-plugin-dts";
10
+ import type { NodePolyfillsOptions } from "rollup-plugin-polyfill-node";
11
+ import type { PureAnnotationsOptions } from "rollup-plugin-pure";
12
+ import type { PluginVisualizerOptions } from "rollup-plugin-visualizer";
13
+ import type { CJSInteropOptions } from "./plugins/cjs-interop.d.ts";
14
+ import type { CopyPluginOptions } from "./plugins/copy.d.ts";
15
+ import type { DataUriPluginOptions } from "./plugins/data-uri.d.ts";
16
+ import type { DebarrelPluginOptions } from "./plugins/debarrel.d.ts";
17
+ import type { EsbuildPluginConfig, Options as EsbuildOptions } from "./plugins/esbuild/types.d.ts";
18
+ import type { EsmShimCjsSyntaxOptions } from "./plugins/esm-shim-cjs-syntax.d.ts";
19
+ import type { IsolatedDeclarationsOptions } from "./plugins/isolated-declarations/index.d.ts";
20
+ import type { JSXRemoveAttributesPlugin } from "./plugins/jsx-remove-attributes.d.ts";
21
+ import type { LicenseOptions } from "./plugins/license.d.ts";
22
+ import type { MinifyHTMLLiteralsOptions } from "./plugins/minify-html-literals/index.d.ts";
23
+ import type { NativeModulesOptions } from "./plugins/native-modules-plugin.d.ts";
24
+ import type { InternalOXCTransformPluginConfig, OxcResolveOptions, OXCTransformPluginConfig } from "./plugins/oxc/types.d.ts";
25
+ import type { RawLoaderOptions } from "./plugins/raw.d.ts";
26
+ import type { Options as RequireCJSPluginOptions } from "./plugins/require-cjs-transformer.d.ts";
27
+ import type { ShebangOptions } from "./plugins/shebang.d.ts";
28
+ import type { SourcemapsPluginOptions } from "./plugins/source-maps.d.ts";
29
+ import type { SucrasePluginConfig } from "./plugins/sucrase/index.d.ts";
30
+ import type { SwcPluginConfig } from "./plugins/swc/types.d.ts";
31
+ import type { PatchTypesOptions } from "./plugins/typescript/patch-typescript-types.d.ts";
32
+ import type { TsconfigPathsPluginOptions } from "./plugins/typescript/resolve-tsconfig-paths-plugin.d.ts";
33
+ import type { UrlOptions } from "./plugins/url.d.ts";
34
+ interface RollupDynamicImportVariablesOptions {
35
+ /**
36
+ * By default, the plugin will not throw errors when target files are not found.
37
+ * Setting this option to true will result in errors thrown when encountering files which don't exist.
38
+ * @default false
39
+ */
40
+ errorWhenNoFilesFound?: boolean;
41
+ /**
42
+ * A picomatch pattern, or array of patterns, which specifies the files in the build the plugin
43
+ * should _ignore_.
44
+ *
45
+ * By default, no files are ignored.
46
+ */
47
+ exclude?: FilterPattern;
48
+ /**
49
+ * A picomatch pattern, or array of patterns, which specifies the files in the build the plugin
50
+ * should operate on.
51
+ * By default, all files are targeted.
52
+ */
53
+ include?: FilterPattern;
54
+ /**
55
+ * By default, the plugin quits the build process when it encounters an error.
56
+ * If you set this option to true, it will throw a warning instead and leave the code untouched.
57
+ * @default false
58
+ */
59
+ warnOnError?: boolean;
60
+ }
61
+ export interface ExtendedRollupNodeResolveOptions extends RollupNodeResolveOptions {
62
+ /**
63
+ * Controls how unresolved import warnings from the node-resolve plugin are handled.
64
+ * - `"error"` (default): Treat unresolved imports as errors, causing the build to fail
65
+ * - `"warn"`: Treat unresolved imports as warnings, allowing the build to continue
66
+ * @default "error"
67
+ */
68
+ unresolvedImportBehavior?: "error" | "warn";
69
+ }
70
+ export interface IsolatedDeclarationsResult {
71
+ errors: string[];
72
+ map?: string;
73
+ sourceText: string;
74
+ }
75
+ export type IsolatedDeclarationsTransformer = (code: string, id: string, sourceMap?: boolean) => Promise<IsolatedDeclarationsResult>;
76
+ export interface PackemRollupOptions {
77
+ alias?: RollupAliasOptions | false;
78
+ cjsInterop?: CJSInteropOptions;
79
+ commonjs?: RollupCommonJSOptions | false;
80
+ copy?: CopyPluginOptions | false;
81
+ dataUri?: DataUriPluginOptions | false;
82
+ debarrel?: DebarrelPluginOptions | false;
83
+ dts?: RollupDtsOptions;
84
+ dynamicVars?: RollupDynamicImportVariablesOptions | false;
85
+ esbuild?: EsbuildOptions | false;
86
+ experimental?: {
87
+ resolve?: OxcResolveOptions | false;
88
+ };
89
+ isolatedDeclarations?: IsolatedDeclarationsOptions;
90
+ json?: RollupJsonOptions | false;
91
+ jsxRemoveAttributes?: JSXRemoveAttributesPlugin | false;
92
+ license?: LicenseOptions | false;
93
+ metafile?: boolean;
94
+ minifyHTMLLiterals?: MinifyHTMLLiteralsOptions | false;
95
+ nativeModules?: NativeModulesOptions | false;
96
+ output?: OutputOptions;
97
+ oxc?: Omit<OXCTransformPluginConfig, "cwd" | "sourcemap" | "target"> | false;
98
+ patchTypes?: PatchTypesOptions | false;
99
+ pluginPure?: Omit<PureAnnotationsOptions, "sourcemap"> | false;
100
+ plugins?: RollupPlugins;
101
+ polyfillNode?: NodePolyfillsOptions | false;
102
+ preserveDirectives?: {
103
+ directiveRegex?: RegExp;
104
+ exclude?: FilterPattern;
105
+ include?: FilterPattern;
106
+ };
107
+ preserveDynamicImports?: boolean;
108
+ raw?: RawLoaderOptions | false;
109
+ replace?: Omit<RollupReplaceOptions, "cwd"> | false;
110
+ requireCJS?: RequireCJSPluginOptions | false;
111
+ resolve?: ExtendedRollupNodeResolveOptions | false;
112
+ shebang?: Partial<ShebangOptions> | false;
113
+ shim?: EsmShimCjsSyntaxOptions | false;
114
+ sourcemap?: SourcemapsPluginOptions;
115
+ sucrase?: SucrasePluginConfig | false;
116
+ swc?: SwcPluginConfig | false;
117
+ treeshake?: RollupOptions["treeshake"];
118
+ tsconfigPaths?: TsconfigPathsPluginOptions | false;
119
+ url?: UrlOptions | false;
120
+ visualizer?: PluginVisualizerOptions | false;
121
+ wasm?: RollupWasmOptions | false;
122
+ watch?: RollupOptions["watch"];
123
+ }
124
+ export type RollupPlugins = {
125
+ enforce?: "post" | "pre";
126
+ plugin: Plugin;
127
+ type?: "build" | "dts";
128
+ }[];
129
+ export type TransformerFn = ((config: EsbuildPluginConfig | InternalOXCTransformPluginConfig | SucrasePluginConfig | SwcPluginConfig) => Plugin) & {
130
+ NAME?: TransformerName;
131
+ };
132
+ export type TransformerName = "esbuild" | "oxc" | "sucrase" | "swc";
133
+ export {};
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Modified copy of https://github.com/huozhi/bunchee/blob/3cb85160bbad3af229654cc09d6fcd67120fe8bd/src/lib/split-chunk.ts
3
+ *
4
+ * The MIT License (MIT)
5
+ *
6
+ * Copyright (c) 2018 these people -> https://github.com/huozhi/bunchee/graphs/contributors
7
+ */
8
+ import type { BuildContextBuildAssetAndChunk, BuildContextBuildEntry } from "@visulima/packem-share/types";
9
+ import type { GetManualChunk } from "rollup";
10
+ declare const createSplitChunks: (dependencyGraphMap: Map<string, Set<[string, string]>>, entryFiles: (BuildContextBuildAssetAndChunk | BuildContextBuildEntry)[]) => GetManualChunk;
11
+ export default createSplitChunks;
@@ -0,0 +1,2 @@
1
+ declare const getCustomModuleLayer: (moduleId: string) => string | undefined;
2
+ export default getCustomModuleLayer;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Modified copy of https://github.com/huozhi/bunchee/blob/3cb85160bbad3af229654cc09d6fcd67120fe8bd/src/lib/split-chunk.ts
3
+ *
4
+ * The MIT License (MIT)
5
+ *
6
+ * Copyright (c) 2018 these people -> https://github.com/huozhi/bunchee/graphs/contributors
7
+ */
8
+ import type { CustomPluginOptions } from "rollup";
9
+ declare const getModuleLayer: (moduleMeta: CustomPluginOptions) => any;
10
+ export default getModuleLayer;
@@ -0,0 +1,4 @@
1
+ export { default as createSplitChunks } from "./chunks/create-split-chunks.d.ts";
2
+ export { default as getCustomModuleLayer } from "./chunks/get-custom-module-layer.d.ts";
3
+ export { default as getModuleLayer } from "./chunks/get-module-layer.d.ts";
4
+ export { arrayify, enhanceRollupError, FileCache, getChunkFilename, getEntryFileNames, getHash, getPackageName, memoize, memoizeByKey, replaceContentWithinMarker, sortUserPlugins, svgEncoder, } from "@visulima/packem-share/utils";
@@ -0,0 +1,9 @@
1
+ import type { ResolvedId } from "rollup";
2
+ /**
3
+ * Determines if a module is a pure CommonJS module by checking various indicators.
4
+ * @param id The module ID to check
5
+ * @param importer The importer context (can be a file path or Rollup plugin context)
6
+ * @param rollupResolve Optional Rollup resolve function for better module resolution
7
+ */
8
+ export declare const isPureCJS: (id: string, importer: string, rollupResolve?: (id: string, importer?: string) => Promise<ResolvedId | null>) => Promise<boolean>;
9
+ export default isPureCJS;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visulima/packem-rollup",
3
- "version": "1.0.0-alpha.27",
3
+ "version": "1.0.0-alpha.29",
4
4
  "description": "Rollup plugins for packem",
5
5
  "keywords": [
6
6
  "visulima",
@@ -147,20 +147,20 @@
147
147
  "@rollup/plugin-replace": "6.0.2",
148
148
  "@rollup/plugin-wasm": "6.2.2",
149
149
  "@rollup/pluginutils": "5.3.0",
150
- "@visulima/find-cache-dir": "1.0.34",
151
- "@visulima/fs": "3.1.8",
152
- "@visulima/package": "4.0.0",
153
- "@visulima/packem-share": "1.0.0-alpha.13",
150
+ "@visulima/find-cache-dir": "2.0.4",
151
+ "@visulima/fs": "4.0.4",
152
+ "@visulima/package": "4.1.4",
153
+ "@visulima/packem-share": "1.0.0-alpha.14",
154
154
  "@visulima/path": "1.4.0",
155
- "@visulima/source-map": "1.0.20",
155
+ "@visulima/source-map": "2.0.3",
156
156
  "cjs-module-lexer": "^2.1.1",
157
157
  "clean-css": "^5.3.3",
158
158
  "glob-parent": "6.0.2",
159
- "html-minifier-next": "^4.1.0",
159
+ "html-minifier-next": "^4.3.1",
160
160
  "magic-string": "0.30.19",
161
161
  "mlly": "1.8.0",
162
- "oxc-parser": "0.93.0",
163
- "oxc-resolver": "11.8.2",
162
+ "oxc-parser": "0.99.0",
163
+ "oxc-resolver": "11.14.0",
164
164
  "rollup-plugin-dts": "6.2.3",
165
165
  "rollup-plugin-license": "3.6.0",
166
166
  "rollup-plugin-polyfill-node": "0.13.0",