@visulima/packem-rollup 1.0.0-alpha.6 → 1.0.0-alpha.61

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 (145) hide show
  1. package/CHANGELOG.md +611 -0
  2. package/LICENSE.md +219 -477
  3. package/README.md +89 -2
  4. package/dist/index.d.ts +25 -64
  5. package/dist/index.js +1 -0
  6. package/dist/packem_shared/cachingPlugin-DLKoeQeF.js +1 -0
  7. package/dist/packem_shared/createSplitChunks-BrEBZq7d.js +1 -0
  8. package/dist/packem_shared/esbuildPlugin-C5x4_cXf.js +1 -0
  9. package/dist/packem_shared/{index-Cj1Okk1t.mjs → index-QEzU3Fey.js} +1 -1
  10. package/dist/packem_shared/{metafilePlugin-ObS4J7mO.mjs → metafilePlugin-CVcqFpPJ.js} +1 -1
  11. package/dist/packem_shared/oxcResolvePlugin-SH1JFonc.js +1 -0
  12. package/dist/packem_shared/oxcTransformPlugin-BGmQroQ4.js +4 -0
  13. package/dist/packem_shared/patchTypescriptTypes-CZ4v3hr9.js +6 -0
  14. package/dist/packem_shared/pureNewExpressionPlugin-DX9yMcH2.js +1 -0
  15. package/dist/packem_shared/resolveTsconfigPathsPlugin-CEasmDpi.js +1 -0
  16. package/dist/packem_shared/{resolveTsconfigRootDirectoriesPlugin-_93afm2q.mjs → resolveTsconfigRootDirectoriesPlugin-Cwj3tqCJ.js} +1 -1
  17. package/dist/packem_shared/resolveTypescriptMjsCtsPlugin-DX9at4BX.js +1 -0
  18. package/dist/plugins/babel/index.d.ts +10 -0
  19. package/dist/plugins/babel/index.js +1 -0
  20. package/dist/plugins/cache-plugin.d.ts +11 -0
  21. package/dist/plugins/chunk-splitter/gather.d.ts +8 -0
  22. package/dist/plugins/chunk-splitter/index.d.ts +6 -0
  23. package/dist/plugins/chunk-splitter/parse/index.d.ts +4 -0
  24. package/dist/plugins/chunk-splitter/parse/types.d.ts +24 -0
  25. package/dist/plugins/cjs-interop.d.ts +7 -0
  26. package/dist/{packem_shared/cjsInteropPlugin-D5wyoQ_B.mjs → plugins/cjs-interop.js} +1 -1
  27. package/dist/plugins/copy.d.ts +23 -0
  28. package/dist/plugins/copy.js +1 -0
  29. package/dist/plugins/data-uri.d.ts +25 -0
  30. package/dist/plugins/data-uri.js +1 -0
  31. package/dist/plugins/debarrel.d.ts +7 -0
  32. package/dist/plugins/debarrel.js +2 -0
  33. package/dist/{packem_shared/browserslist-to-esbuild-DY9HwYtp.d.mts → plugins/esbuild/browserslist-to-esbuild.d.ts} +1 -2
  34. package/dist/plugins/esbuild/esbuild-plugin.d.ts +3 -0
  35. package/dist/plugins/esbuild/index.d.ts +3 -25
  36. package/dist/plugins/esbuild/index.js +1 -0
  37. package/dist/plugins/esbuild/types.d.ts +39 -0
  38. package/dist/plugins/esbuild/utils/get-render-chunk.d.ts +14 -0
  39. package/dist/plugins/esbuild/utils/optimize-deps.d.ts +3 -0
  40. package/dist/plugins/esbuild/utils/warn.d.ts +4 -0
  41. package/dist/plugins/esm-shim-cjs-syntax.d.ts +9 -0
  42. package/dist/plugins/fix-dts-default-cjs-exports-util.d.ts +35 -0
  43. package/dist/plugins/fix-dts-default-cjs-exports.d.ts +26 -0
  44. package/dist/plugins/fix-dts-default-cjs-exports.js +26 -0
  45. package/dist/plugins/fix-dynamic-import-extension.d.ts +3 -0
  46. package/dist/plugins/import-attributes.d.ts +2 -0
  47. package/dist/plugins/import-attributes.js +1 -0
  48. package/dist/plugins/json.d.ts +4 -0
  49. package/dist/plugins/json.js +1 -0
  50. package/dist/plugins/jsx-remove-attributes.d.ts +7 -0
  51. package/dist/plugins/jsx-remove-attributes.js +1 -0
  52. package/dist/plugins/license.d.ts +17 -0
  53. package/dist/plugins/license.js +13 -0
  54. package/dist/plugins/metafile.d.ts +3 -0
  55. package/dist/plugins/minify-html-literals/index.d.ts +41 -0
  56. package/dist/plugins/minify-html-literals/index.js +3 -0
  57. package/dist/plugins/minify-html-literals/lib/minify-html-literals.d.ts +200 -0
  58. package/dist/plugins/minify-html-literals/lib/models.d.ts +25 -0
  59. package/dist/plugins/minify-html-literals/lib/parse-literals.d.ts +13 -0
  60. package/dist/plugins/minify-html-literals/lib/strategy.d.ts +69 -0
  61. package/dist/plugins/minify-html-literals/lib/typescript.d.ts +23 -0
  62. package/dist/plugins/native-modules-plugin.d.ts +14 -0
  63. package/dist/plugins/native-modules-plugin.js +1 -0
  64. package/dist/plugins/oxc/index.d.ts +3 -28
  65. package/dist/plugins/oxc/index.js +1 -0
  66. package/dist/plugins/oxc/oxc-resolve-plugin.d.ts +4 -0
  67. package/dist/plugins/oxc/oxc-transformer-plugin.d.ts +3 -0
  68. package/dist/plugins/oxc/types.d.ts +16 -0
  69. package/dist/plugins/preserve-directives.d.ts +16 -0
  70. package/dist/{packem_shared/preserveDirectivesPlugin-B49Cbykd.mjs → plugins/preserve-directives.js} +2 -2
  71. package/dist/plugins/pure-new-expression-plugin.d.ts +11 -0
  72. package/dist/plugins/raw.d.ts +7 -0
  73. package/dist/plugins/raw.js +6 -0
  74. package/dist/plugins/require-cjs-transformer.d.ts +43 -0
  75. package/dist/plugins/require-cjs-transformer.js +21 -0
  76. package/dist/plugins/resolve-file-url.d.ts +3 -0
  77. package/dist/plugins/shebang.d.ts +9 -0
  78. package/dist/plugins/source-maps.d.ts +7 -0
  79. package/dist/plugins/sucrase/index.d.ts +8 -19
  80. package/dist/plugins/swc/index.d.ts +2 -26
  81. package/dist/plugins/swc/index.js +1 -0
  82. package/dist/plugins/swc/swc-plugin.d.ts +3 -0
  83. package/dist/plugins/swc/types.d.ts +6 -0
  84. package/dist/plugins/typescript/index.d.ts +7 -29
  85. package/dist/plugins/typescript/index.js +1 -0
  86. package/dist/plugins/typescript/patch-typescript-types.d.ts +13 -0
  87. package/dist/plugins/typescript/resolve-tsconfig-paths-plugin.d.ts +11 -0
  88. package/dist/plugins/typescript/resolve-tsconfig-root-dirs.d.ts +24 -0
  89. package/dist/plugins/typescript/resolve-typescript-mjs-cjs.d.ts +3 -0
  90. package/dist/plugins/url.d.ts +72 -0
  91. package/dist/plugins/url.js +1 -0
  92. package/dist/types.d.ts +127 -0
  93. package/dist/utils/chunks/create-split-chunks.d.ts +11 -0
  94. package/dist/utils/chunks/get-custom-module-layer.d.ts +2 -0
  95. package/dist/utils/chunks/get-module-layer.d.ts +10 -0
  96. package/dist/utils/index.d.ts +4 -0
  97. package/dist/utils/is-pure-cjs.d.ts +9 -0
  98. package/package.json +120 -37
  99. package/dist/index.d.mts +0 -64
  100. package/dist/index.mjs +0 -1
  101. package/dist/packem_shared/browserslist-to-esbuild-DY9HwYtp.d.ts +0 -3
  102. package/dist/packem_shared/cachingPlugin-D0BBFJPD.mjs +0 -1
  103. package/dist/packem_shared/copyPlugin--6RITp1-.mjs +0 -1
  104. package/dist/packem_shared/createSplitChunks-CGDk55G3.mjs +0 -1
  105. package/dist/packem_shared/dataUriPlugin-BOjv6O2O.mjs +0 -1
  106. package/dist/packem_shared/esbuildPlugin-BAwyhG6L.mjs +0 -1
  107. package/dist/packem_shared/fix-dts-default-cjs-exports-BQc0nwIG.mjs +0 -26
  108. package/dist/packem_shared/fixDtsDefaultCjsExportsPlugin-Dp1UcHVR.mjs +0 -1
  109. package/dist/packem_shared/isolatedDeclarationsOxcTransformer-WbfE6cGu.mjs +0 -1
  110. package/dist/packem_shared/isolatedDeclarationsPlugin-A0wmmw3Y.mjs +0 -3
  111. package/dist/packem_shared/isolatedDeclarationsSwcTransformer-Ch2AgtWC.mjs +0 -1
  112. package/dist/packem_shared/isolatedDeclarationsTypescriptTransformer-DkuEkofo.mjs +0 -3
  113. package/dist/packem_shared/jsonPlugin-BAi3Da-h.mjs +0 -1
  114. package/dist/packem_shared/jsxRemoveAttributes-B1PLPffj.mjs +0 -1
  115. package/dist/packem_shared/licensePlugin-C5yzUqe-.mjs +0 -13
  116. package/dist/packem_shared/oxcResolvePlugin-BJpi-eSG.mjs +0 -1
  117. package/dist/packem_shared/oxcTransformPlugin-DfVQouIB.mjs +0 -4
  118. package/dist/packem_shared/patchTypescriptTypes-BEdkvKxL.mjs +0 -6
  119. package/dist/packem_shared/rawPlugin-BqlR6ZOI.mjs +0 -1
  120. package/dist/packem_shared/resolveTsconfigPathsPlugin-Crf4lzxq.mjs +0 -1
  121. package/dist/packem_shared/resolveTypescriptMjsCtsPlugin-DcZrZTmM.mjs +0 -1
  122. package/dist/packem_shared/types-yL82LLIx.d.mts +0 -4541
  123. package/dist/packem_shared/types-yL82LLIx.d.ts +0 -4541
  124. package/dist/packem_shared/urlPlugin-Bm2IE00y.mjs +0 -1
  125. package/dist/plugins/esbuild/index.d.mts +0 -25
  126. package/dist/plugins/esbuild/index.mjs +0 -1
  127. package/dist/plugins/oxc/index.d.mts +0 -28
  128. package/dist/plugins/oxc/index.mjs +0 -1
  129. package/dist/plugins/sucrase/index.d.mts +0 -19
  130. package/dist/plugins/swc/index.d.mts +0 -26
  131. package/dist/plugins/swc/index.mjs +0 -1
  132. package/dist/plugins/typescript/index.d.mts +0 -29
  133. package/dist/plugins/typescript/index.mjs +0 -1
  134. /package/dist/packem_shared/{browserslistToEsbuild-C0IWmbNe.mjs → browserslistToEsbuild-C0IWmbNe.js} +0 -0
  135. /package/dist/packem_shared/{chunkSplitter-DWAy1JkE.mjs → chunkSplitter-DWAy1JkE.js} +0 -0
  136. /package/dist/packem_shared/{fixDynamicImportExtension-BBGNRniz.mjs → fixDynamicImportExtension-BBGNRniz.js} +0 -0
  137. /package/dist/packem_shared/{getCustomModuleLayer-d8i66lfh.mjs → getCustomModuleLayer-d8i66lfh.js} +0 -0
  138. /package/dist/packem_shared/{getModuleLayer-rF9RxnJ5.mjs → getModuleLayer-rF9RxnJ5.js} +0 -0
  139. /package/dist/packem_shared/{index-Dq8IUFTs.mjs → index-Dq8IUFTs.js} +0 -0
  140. /package/dist/packem_shared/{resolveFileUrlPlugin-BkpjVHeK.mjs → resolveFileUrlPlugin-BkpjVHeK.js} +0 -0
  141. /package/dist/packem_shared/{swcPlugin-Boip4lWG.mjs → swcPlugin-Boip4lWG.js} +0 -0
  142. /package/dist/{packem_shared/esmShimCjsSyntaxPlugin-DjKqX4DE.mjs → plugins/esm-shim-cjs-syntax.js} +0 -0
  143. /package/dist/{packem_shared/makeExecutable-6aOVHoJR.mjs → plugins/shebang.js} +0 -0
  144. /package/dist/{packem_shared/sourcemapsPlugin-B4W3J79w.mjs → plugins/source-maps.js} +0 -0
  145. /package/dist/plugins/sucrase/{index.mjs → index.js} +0 -0
@@ -0,0 +1,200 @@
1
+ /**
2
+ * Ported from https://github.com/lit/lit/tree/main/packages/labs/rollup-plugin-minify-html-literals
3
+ *
4
+ * BSD-3-Clause License
5
+ *
6
+ * Copyright (c) 2024 Google LLC
7
+ */
8
+ import type { SourceMapOptions } from "magic-string";
9
+ import type { Template, TemplatePart } from "./models.d.ts";
10
+ import type { ParseLiteralsOptions } from "./parse-literals.d.ts";
11
+ import { parseLiterals } from "./parse-literals.d.ts";
12
+ import type { Strategy } from "./strategy.d.ts";
13
+ import { defaultMinifyOptions } from "./strategy.d.ts";
14
+ /**
15
+ * Options for <code>minifyHTMLLiterals()</code>.
16
+ */
17
+ export type Options = DefaultOptions | CustomOptions<unknown>;
18
+ /**
19
+ * Options for &lt;code>minifyHTMLLiterals()&lt;/code>, using default html-minifier
20
+ * strategy.
21
+ */
22
+ export interface DefaultOptions extends BaseOptions {
23
+ /**
24
+ * &lt;code>html-minifier&lt;/code> options to use. Defaults to
25
+ * &lt;code>defaultMinifyOptions&lt;/code>, for production-ready minification.
26
+ */
27
+ minifyOptions?: Partial<typeof defaultMinifyOptions>;
28
+ }
29
+ /**
30
+ * Options for &lt;code>minifyHTMLLiterals()&lt;/code>, using a custom strategy.
31
+ */
32
+ export interface CustomOptions<S extends Strategy | unknown> extends BaseOptions {
33
+ /**
34
+ * HTML minification options.
35
+ */
36
+ minifyOptions?: S extends Strategy<infer O> ? Partial<O> : never;
37
+ /**
38
+ * Override the default strategy for how to minify HTML. The default is to
39
+ * use &lt;code>html-minifier&lt;/code>.
40
+ */
41
+ strategy: S;
42
+ }
43
+ /**
44
+ * Options for &lt;code>minifyHTMLLiterals()&lt;/code>.
45
+ */
46
+ export interface BaseOptions {
47
+ /**
48
+ * The name of the file. This is used to determine how to parse the source
49
+ * code and for source map filenames. It may be a base name, relative, or
50
+ * absolute path.
51
+ */
52
+ fileName?: string;
53
+ /**
54
+ * Override how source maps are generated. Set to false to disable source map
55
+ * generation.
56
+ * @param ms the MagicString instance with code modifications
57
+ * @param fileName the name or path of the file
58
+ * @returns a v3 SourceMap or undefined
59
+ */
60
+ generateSourceMap?: ((ms: MagicStringLike, fileName: string) => SourceMap | undefined) | false;
61
+ /**
62
+ * The MagicString-like constructor to use. MagicString is used to replace
63
+ * strings and generate source maps.
64
+ *
65
+ * Override if you want to set your own version of MagicString or change how
66
+ * strings are overridden. Use &lt;code>generateSourceMap&lt;/code> if you want to
67
+ * change how source maps are created.
68
+ */
69
+ MagicString?: new (source: string) => MagicStringLike;
70
+ /**
71
+ * Override how template literals are parsed from a source string.
72
+ */
73
+ parseLiterals?: typeof parseLiterals;
74
+ /**
75
+ * Options for &lt;code>parseLiterals()&lt;/code>.
76
+ */
77
+ parseLiteralsOptions?: Partial<ParseLiteralsOptions>;
78
+ /**
79
+ * Determines whether or not a template should be minified. The default is to
80
+ * minify all tagged template whose tag name contains "html" (case
81
+ * insensitive).
82
+ * @param template the template to check
83
+ * @returns true if the template should be minified
84
+ */
85
+ shouldMinify?: (template: Template) => boolean;
86
+ /**
87
+ * Determines whether or not a CSS template should be minified. The default is
88
+ * to minify all tagged template whose tag name contains "css" (case
89
+ * insensitive).
90
+ * @param template the template to check
91
+ * @returns true if the template should be minified
92
+ */
93
+ shouldMinifyCSS?: (template: Template) => boolean;
94
+ /**
95
+ * Override custom validation or set to false to disable validation. This is
96
+ * only useful when implementing your own strategy that may return
97
+ * unexpected results.
98
+ */
99
+ validate?: Validation | false;
100
+ }
101
+ /**
102
+ * A MagicString-like instance. &lt;code>minify-html-literals&lt;/code> only uses a
103
+ * subset of the MagicString API to overwrite the source code and generate
104
+ * source maps.
105
+ */
106
+ export interface MagicStringLike {
107
+ generateMap: (options?: Partial<SourceMapOptions>) => SourceMap;
108
+ overwrite: (start: number, end: number, content: string) => unknown;
109
+ toString: () => string;
110
+ }
111
+ /**
112
+ * A v3 SourceMap.
113
+ *
114
+ * &lt;code>magic-string> incorrectly declares the SourceMap type with a version
115
+ * string instead of a number, so &lt;code>minify-html-literals&lt;/code> declares
116
+ * its own type.
117
+ */
118
+ export interface SourceMap {
119
+ file?: string;
120
+ mappings: string;
121
+ names: string[];
122
+ sources: string[];
123
+ sourcesContent?: string[];
124
+ toString: () => string;
125
+ toUrl: () => string;
126
+ version: number;
127
+ }
128
+ /**
129
+ * Validation that is executed when minifying HTML to ensure there are no
130
+ * unexpected errors. This is to alleviate hard-to-troubleshoot errors such as
131
+ * undefined errors.
132
+ */
133
+ export interface Validation {
134
+ /**
135
+ * Throws an error if &lt;code>strategy.splitHTMLByPlaceholder()&lt;/code> does not
136
+ * return an HTML part string for each template part.
137
+ * @param parts the template parts that generated the strings
138
+ * @param htmlParts the split HTML strings
139
+ */
140
+ ensureHTMLPartsValid: (parts: TemplatePart[], htmlParts: string[]) => void;
141
+ /**
142
+ * Throws an error if &lt;code>strategy.getPlaceholder()&lt;/code> does not return
143
+ * a valid placeholder string.
144
+ * @param placeholder the placeholder to check
145
+ */
146
+ ensurePlaceholderValid: (placeholder: unknown) => void;
147
+ }
148
+ /**
149
+ * The result of a call to &lt;code>minifyHTMLLiterals()&lt;/code>.
150
+ */
151
+ export interface Result {
152
+ /**
153
+ * The minified code.
154
+ */
155
+ code: string;
156
+ /**
157
+ * Optional v3 SourceMap for the code.
158
+ */
159
+ map: SourceMap | undefined;
160
+ }
161
+ /**
162
+ * The default method to generate a SourceMap. It will generate the SourceMap
163
+ * from the provided MagicString instance using "fileName.map" as the file and
164
+ * "fileName" as the source.
165
+ * @param ms the MagicString instance with code modifications
166
+ * @param fileName the name of the source file
167
+ * @returns a v3 SourceMap
168
+ */
169
+ export declare const defaultGenerateSourceMap: (ms: MagicStringLike, fileName: string) => SourceMap;
170
+ /**
171
+ * The default method to determine whether or not to minify a template. It will
172
+ * return true for all tagged templates whose tag name contains "html" (case
173
+ * insensitive).
174
+ * @param template the template to check
175
+ * @returns true if the template should be minified
176
+ */
177
+ export declare const defaultShouldMinify: (template: Template) => boolean;
178
+ /**
179
+ * The default method to determine whether or not to minify a CSS template. It
180
+ * will return true for all tagged templates whose tag name contains "css" (case
181
+ * insensitive).
182
+ * @param template the template to check
183
+ * @returns true if the template should be minified
184
+ */
185
+ export declare const defaultShouldMinifyCSS: (template: Template) => boolean;
186
+ export declare const defaultValidation: Validation;
187
+ /**
188
+ * Minifies all HTML template literals in the provided source string.
189
+ * @param source the source code
190
+ * @param options minification options
191
+ * @returns the minified code, or null if no minification occurred.
192
+ */
193
+ export declare function minifyHTMLLiterals(source: string, options?: DefaultOptions): Promise<Result | null | undefined>;
194
+ /**
195
+ * Minifies all HTML template literals in the provided source string.
196
+ * @param source the source code
197
+ * @param options minification options
198
+ * @returns the minified code, or null if no minification occurred.
199
+ */
200
+ export declare function minifyHTMLLiterals<S extends Strategy>(source: string, options?: CustomOptions<S>): Promise<Result | undefined>;
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Ported from https://github.com/lit/lit/tree/main/packages/labs/rollup-plugin-minify-html-literals
3
+ *
4
+ * BSD-3-Clause License
5
+ *
6
+ * Copyright (c) 2024 Google LLC
7
+ */
8
+ export interface Template {
9
+ parts: TemplatePart[];
10
+ tag?: string;
11
+ }
12
+ export interface TemplatePart {
13
+ end: number;
14
+ start: number;
15
+ text: string;
16
+ }
17
+ export interface Strategy<N = unknown> {
18
+ getRootNode: (source: string, fileName?: string) => N;
19
+ getTaggedTemplateTemplate: (node: N) => unknown;
20
+ getTagText: (node: N) => string;
21
+ getTemplateParts: (node: N) => TemplatePart[];
22
+ isTaggedTemplate: (node: N) => boolean;
23
+ isTemplate: (node: N) => boolean;
24
+ walkNodes: (parent: N, visit: (child: N) => void) => void;
25
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Ported from https://github.com/lit/lit/tree/main/packages/labs/rollup-plugin-minify-html-literals
3
+ *
4
+ * BSD-3-Clause License
5
+ *
6
+ * Copyright (c) 2024 Google LLC
7
+ */
8
+ import type { Strategy, Template } from "./models.d.ts";
9
+ export interface ParseLiteralsOptions {
10
+ fileName?: string;
11
+ strategy?: Partial<Strategy<unknown>>;
12
+ }
13
+ export declare const parseLiterals: (source: string, options?: ParseLiteralsOptions) => Template[];
@@ -0,0 +1,69 @@
1
+ import CleanCSS from "clean-css";
2
+ import type { MinifierOptions as HTMLOptions } from "html-minifier-next";
3
+ import type { TemplatePart } from "./models.d.ts";
4
+ /**
5
+ * A strategy on how to minify HTML and optionally CSS.
6
+ * @template O minify HTML options
7
+ * @template C minify CSS options
8
+ */
9
+ export interface Strategy<O = unknown, C = unknown> {
10
+ /**
11
+ * Combines the parts' HTML text strings together into a single string using
12
+ * the provided placeholder. The placeholder indicates where a template
13
+ * expression occurs.
14
+ * @param parts the parts to combine
15
+ * @param placeholder the placeholder to use between parts
16
+ * @returns the combined parts' text strings
17
+ */
18
+ combineHTMLStrings: (parts: TemplatePart[], placeholder: string) => string;
19
+ /**
20
+ * Retrieve a placeholder for the given array of template parts. The
21
+ * placeholder returned should be the same if the function is invoked with the
22
+ * same array of parts.
23
+ *
24
+ * The placeholder should be an HTML-compliant string that is not present in
25
+ * any of the parts' text.
26
+ * @param parts the parts to get a placeholder for
27
+ * @returns the placeholder
28
+ */
29
+ getPlaceholder: (parts: TemplatePart[]) => string;
30
+ /**
31
+ * Minifies the provided CSS string.
32
+ * @param css the css to minfiy
33
+ * @param options css minify options
34
+ * @returns minified CSS string
35
+ */
36
+ minifyCSS?: (css: string, options?: C) => string;
37
+ /**
38
+ * Minfies the provided HTML string.
39
+ * @param html the html to minify
40
+ * @param options html minify options
41
+ * @returns minified HTML string
42
+ */
43
+ minifyHTML: (html: string, options?: O) => string | Promise<string>;
44
+ /**
45
+ * Splits a minfied HTML string back into an array of strings from the
46
+ * provided placeholder. The returned array of strings should be the same
47
+ * length as the template parts that were combined to make the HTML string.
48
+ * @param html the html string to split
49
+ * @param placeholder the placeholder to split by
50
+ * @returns an array of html strings
51
+ */
52
+ splitHTMLByPlaceholder: (html: string, placeholder: string) => string[];
53
+ }
54
+ /**
55
+ * The default &lt;code>clean-css&lt;/code> options, optimized for production
56
+ * minification.
57
+ */
58
+ export declare const defaultMinifyCSSOptions: CleanCSS.Options;
59
+ /**
60
+ * The default &lt;code>html-minifier&lt;/code> options, optimized for production
61
+ * minification.
62
+ */
63
+ export declare const defaultMinifyOptions: HTMLOptions;
64
+ export declare const adjustMinifyCSSOptions: (options?: CleanCSS.Options) => CleanCSS.Options;
65
+ /**
66
+ * The default strategy. This uses &lt;code>html-minifier&lt;/code> to minify HTML and
67
+ * &lt;code>clean-css&lt;/code> to minify CSS.
68
+ */
69
+ export declare const defaultStrategy: Strategy<HTMLOptions, CleanCSS.Options>;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Ported from https://github.com/lit/lit/tree/main/packages/labs/rollup-plugin-minify-html-literals
3
+ *
4
+ * BSD-3-Clause License
5
+ *
6
+ * Copyright (c) 2024 Google LLC
7
+ */
8
+ import ts from "typescript";
9
+ import type { TemplatePart } from "./models.d.ts";
10
+ export interface TypescriptStrategy {
11
+ getHeadTemplatePart: (node: ts.TemplateLiteral | ts.TemplateHead) => TemplatePart;
12
+ getMiddleTailTemplatePart: (node: ts.TemplateMiddle | ts.TemplateTail) => TemplatePart;
13
+ getRootNode: (source: string, fileName?: string) => ts.SourceFile;
14
+ getTaggedTemplateTemplate: (node: ts.TaggedTemplateExpression) => ts.TemplateLiteral;
15
+ getTagText: (node: ts.TaggedTemplateExpression) => string;
16
+ getTemplateParts: (node: ts.TemplateLiteral) => TemplatePart[];
17
+ isTaggedTemplate: (node: ts.Node) => node is ts.TaggedTemplateExpression;
18
+ isTemplate: (node: ts.Node) => node is ts.TemplateLiteral;
19
+ walkChildNodes: (node: ts.Node, visit: (node: ts.Node) => void) => void;
20
+ walkNodes: (root: ts.SourceFile, visit: (node: ts.Node) => void) => void;
21
+ }
22
+ declare const _default: TypescriptStrategy;
23
+ export default _default;
@@ -0,0 +1,14 @@
1
+ import type { Plugin } from "rollup";
2
+ export interface NativeModulesOptions {
3
+ /**
4
+ * Custom subdirectory name for native modules within the output directory
5
+ * @default 'natives'
6
+ */
7
+ nativesDirectory?: string;
8
+ }
9
+ /**
10
+ * Handles native Node.js addons (.node files)
11
+ * - Stage 1 (resolve/load): Identifies .node files and generates runtime code.
12
+ * - Stage 2 (generateBundle): Copies the identified .node files to the output dir.
13
+ */
14
+ export declare const nativeModulesPlugin: (config?: NativeModulesOptions) => Plugin;
@@ -0,0 +1 @@
1
+ var $=Object.defineProperty;var m=(a,i)=>$(a,"name",{value:i,configurable:!0});import{copyFile as w}from"node:fs/promises";import{isAccessible as A,ensureDir as P}from"@visulima/fs";import{resolve as v,dirname as c,basename as f,extname as b,join as g}from"@visulima/path";var x=Object.defineProperty,h=m((a,i)=>x(a,"name",{value:i,configurable:!0}),"f");const d="\0natives:",B=h((a={})=>{const{nativesDirectory:i="natives"}=a,u=new Map;let n;return{buildStart(){u.clear()},generateBundle:h(async r=>{if(u.size===0)return;if(n||(r.dir?n=r.dir:r.file&&(n=c(r.file))),!n)throw new Error("Output directory not detected. Please ensure Rollup output options are configured.");const t=g(n,i);await P(t),await Promise.all(Array.from(u.entries(),([e,o])=>{const s=g(t,o);return w(e,s)}))},"generateBundle"),load(r){if(!r.startsWith(d))return;const t=r.slice(d.length),e=u.get(t);if(e||this.error(`Could not find staged native module for: ${t}`),!n){const o=this;if(o&&o.meta&&o.meta.rollupVersion)return`export default require("./${i}/${e}");`;this.error("Output directory not detected. Please ensure Rollup output options are configured.")}return`export default require("${`./${i}/${e}`.replaceAll("\\","/")}");`},name:"native-modules",options(r){const t=r;if(t.output){const e=Array.isArray(t.output)?t.output[0]:t.output;e.dir?n=e.dir:e.file&&(n=c(e.file))}return r},resolveId:{filter:{id:/\.node$/},async handler(r,t){if(r.startsWith(d))return;const e=t?v(c(t),r):v(r);if(!await A(e)){this.warn(`Native module not found: ${e}`);return}const o=f(e);let s=o,p=1;const y=new Set(Array.from(u.values(),l=>f(l)));for(;y.has(s);){const l=b(o);s=`${f(o,l)}_${p}${l}`,p+=1}return u.set(e,s),d+e}}}},"nativeModulesPlugin");export{B as nativeModulesPlugin};
@@ -1,28 +1,3 @@
1
- import { G as OxcResolveOptions, P as PailServerType, T as TransformerFn, k as IsolatedDeclarationsResult } from '../../packem_shared/types-yL82LLIx.js';
2
- export { H as InternalOXCTransformPluginConfig, K as OXCTransformPluginConfig } from '../../packem_shared/types-yL82LLIx.js';
3
- import { Plugin } from 'rollup';
4
- import { IsolatedDeclarationsOptions } from 'oxc-transform';
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 'esbuild';
17
- import '@visulima/package';
18
- import '@visulima/packem-share/types';
19
- import 'oxc-resolver';
20
- import 'sucrase';
21
-
22
- declare const oxcResolvePlugin: (options: OxcResolveOptions, rootDirectory: string, logger: PailServerType, tsconfigPath?: string) => Plugin;
23
-
24
- declare const oxcTransformPlugin: TransformerFn;
25
-
26
- declare const isolatedDeclarationsOxcTransformer: (id: string, code: string, sourceMap?: boolean, transformOptions?: Omit<IsolatedDeclarationsOptions, "sourcemap">) => IsolatedDeclarationsResult;
27
-
28
- export { OxcResolveOptions, isolatedDeclarationsOxcTransformer, oxcResolvePlugin, oxcTransformPlugin };
1
+ export { default as oxcResolvePlugin } from "./oxc-resolve-plugin.d.ts";
2
+ export { default as oxcTransformPlugin } from "./oxc-transformer-plugin.d.ts";
3
+ export type { InternalOXCTransformPluginConfig, OxcResolveOptions, OXCTransformPluginConfig } from "./types.d.ts";
@@ -0,0 +1 @@
1
+ import{default as r}from"../../packem_shared/oxcResolvePlugin-SH1JFonc.js";import{default as f}from"../../packem_shared/oxcTransformPlugin-BGmQroQ4.js";export{r as oxcResolvePlugin,f as oxcTransformPlugin};
@@ -0,0 +1,4 @@
1
+ import type { Plugin } from "rollup";
2
+ import type { OxcResolveOptions } from "./types.d.ts";
3
+ declare const oxcResolvePlugin: (options: OxcResolveOptions, rootDirectory: string, logger: Console, tsconfigPath?: string) => Plugin;
4
+ export default oxcResolvePlugin;
@@ -0,0 +1,3 @@
1
+ import type { TransformerFn as TransformerFunction } from "../../types.d.ts";
2
+ declare const oxcTransformPlugin: TransformerFunction;
3
+ export default oxcTransformPlugin;
@@ -0,0 +1,16 @@
1
+ import type { FilterPattern } from "@rollup/pluginutils";
2
+ import type { NapiResolveOptions } from "oxc-resolver";
3
+ import type { JsxOptions, TransformOptions } from "oxc-transform";
4
+ export type InternalOXCTransformPluginConfig = TransformOptions & {
5
+ exclude?: FilterPattern;
6
+ include?: FilterPattern;
7
+ };
8
+ export type OXCTransformPluginConfig = Omit<TransformOptions, "cwd" | "sourcemap" | "target" | "typescript"> & {
9
+ exclude?: FilterPattern;
10
+ include?: FilterPattern;
11
+ /** Configure how TSX and JSX are transformed. */
12
+ jsx?: Omit<JsxOptions, "refresh"> | "preserve";
13
+ };
14
+ export type OxcResolveOptions = Omit<NapiResolveOptions, "tsconfig"> & {
15
+ ignoreSideEffectsForRoot?: boolean;
16
+ };
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Modified copy of https://github.com/huozhi/rollup-preserve-directives/blob/main/src/index.ts
3
+ *
4
+ * The MIT License (MIT)
5
+ *
6
+ * Copyright (c) 2018 these people -> https://github.com/huozhi/rollup-preserve-directives/graphs/contributors
7
+ */
8
+ import type { FilterPattern } from "@rollup/pluginutils";
9
+ import type { Plugin } from "rollup";
10
+ export type PreserveDirectivesPluginOptions = {
11
+ directiveRegex: RegExp;
12
+ exclude?: FilterPattern;
13
+ include?: FilterPattern;
14
+ logger: Console;
15
+ };
16
+ export declare const preserveDirectivesPlugin: ({ directiveRegex, exclude, include, logger }: PreserveDirectivesPluginOptions) => Plugin;
@@ -1,4 +1,4 @@
1
- var b=Object.defineProperty;var v=(a,d)=>b(a,"name",{value:d,configurable:!0});import{createFilter as x}from"@rollup/pluginutils";import g from"magic-string";var y=Object.defineProperty,$=v((a,d)=>y(a,"name",{value:d,configurable:!0}),"c");const S=$(({directiveRegex:a,exclude:d=[],include:m=[],logger:p})=>{const u={},f={},h=x(m,d);return{name:"packem:preserve-directives",onLog(i,t){if(t.code==="MODULE_LEVEL_DIRECTIVE"&&i==="warn")return!1},renderChunk:{handler(i,t,{sourcemap:c}){const s=t.moduleIds.map(r=>{if(u[r])return u[r]}).reduce((r,l)=>(l&&l.forEach(o=>{r.add(o)}),r),new Set),n=new g(i);s.size>0&&(p.debug({message:`directives for chunk "${t.fileName}" are preserved.`,prefix:"plugin:preserve-directives"}),n.prepend(`${[...s].map(r=>`'${r}';`).join(`
1
+ var b=Object.defineProperty;var v=(d,o)=>b(d,"name",{value:o,configurable:!0});import{createFilter as x}from"@rollup/pluginutils";import g from"magic-string";var y=Object.defineProperty,$=v((d,o)=>y(d,"name",{value:o,configurable:!0}),"l");const S=$(({directiveRegex:d,exclude:o=[],include:m=[],logger:p})=>{const u={},f={},h=x(m,o);return{name:"packem:preserve-directives",onLog(i,t){if(t.code==="MODULE_LEVEL_DIRECTIVE"&&i==="warn")return!1},renderChunk:{handler(i,t,{sourcemap:c}){const s=t.moduleIds.map(r=>{if(u[r])return u[r]}).reduce((r,l)=>(l&&l.forEach(a=>{r.add(a)}),r),new Set),n=new g(i);s.size>0&&(p.debug({message:`directives for chunk "${t.fileName}" are preserved.`,prefix:"plugin:preserve-directives"}),n.prepend(`${Array.from(s,r=>`'${r}';`).join(`
2
2
  `)}
3
3
  `));let e;if(t.facadeModuleId&&typeof f[t.facadeModuleId]=="string"&&(e=f[t.facadeModuleId]),e&&(p.debug({message:`shebang for chunk "${t.fileName}" is preserved.`,prefix:"plugin:preserve-directives"}),n.prepend(`${e}
4
- `)),!(s.size===0&&e===void 0))return{code:n.toString(),map:c?n.generateMap({hires:!0}):void 0}},order:"post"},transform(i,t){if(!h(t))return;let c=!1;const s=new g(i);if(i.startsWith("#")&&i[1]==="!"){let e=0;for(let r=2,l=i.length;r<l;r++){const o=i.codePointAt(r);if(o===10||o===13||o===8232||o===8233){e=r;break}}e&&(f[t]=i.slice(0,e),s.remove(0,e+1),c=!0,p.debug({message:`shebang for module "${t}" is preserved.`,prefix:"plugin:preserve-directives"}))}let n;try{n=this.parse(s.toString(),{allowReturnOutsideFunction:!0})}catch(e){this.warn({code:"PARSE_ERROR",message:`failed to parse "${t}" and extract the directives.`}),p.warn(e);return}if(n.type==="Program"){for(const e of n.body.filter(Boolean)){if(e.type!=="ExpressionStatement")break;let r;"directive"in e?r=e.directive:e.expression.type==="Literal"&&typeof e.expression.value=="string"&&a.test(e.expression.value)&&(r=e.expression.value),r!=="use strict"&&r&&(u[t]||=new Set,u[t].add(r),"start"in e&&typeof e.start=="number"&&"end"in e&&typeof e.end=="number"&&(s.remove(e.start,e.end),c=!0),p.debug({message:`directive "${r}" for module "${t}" is preserved.`,prefix:"plugin:preserve-directives"}))}if(c)return{code:s.toString(),map:s.generateMap({hires:!0}),meta:{preserveDirectives:{directives:[...u[t]??[]],shebang:f[t]??void 0}}}}}}},"preserveDirectives");export{S as default};
4
+ `)),!(s.size===0&&e===void 0))return{code:n.toString(),map:c?n.generateMap({hires:!0}):void 0}},order:"post"},transform(i,t){if(!h(t))return;let c=!1;const s=new g(i);if(i.startsWith("#")&&i[1]==="!"){let e=0;for(let r=2,l=i.length;r<l;r++){const a=i.codePointAt(r);if(a===10||a===13||a===8232||a===8233){e=r;break}}e&&(f[t]=i.slice(0,e),s.remove(0,e+1),c=!0,p.debug({message:`shebang for module "${t}" is preserved.`,prefix:"plugin:preserve-directives"}))}let n;try{n=this.parse(s.toString(),{allowReturnOutsideFunction:!0})}catch(e){this.warn({code:"PARSE_ERROR",message:`failed to parse "${t}" and extract the directives.`}),p.warn(e);return}if(n.type==="Program"){for(const e of n.body.filter(Boolean)){if(e.type!=="ExpressionStatement")break;let r;"directive"in e?r=e.directive:e.expression.type==="Literal"&&typeof e.expression.value=="string"&&d.test(e.expression.value)&&(r=e.expression.value),r!=="use strict"&&r&&(u[t]||=new Set,u[t].add(r),"start"in e&&typeof e.start=="number"&&"end"in e&&typeof e.end=="number"&&(s.remove(e.start,e.end),c=!0),p.debug({message:`directive "${r}" for module "${t}" is preserved.`,prefix:"plugin:preserve-directives"}))}if(c)return{code:s.toString(),map:s.generateMap({hires:!0}),meta:{preserveDirectives:{directives:[...u[t]??[]],shebang:f[t]??void 0}}}}}}},"preserveDirectivesPlugin");export{S as preserveDirectivesPlugin};
@@ -0,0 +1,11 @@
1
+ import type { Plugin } from "rollup";
2
+ /**
3
+ * A Rollup plugin that adds `/*@__PURE__*\/` annotations before `new Constructor(...)` expressions
4
+ * for a given list of constructor names. This allows tree-shaking of unused instantiations.
5
+ *
6
+ * `rollup-plugin-pure` only handles `CallExpression` nodes; this plugin handles `NewExpression`.
7
+ */
8
+ export declare const pureNewExpressionPlugin: (options: {
9
+ constructors: string[];
10
+ sourcemap?: boolean;
11
+ }) => Plugin;
@@ -0,0 +1,7 @@
1
+ import type { FilterPattern } from "@rollup/pluginutils";
2
+ import type { Plugin } from "rollup";
3
+ export interface RawLoaderOptions {
4
+ exclude?: FilterPattern;
5
+ include?: FilterPattern;
6
+ }
7
+ export declare const rawPlugin: (options: RawLoaderOptions) => Plugin;
@@ -0,0 +1,6 @@
1
+ var i=Object.defineProperty;var n=(r,a)=>i(r,"name",{value:a,configurable:!0});import{createFilter as s}from"@rollup/pluginutils";import{readFile as u}from"@visulima/fs";var p=Object.defineProperty,d=n((r,a)=>p(r,"name",{value:a,configurable:!0}),"a");const g=d(r=>{const a=s(r.include,r.exclude);return{async load(t){if(t.includes("?raw")){const e=t.split("?")[0];try{const l=await u(e);return process.platform==="win32"?l.replaceAll(`\r
2
+ `,`
3
+ `):l}catch{this.error(`Failed to read file: ${e}`)}}return null},name:"packem:raw",transform(t,e){const l=e.includes("?raw"),o=l?e.split("?")[0]:e;if(a(o)||l){const c=process.platform==="win32"?t.replaceAll(`\r
4
+ `,`
5
+ `):t;return{code:`const data = ${JSON.stringify(c)};
6
+ export default data;`,map:null}}return null}}},"rawPlugin");export{g as rawPlugin};
@@ -0,0 +1,43 @@
1
+ import type { FilterPattern } from "@rollup/pluginutils";
2
+ import type { Plugin, ResolvedId } from "rollup";
3
+ type Awaitable<T> = T | Promise<T>;
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
+ */
30
+ builtinNodeModules?: boolean;
31
+ cwd?: string;
32
+ exclude?: FilterPattern;
33
+ include?: FilterPattern;
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
+ */
40
+ shouldTransform?: string[] | TransformFunction;
41
+ }
42
+ export declare const requireCJSTransformerPlugin: (userOptions: Options, _logger: Console) => Plugin;
43
+ export {};
@@ -0,0 +1,21 @@
1
+ var E=Object.defineProperty;var w=(e,r)=>E(e,"name",{value:r,configurable:!0});import{createRequire as F,builtinModules as K}from"node:module";import B from"node:process";import{createFilter as L}from"@rollup/pluginutils";import{init as x,parse as G}from"cjs-module-lexer";import S from"magic-string";import{parseSync as H}from"oxc-parser";import{readFile as Q}from"@visulima/fs";import{findPackageJson as U}from"@visulima/package/package-json";var V=Object.defineProperty,X=w((e,r)=>V(e,"name",{value:r,configurable:!0}),"s");const Y=X(async(e,r,i)=>{if(await x(),e.startsWith("node:"))return!1;if(e.endsWith(".cjs"))return!0;if(e.endsWith(".js")||!e.includes("/")&&!e.startsWith(".")){let s;if(i)try{s=(await i(e,r))?.id}catch{}if(!s&&r&&!r.includes("!~{"))try{s=F(r).resolve(e)}catch{}if(s){try{const{packageJson:o}=await U(s);if(o.type==="module")return!1;if(o.type==="commonjs")return!0}catch{}try{const o=await Q(s,{encoding:"utf8"});try{return G(o,s),!0}catch{}}catch{}}}return!1},"isPureCJS");var Z=Object.defineProperty,m=w((e,r)=>Z(e,"name",{value:r,configurable:!0}),"c");const T="__cjs_require",z='import { createRequire as __cjs_createRequire } from "node:module";',ee=`const ${T} = __cjs_createRequire(import.meta.url);`,re='const __cjs_getProcess = typeof globalThis !== "undefined" && typeof globalThis.process !== "undefined" ? globalThis.process : process;',se=`const __cjs_getBuiltinModule = (module) => {
2
+ // Check if we're in Node.js and version supports getBuiltinModule
3
+ if (typeof __cjs_getProcess !== "undefined" && __cjs_getProcess.versions && __cjs_getProcess.versions.node) {
4
+ const [major, minor] = __cjs_getProcess.versions.node.split(".").map(Number);
5
+ // Node.js 20.16.0+ and 22.3.0+
6
+ if (major > 22 || (major === 22 && minor >= 3) || (major === 20 && minor >= 16)) {
7
+ return __cjs_getProcess.getBuiltinModule(module);
8
+ }
9
+ }
10
+ // Fallback to createRequire
11
+ return ${T}(module);
12
+ };`,g={builtin:/const\s+__cjs_getBuiltinModule\s*=\s*\(module\)\s*=>\s*\{[\s\S]*?\};\s*/g,import:/import\s*\{\s*createRequire(?:\s+as\s+__cjs_createRequire)?\s*\}\s*from\s*["']node:module["'];?\s*/g,process:/const\s+__cjs_getProcess\s*=\s*typeof\s+globalThis[^;]*;\s*/g,require:/const\s+__cjs_require\s*=\s*(?:__cjs_)?createRequire\s*\([^)]*\);\s*/g};let R=!1;const te=m((e,r)=>r&&(K.includes(e)||e.startsWith("node:")),"isBuiltinModule"),oe=m(async(e,r,i,s,o)=>{if(r)return!0;const c=await i?.(e,s,o);return c===void 0?await Y(e,s,o):c},"shouldTransformImport"),ne=m((e,r)=>r?e==="process"||e==="node:process"?{code:"__cjs_getProcess",needsBuiltin:!1,needsProcess:!0,needsRequire:!0}:{code:`__cjs_getBuiltinModule(${JSON.stringify(e)})`,needsBuiltin:!0,needsProcess:!0,needsRequire:!0}:{code:`${T}(${JSON.stringify(e)})`,needsBuiltin:!1,needsProcess:!1,needsRequire:!0},"generateRequireCode"),ie=m(e=>{const r=new S(e),i={builtin:[...e.matchAll(g.builtin)],import:[...e.matchAll(g.import)],process:[...e.matchAll(g.process)],require:[...e.matchAll(g.require)]};return Object.values(i).forEach(s=>{if(s.length>1)for(let o=s.length-1;o>0;o-=1){const c=s[o];c&&r.remove(c.index,c.index+c[0].length)}}),r.toString()},"removeDuplicates"),ce=m(e=>{if(Array.isArray(e.shouldTransform)){const{shouldTransform:r}=e;e.shouldTransform=i=>r.includes(i)}return{builtinNodeModules:!!e.builtinNodeModules,cwd:e.cwd||B.cwd(),exclude:e.exclude||[/node_modules/,/\.d\.[cm]?ts$/],include:e.include||[/\.[cm]?[jt]sx?$/],order:"order"in e?e.order:"pre",shouldTransform:e.shouldTransform}},"resolveOptions"),he=m((e,r)=>{if(B.env.INTERNAL_PACKEM_BUILD)return{name:"require-cjs-transformer"};const{builtinNodeModules:i,cwd:s,exclude:o,include:c,order:A,shouldTransform:C}=ce(e),J=L(c,o);return{async buildStart(){R||(await x(),R=!0)},name:"packem:plugin-require-cjs",renderChunk:{async handler(h,M,O){if(O.format!=="es"||!J(M.fileName))return;const I=H(M.fileName,h,{astType:"js",lang:"js",sourceType:"module"}),u=new S(h);let j=!1,y=!1,v=!1;for await(const t of I.program.body){if(t.type!=="ImportDeclaration"||t.importKind==="type")continue;const l=t.source.value,d=te(l,i),$=this.resolve;if(!await oe(l,d,C,s,$))continue;const{code:b,needsBuiltin:k,needsProcess:W,needsRequire:D}=ne(l,d);if(j||=D,y||=W,v||=k,t.specifiers.length===0){d?u.remove(t.start,t.end):u.overwrite(t.start,t.end,`${b};`);continue}const P=[];let f,a;for(const n of t.specifiers)if(n.type==="ImportNamespaceSpecifier")f=n.local.name;else if(n.type==="ImportSpecifier"&&n.importKind!=="type"){const _=h.slice(n.imported.start,n.imported.end);P.push([_,n.local.name])}else n.type==="ImportDefaultSpecifier"&&(a=n.local.name);const p=[];if(f&&(a||=`_cjs_${f}_default`),a&&p.push(`const ${a} = ${b};`),f&&p.push(`const ${f} = { ...${a}, default: ${a} };`),P.length>0){const n=`const {
13
+ ${P.map(([_,q])=>` ${_===q?q:`${_}: ${q}`}`).join(`,
14
+ `)}
15
+ } = ${a||b};`;p.push(n)}u.overwrite(t.start,t.end,p.join(`
16
+ `))}if(j||y||v){const t=[];j&&t.push(z,ee),y&&t.push(re),v&&t.push(se);const l=`${t.join(`
17
+
18
+ `)}
19
+
20
+ `,d=u.toString();if(d[0]==="#"){const $=d.indexOf(`
21
+ `)+1;u.appendLeft($,l)}else u.prepend(l)}const N=new S(ie(u.toString()));return{code:N.toString(),map:N.generateMap()}},order:A}}},"requireCJSTransformerPlugin");export{he as requireCJSTransformerPlugin};
@@ -0,0 +1,3 @@
1
+ import type { Plugin } from "rollup";
2
+ declare const resolveFileUrl: () => Plugin;
3
+ export default resolveFileUrl;
@@ -0,0 +1,9 @@
1
+ import type { Plugin } from "rollup";
2
+ export type ShebangOptions = {
3
+ replace: boolean;
4
+ shebang: string;
5
+ };
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;
@@ -0,0 +1,7 @@
1
+ import type { FilterPattern } from "@rollup/pluginutils";
2
+ import type { Plugin } from "rollup";
3
+ export interface SourcemapsPluginOptions {
4
+ exclude?: FilterPattern;
5
+ include?: FilterPattern;
6
+ }
7
+ export declare const sourcemapsPlugin: ({ exclude, include }?: SourcemapsPluginOptions) => Plugin;
@@ -1,19 +1,8 @@
1
- import '@rollup/pluginutils';
2
- import 'sucrase';
3
- export { M as SucrasePluginConfig, N as sucrasePlugin } from '../../packem_shared/types-yL82LLIx.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 'esbuild';
16
- import '@visulima/package';
17
- import '@visulima/packem-share/types';
18
- import 'oxc-resolver';
19
- import 'oxc-transform';
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,26 +1,2 @@
1
- import { T as TransformerFn, k as IsolatedDeclarationsResult } from '../../packem_shared/types-yL82LLIx.js';
2
- export { y as SwcPluginConfig } from '../../packem_shared/types-yL82LLIx.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 'esbuild';
16
- import '@visulima/package';
17
- import '@visulima/packem-share/types';
18
- import 'oxc-resolver';
19
- import 'oxc-transform';
20
- import 'sucrase';
21
-
22
- declare const _default: TransformerFn;
23
-
24
- declare const isolatedDeclarationsSwcTransformer: (id: string, code: string, sourceMap?: boolean) => Promise<IsolatedDeclarationsResult>;
25
-
26
- export { isolatedDeclarationsSwcTransformer, _default as swcPlugin };
1
+ export { default as swcPlugin } from "./swc-plugin.d.ts";
2
+ export type * from "./types.d.ts";
@@ -0,0 +1 @@
1
+ import{default as f}from"../../packem_shared/swcPlugin-Boip4lWG.js";export{f as swcPlugin};