@visulima/packem-rollup 1.0.0-alpha.71 → 1.0.0-alpha.73
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 +38 -0
- package/README.md +81 -51
- package/dist/index.d.ts +17 -37
- package/dist/packem_shared/esbuildPlugin-D_vSjXWg.js +1 -0
- package/dist/packem_shared/swcPlugin-BdHPQBN4.js +1 -0
- package/dist/packem_shared/{types.d-Dmpk2asd.d.ts → types.d-DukC_8rF.d.ts} +1 -1
- package/dist/plugins/chunk-splitter/index.js +1 -1
- package/dist/plugins/cjs-interop.js +2 -2
- package/dist/plugins/esbuild/index.js +1 -1
- package/dist/plugins/json.js +1 -1
- package/dist/plugins/jsx-remove-attributes.d.ts +17 -1
- package/dist/plugins/jsx-remove-attributes.js +1 -1
- package/dist/plugins/preserve-directives.js +4 -3
- package/dist/plugins/pure-new-expression-plugin.d.ts +13 -3
- package/dist/plugins/pure-new-expression-plugin.js +1 -1
- package/dist/plugins/sucrase/index.js +1 -1
- package/dist/plugins/swc/index.d.ts +1 -1
- package/dist/plugins/swc/index.js +1 -1
- package/package.json +6 -3
- package/dist/packem_shared/esbuildPlugin-BStpbA6S.js +0 -1
- package/dist/packem_shared/swcPlugin-DBBN5mct.js +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,41 @@
|
|
|
1
|
+
## @visulima/packem-rollup [1.0.0-alpha.73](https://github.com/visulima/packem/compare/@visulima/packem-rollup@1.0.0-alpha.72...@visulima/packem-rollup@1.0.0-alpha.73) (2026-06-12)
|
|
2
|
+
|
|
3
|
+
### Features
|
|
4
|
+
|
|
5
|
+
* **packem:** run preserve-directives/jsx/pure plugins under rolldown + native rolldown watch ([3087190](https://github.com/visulima/packem/commit/3087190f011f85e881c7a2dc5b0579360741ac67))
|
|
6
|
+
|
|
7
|
+
### Bug Fixes
|
|
8
|
+
|
|
9
|
+
* **packem-rollup:** handle first-position attribute in jsx-remove-attributes ([5b36f50](https://github.com/visulima/packem/commit/5b36f504c4548cf2f85e6293cb0cbb94dc01d769))
|
|
10
|
+
* **packem:** enable chunk-per-export splitting under rolldown ([8eb4e67](https://github.com/visulima/packem/commit/8eb4e679ed044487d3d1c1a86956ca5ee856501b))
|
|
11
|
+
* resolve package audit findings across the monorepo ([2800d68](https://github.com/visulima/packem/commit/2800d68c00de2ff488b51ad90179731b929b9642))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Dependencies
|
|
15
|
+
|
|
16
|
+
* **@visulima/packem-share:** upgraded to 1.0.0-alpha.50
|
|
17
|
+
* **@visulima/rollup-plugin-dts:** upgraded to 1.0.0-alpha.34
|
|
18
|
+
|
|
19
|
+
## @visulima/packem-rollup [1.0.0-alpha.72](https://github.com/visulima/packem/compare/@visulima/packem-rollup@1.0.0-alpha.71...@visulima/packem-rollup@1.0.0-alpha.72) (2026-06-04)
|
|
20
|
+
|
|
21
|
+
### Bug Fixes
|
|
22
|
+
|
|
23
|
+
* **packem-rollup:** shared-loader mutation, chunk-splitter recursion/sourcemap fixes, parse perf + bench ([7a90c64](https://github.com/visulima/packem/commit/7a90c6400bd6aee9a3225a9479b53fa5ffcda89b))
|
|
24
|
+
|
|
25
|
+
### Styles
|
|
26
|
+
|
|
27
|
+
* clear eslint debt from the audit/types passes ([fd68951](https://github.com/visulima/packem/commit/fd68951681817078ae579dcad10963b1a07c1d27))
|
|
28
|
+
|
|
29
|
+
### Code Refactoring
|
|
30
|
+
|
|
31
|
+
* **packem-rollup:** tighten internal TypeScript types ([c381f84](https://github.com/visulima/packem/commit/c381f84b62f250426e962126c87663bdd3001c48))
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
### Dependencies
|
|
35
|
+
|
|
36
|
+
* **@visulima/packem-share:** upgraded to 1.0.0-alpha.49
|
|
37
|
+
* **@visulima/rollup-plugin-dts:** upgraded to 1.0.0-alpha.33
|
|
38
|
+
|
|
1
39
|
## @visulima/packem-rollup [1.0.0-alpha.71](https://github.com/visulima/packem/compare/@visulima/packem-rollup@1.0.0-alpha.70...@visulima/packem-rollup@1.0.0-alpha.71) (2026-06-03)
|
|
2
40
|
|
|
3
41
|
### Bug Fixes
|
package/README.md
CHANGED
|
@@ -41,93 +41,123 @@ pnpm add @visulima/packem-rollup
|
|
|
41
41
|
|
|
42
42
|
## Usage
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
This package bundles the Rollup plugins that power packem. They are also reused as
|
|
45
|
+
the rolldown `renderChunk` ports, so the directive/JSX/pure passes behave the same
|
|
46
|
+
under both bundlers. The plugins are exported from the package root and from
|
|
47
|
+
per-plugin subpath entries.
|
|
45
48
|
|
|
46
|
-
|
|
49
|
+
### Preserve Directives
|
|
50
|
+
|
|
51
|
+
`preserveDirectivesPlugin` hoists module-level directives (`"use client"`,
|
|
52
|
+
`"use server"`, …) and shebangs to the top of the emitted chunk.
|
|
47
53
|
|
|
48
54
|
```typescript
|
|
49
|
-
import {
|
|
55
|
+
import { preserveDirectivesPlugin } from "@visulima/packem-rollup";
|
|
50
56
|
|
|
51
57
|
export default {
|
|
52
|
-
plugins: [
|
|
58
|
+
plugins: [
|
|
59
|
+
preserveDirectivesPlugin({
|
|
60
|
+
directiveRegex: /^use (client|server)$/,
|
|
61
|
+
logger: console,
|
|
62
|
+
}),
|
|
63
|
+
],
|
|
53
64
|
};
|
|
54
65
|
```
|
|
55
66
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
- `?data-uri` - Basic data URI conversion
|
|
59
|
-
- `?data-uri&encoding=css` - Use CSS-optimized SVG encoding
|
|
60
|
-
- `?data-uri&encoding=tiny` - Use tiny SVG encoding (default)
|
|
61
|
-
- `?data-uri&srcset` - Encode spaces as %20 for srcset compatibility
|
|
67
|
+
### CJS Interop
|
|
62
68
|
|
|
63
|
-
|
|
69
|
+
`cjsInteropPlugin` rewrites the entry chunk's `exports.default` /
|
|
70
|
+
`exports.<name>` assignments to `module.exports` for `format: "cjs"` +
|
|
71
|
+
`exports: "auto"` output, so `require()` returns the default export directly.
|
|
64
72
|
|
|
65
73
|
```typescript
|
|
66
|
-
|
|
67
|
-
|
|
74
|
+
import { cjsInteropPlugin } from "@visulima/packem-rollup/plugin/cjs-interop";
|
|
75
|
+
|
|
76
|
+
export default {
|
|
77
|
+
plugins: [cjsInteropPlugin({ addDefaultProperty: false, logger: console })],
|
|
78
|
+
};
|
|
79
|
+
```
|
|
68
80
|
|
|
69
|
-
|
|
70
|
-
import icon from "./icon.svg?data-uri&encoding=css";
|
|
81
|
+
### JSX Remove Attributes
|
|
71
82
|
|
|
72
|
-
|
|
73
|
-
|
|
83
|
+
`jsxRemoveAttributes` strips configured attributes (e.g. `data-testid`) from
|
|
84
|
+
automatic-runtime JSX calls (`jsx`/`jsxs`/`jsxDEV`).
|
|
74
85
|
|
|
75
|
-
|
|
76
|
-
import
|
|
86
|
+
```typescript
|
|
87
|
+
import { jsxRemoveAttributes } from "@visulima/packem-rollup";
|
|
88
|
+
|
|
89
|
+
export default {
|
|
90
|
+
plugins: [jsxRemoveAttributes({ attributes: ["data-testid"], logger: console })],
|
|
91
|
+
};
|
|
77
92
|
```
|
|
78
93
|
|
|
79
|
-
###
|
|
94
|
+
### Pure New Expression
|
|
80
95
|
|
|
81
|
-
|
|
96
|
+
`pureNewExpressionPlugin` adds `/* @__PURE__ */` annotations to configured
|
|
97
|
+
constructor instantiations (and, in `renderChunk` mode, function calls) so
|
|
98
|
+
consumers can tree-shake them.
|
|
82
99
|
|
|
83
100
|
```typescript
|
|
84
|
-
import {
|
|
101
|
+
import { pureNewExpressionPlugin } from "@visulima/packem-rollup";
|
|
85
102
|
|
|
86
103
|
export default {
|
|
87
|
-
plugins: [
|
|
88
|
-
lazyBarrelPlugin({
|
|
89
|
-
sideEffectsCheck: true,
|
|
90
|
-
lazyThreshold: 2,
|
|
91
|
-
include: [/\.ts$/, /\.js$/],
|
|
92
|
-
exclude: [/\.test\.ts$/],
|
|
93
|
-
}),
|
|
94
|
-
],
|
|
104
|
+
plugins: [pureNewExpressionPlugin({ constructors: ["WeakMap", "Map"] })],
|
|
95
105
|
};
|
|
96
106
|
```
|
|
97
107
|
|
|
98
|
-
|
|
108
|
+
### Chunk Splitter
|
|
99
109
|
|
|
100
|
-
|
|
101
|
-
- **Side Effects Checking**: Reads package.json to check `sideEffects` field
|
|
102
|
-
- **Lazy Loading**: Generates lazy loading code for unused exports
|
|
103
|
-
- **Configurable Threshold**: Set minimum exports to consider a file as a barrel
|
|
104
|
-
- **Filtering**: Include/exclude specific file patterns
|
|
110
|
+
`chunkSplitter` controls how shared code is split into chunks.
|
|
105
111
|
|
|
106
|
-
|
|
112
|
+
```typescript
|
|
113
|
+
import { chunkSplitter } from "@visulima/packem-rollup";
|
|
107
114
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
5. **Optimization**: Only builds modules when their exports are actually requested
|
|
115
|
+
export default {
|
|
116
|
+
plugins: [chunkSplitter()],
|
|
117
|
+
};
|
|
118
|
+
```
|
|
113
119
|
|
|
114
|
-
###
|
|
120
|
+
### JSON
|
|
115
121
|
|
|
116
|
-
|
|
122
|
+
`JsonPlugin` wraps `@rollup/plugin-json` and rewrites the emitted
|
|
123
|
+
`export default <json>` to `module.exports = <json>` for CJS interop.
|
|
117
124
|
|
|
118
125
|
```typescript
|
|
119
|
-
import {
|
|
126
|
+
import { JsonPlugin } from "@visulima/packem-rollup/plugin/json";
|
|
120
127
|
|
|
121
128
|
export default {
|
|
122
|
-
plugins: [
|
|
123
|
-
urlPlugin({
|
|
124
|
-
limit: 14336, // 14kb
|
|
125
|
-
fileName: "[hash][extname]",
|
|
126
|
-
}),
|
|
127
|
-
],
|
|
129
|
+
plugins: [JsonPlugin({})],
|
|
128
130
|
};
|
|
129
131
|
```
|
|
130
132
|
|
|
133
|
+
### Transformer adapters (esbuild / swc / sucrase)
|
|
134
|
+
|
|
135
|
+
The TypeScript/JSX transformer adapters are exported from dedicated subpaths.
|
|
136
|
+
|
|
137
|
+
```typescript
|
|
138
|
+
import esbuildTransformer from "@visulima/packem-rollup/esbuild";
|
|
139
|
+
import swcPlugin from "@visulima/packem-rollup/swc";
|
|
140
|
+
import { sucrasePlugin } from "@visulima/packem-rollup/sucrase";
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
`browserslistToEsbuild` (root export) converts a Browserslist query into esbuild
|
|
144
|
+
`target` strings:
|
|
145
|
+
|
|
146
|
+
```typescript
|
|
147
|
+
import { browserslistToEsbuild } from "@visulima/packem-rollup";
|
|
148
|
+
|
|
149
|
+
const target = browserslistToEsbuild(["chrome 100", "ios_saf 15"]);
|
|
150
|
+
// → ["chrome100", "ios15"]
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### Re-exported Rollup plugins
|
|
154
|
+
|
|
155
|
+
For convenience the package also re-exports a curated set of upstream Rollup
|
|
156
|
+
plugins under their conventional names: `alias`, `commonjs`, `dynamicImportVars`
|
|
157
|
+
(with `RollupDynamicImportVariablesOptions`), `inject`, `replace`, `wasm`,
|
|
158
|
+
`polyfillNode`, `purePlugin`, `visualizer`, and `importTrace`. See
|
|
159
|
+
[`src/index.ts`](./src/index.ts) for the full export surface.
|
|
160
|
+
|
|
131
161
|
## Related
|
|
132
162
|
|
|
133
163
|
## Supported Node.js Versions
|
package/dist/index.d.ts
CHANGED
|
@@ -9,6 +9,8 @@ import { RollupAliasOptions } from '@rollup/plugin-alias';
|
|
|
9
9
|
export { type Alias, type ResolverObject as AliasResolverObject, type ResolvedAlias, type RollupAliasOptions, default as alias } from '@rollup/plugin-alias';
|
|
10
10
|
import { RollupCommonJSOptions } from '@rollup/plugin-commonjs';
|
|
11
11
|
export { type RollupCommonJSOptions, default as commonjs } from '@rollup/plugin-commonjs';
|
|
12
|
+
import { RollupDynamicImportVariablesOptions } from '@rollup/plugin-dynamic-import-vars';
|
|
13
|
+
export { type RollupDynamicImportVariablesOptions, default as dynamicImportVars } from '@rollup/plugin-dynamic-import-vars';
|
|
12
14
|
import { RollupJsonOptions } from '@rollup/plugin-json';
|
|
13
15
|
import { RollupReplaceOptions } from '@rollup/plugin-replace';
|
|
14
16
|
export { type RollupReplaceOptions, default as replace } from '@rollup/plugin-replace';
|
|
@@ -33,8 +35,7 @@ import { PluginVisualizerOptions } from 'rollup-plugin-visualizer';
|
|
|
33
35
|
export { type PluginVisualizerOptions as RollupPluginVisualizerOptions, default as visualizer } from 'rollup-plugin-visualizer';
|
|
34
36
|
import { CJSInteropOptions } from "./plugins/cjs-interop.js";
|
|
35
37
|
import { SucrasePluginConfig } from "./plugins/sucrase/index.js";
|
|
36
|
-
import { S as SwcPluginConfig } from "./packem_shared/types.d-
|
|
37
|
-
export { type RollupDynamicImportVariablesOptions, default as dynamicImportVars } from '@rollup/plugin-dynamic-import-vars';
|
|
38
|
+
import { S as SwcPluginConfig } from "./packem_shared/types.d-DukC_8rF.js";
|
|
38
39
|
export { type RollupInjectOptions, default as inject } from '@rollup/plugin-inject';
|
|
39
40
|
export { importTrace, patchErrorWithTrace } from 'rollup-plugin-import-trace';
|
|
40
41
|
import '@visulima/packem-share/utils';
|
|
@@ -45,6 +46,12 @@ interface BabelPluginConfig extends Omit<TransformOptions, "exclude" | "filename
|
|
|
45
46
|
filename?: string;
|
|
46
47
|
include?: FilterPattern;
|
|
47
48
|
/**
|
|
49
|
+
* Optional logger used to surface diagnostics — e.g. why parallel mode fell back
|
|
50
|
+
* to in-process transforms (non-serializable option, missing worker script). When
|
|
51
|
+
* omitted, fallbacks happen silently (preserving prior behaviour).
|
|
52
|
+
*/
|
|
53
|
+
logger?: Pick<Console, "debug" | "warn">;
|
|
54
|
+
/**
|
|
48
55
|
* Run Babel transforms in parallel across a worker pool.
|
|
49
56
|
* `false` always transforms in-process; `true`/`undefined` auto-enables workers
|
|
50
57
|
* once the build crosses `parallelThreshold` matched files (so small builds never
|
|
@@ -79,13 +86,13 @@ type MultipleTargetsDesc = SingleTargetDesc | SingleTargetDesc[] | string[] | st
|
|
|
79
86
|
type CopyPluginOptions = {
|
|
80
87
|
/**
|
|
81
88
|
* Copy items once. Useful in watch mode.
|
|
82
|
-
* @default
|
|
89
|
+
* @default true
|
|
83
90
|
*/
|
|
84
91
|
copyOnce?: boolean;
|
|
85
92
|
exactFileNames?: boolean;
|
|
86
93
|
/**
|
|
87
94
|
* Remove the directory structure of copied files.
|
|
88
|
-
* @default
|
|
95
|
+
* @default false
|
|
89
96
|
*/
|
|
90
97
|
flatten?: boolean;
|
|
91
98
|
targets: MultipleTargetsDesc;
|
|
@@ -101,16 +108,16 @@ type DataUriPluginOptions = {
|
|
|
101
108
|
* Supported query parameters:
|
|
102
109
|
*
|
|
103
110
|
* - `?data-uri` - Basic data URI conversion.
|
|
104
|
-
* - `?data-uri
|
|
105
|
-
* - `?data-uri
|
|
106
|
-
* - `?data-uri
|
|
111
|
+
* - `?data-uri&encoding=css` - Use CSS-optimized SVG encoding.
|
|
112
|
+
* - `?data-uri&encoding=tiny` - Use tiny SVG encoding (default).
|
|
113
|
+
* - `?data-uri&srcset` - Encode spaces as %20 for srcset compatibility.
|
|
107
114
|
*
|
|
108
115
|
* Examples:
|
|
109
116
|
*
|
|
110
117
|
* - `./icon.svg?data-uri` - Tiny SVG encoding.
|
|
111
|
-
* - `./icon.svg?data-uri
|
|
112
|
-
* - `./icon.svg?data-uri
|
|
113
|
-
* - `./icon.svg?data-uri
|
|
118
|
+
* - `./icon.svg?data-uri&encoding=css` - CSS-optimized SVG encoding.
|
|
119
|
+
* - `./icon.svg?data-uri&srcset` - Tiny SVG with srcset compatibility.
|
|
120
|
+
* - `./icon.svg?data-uri&encoding=css&srcset` - CSS encoding with srcset compatibility.
|
|
114
121
|
*/
|
|
115
122
|
interface DebarrelPluginOptions {
|
|
116
123
|
include?: FilterPattern;
|
|
@@ -635,33 +642,6 @@ type TsconfigPathsPluginOptions = {
|
|
|
635
642
|
* on how the TypeScript compiler handles it.
|
|
636
643
|
* @see https://github.com/microsoft/TypeScript/blob/1a9c8197fffe3dace5f8dca6633d450a88cba66d/src/compiler/moduleNameResolver.ts#L1362
|
|
637
644
|
*/
|
|
638
|
-
interface RollupDynamicImportVariablesOptions {
|
|
639
|
-
/**
|
|
640
|
-
* By default, the plugin will not throw errors when target files are not found.
|
|
641
|
-
* Setting this option to true will result in errors thrown when encountering files which don't exist.
|
|
642
|
-
* @default false
|
|
643
|
-
*/
|
|
644
|
-
errorWhenNoFilesFound?: boolean;
|
|
645
|
-
/**
|
|
646
|
-
* A picomatch pattern, or array of patterns, which specifies the files in the build the plugin
|
|
647
|
-
* should _ignore_.
|
|
648
|
-
*
|
|
649
|
-
* By default, no files are ignored.
|
|
650
|
-
*/
|
|
651
|
-
exclude?: FilterPattern;
|
|
652
|
-
/**
|
|
653
|
-
* A picomatch pattern, or array of patterns, which specifies the files in the build the plugin
|
|
654
|
-
* should operate on.
|
|
655
|
-
* By default, all files are targeted.
|
|
656
|
-
*/
|
|
657
|
-
include?: FilterPattern;
|
|
658
|
-
/**
|
|
659
|
-
* By default, the plugin quits the build process when it encounters an error.
|
|
660
|
-
* If you set this option to true, it will throw a warning instead and leave the code untouched.
|
|
661
|
-
* @default false
|
|
662
|
-
*/
|
|
663
|
-
warnOnError?: boolean;
|
|
664
|
-
}
|
|
665
645
|
/**
|
|
666
646
|
* Legacy `@rollup/plugin-node-resolve` option keys. Module resolution is now
|
|
667
647
|
* handled by the oxc resolver, but these keys are still accepted and mapped onto
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var j=Object.defineProperty;var d=(e,t)=>j(e,"name",{value:t,configurable:!0});import{createFilter as $}from"@rollup/pluginutils";import{DEFAULT_LOADERS as k}from"@visulima/packem-share/constants";import{join as E,extname as M}from"@visulima/path";import{formatMessages as S,transform as D,build as A}from"esbuild";import{findCacheDirSync as P}from"@visulima/find-cache-dir";import{readFile as R}from"@visulima/fs";import*as F from"rs-module-lexer";var L=Object.defineProperty,C=d((e,t)=>L(e,"name",{value:t,configurable:!0}),"n");const _=C(async(e,t)=>{t.length>0&&(await S(t,{color:!0,kind:"warning"})).forEach(s=>{e.warn(s)})},"warn");var W=Object.defineProperty,z=d((e,t)=>W(e,"name",{value:t,configurable:!0}),"t");const I=z(e=>{if(e==="es")return"esm";if(e==="cjs")return e},"getEsbuildFormat"),N=z(({sourceMap:e=!0,...t})=>async function(s,o,r){if(t.minify||t.minifyWhitespace||t.minifyIdentifiers||t.minifySyntax){const i=I(r.format),c=await D(s,{format:i,loader:"js",sourcemap:e,...t});if(await _(this,c.warnings),c.code)return{code:c.code,map:c.map||void 0}}},"getRenderChunk");var T=Object.defineProperty,x=d((e,t)=>T(e,"name",{value:t,configurable:!0}),"o");const q=x(e=>e.replaceAll("\\","/"),"slash"),{parseAsync:J}=F,b=/.*/,U=x(async e=>{const t=P("@visulima/packem/optimize-deps",{create:!0,cwd:e.cwd});if(!t)throw new Error('[packem:optimize-deps]: failed to find or create cache directory "node_modules/.cache/packem/optimize_deps".');await A({absWorkingDir:e.cwd,bundle:!0,entryPoints:e.include,format:"esm",ignoreAnnotations:!0,metafile:!0,outdir:t,sourcemap:e.sourceMap,splitting:!0,...e.esbuildOptions,plugins:[{name:"optimize-deps",setup(o){o.onResolve({filter:b},async r=>{if(e.exclude?.includes(r.path))return{external:!0};if(!r.pluginData?.__resolving_dep_path__&&e.include.includes(r.path)){const i=await o.resolve(r.path,{kind:"import-statement",pluginData:{__resolving_dep_path__:!0},resolveDir:r.resolveDir});return i.errors.length>0||i.warnings.length>0?i:{namespace:"optimize-deps",path:r.path,pluginData:{absolute:i.path,resolveDir:r.resolveDir}}}}),o.onLoad({filter:b,namespace:"optimize-deps"},async r=>{const{absolute:i,resolveDir:c}=r.pluginData,l=await R(i),{output:m}=await J({input:[{code:l,filename:i}]}),v=m[0]?.exports??[],u=JSON.stringify(q(i));return{contents:v.length>0?`export * from ${u}`:`module.exports = require(${u})`,resolveDir:c}})}},...e.esbuildOptions?.plugins??[]]});const s=new Map;for(const o of e.include)s.set(o,{file:E(t,`${o}.js`)});return{cacheDir:t,optimized:s}},"optimizeDeps");var B=Object.defineProperty,y=d((e,t)=>B(e,"name",{value:t,configurable:!0}),"m");const G=/\.[cm]ts/,H=new Set(["base64","binary","dataurl","json","text"]),K=y(({exclude:e,include:t,loaders:s,logger:o,optimizeDeps:r,sourceMap:i,...c})=>{const l={...k};if(s!==void 0)for(const[a,n]of Object.entries(s)){const f=a.startsWith(".")?a:`.${a}`;typeof n=="string"?l[f]=n:delete l[f]}const m=Object.keys(l),v=y(a=>a.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`),"escapeForRegExp"),u=new RegExp(String.raw`\.(${m.map(a=>v(a.slice(1))).join("|")})$`),w=t||e?$(t??u,e):void 0;t&&o.debug("`include` is constrained to files matching a configured loader extension (%O)",m);let p;const O=process.cwd();return{async buildStart(){!r||p||(p=await U({cwd:O,sourceMap:i??!1,...r}),o.debug("optimized %O",p.optimized))},name:"packem:esbuild",renderChunk:N({...c,sourceMap:i}),resolveId(a){if(p?.optimized.has(a)){const n=p.optimized.get(a);if(n)return o.debug("resolved %s to %s",a,n.file),n.file}},transform:{filter:{id:u},async handler(a,n){if(w&&!w(n)||p?.optimized.has(n))return;const f=M(n),g=l[f];if(o.debug("transforming %s with %s loader",n,g),!g)return;const h=await D(a,{format:H.has(g)?"esm":void 0,loader:g,sourcefile:n.replace(G,".ts"),sourcemap:i,...c});if(await _(this,h.warnings),h.code)return{code:h.code,map:h.map||void 0}}}}},"esbuildTransformer");K.NAME="esbuild";export{K as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var f=Object.defineProperty;var c=(e,r)=>f(e,"name",{value:r,configurable:!0});import{createFilter as s}from"@rollup/pluginutils";import{transform as u}from"@swc/core";import{EXCLUDE_REGEXP as t}from"@visulima/packem-share/constants";var d=Object.defineProperty,p=c((e,r)=>d(e,"name",{value:r,configurable:!0}),"i");const w=p(({exclude:e,include:r,...n})=>{const i=s(r,e??t);return{name:"packem:swc",transform:{filter:{id:{exclude:e??t,include:r}},async handler(l,a){if(!i(a))return;const{code:o,map:m}=await u(l,{...n,configFile:!1,filename:a,swcrc:!1});return{code:o,map:m}}}}},"swcPlugin");w.NAME="swc";export{w as default};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FilterPattern } from '@rollup/pluginutils';
|
|
2
2
|
import { Options } from '@swc/types';
|
|
3
|
-
type SwcPluginConfig =
|
|
3
|
+
type SwcPluginConfig = Omit<Options, "configFile" | "exclude" | "filename" | "swcrc"> & {
|
|
4
4
|
exclude?: FilterPattern;
|
|
5
5
|
include?: FilterPattern;
|
|
6
6
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var x=Object.defineProperty;var d=(t,e)=>x(t,"name",{value:e,configurable:!0});import c from"node:assert/strict";import{extractAssignedNames as y}from"@rollup/pluginutils";var h=Object.defineProperty,n=d((t,e)=>h(t,"name",{value:e,configurable:!0}),"t");const v=n(function*(t){switch(t.declaration?.type){case"ClassDeclaration":case"FunctionDeclaration":{const{id:e}=t.declaration;c.ok(e,"Expected class/function to have a name"),yield e.name;break}case"VariableDeclaration":{for(const e of t.declaration.declarations)for(const a of y(e.id))yield a;break}}},"exportName"),N=n(function*(t){if(t.declaration)for(const e of v(t))yield{exportedName:e,from:"self",type:"named"};else if(t.source)yield{bindings:t.specifiers.map(e=>({exportedName:e.exported.name,importedName:e.local.name})),from:"other",source:t.source.value,type:"named"};else for(const e of t.specifiers)yield{exportedName:e.exported.name,from:"self",type:"named"}},"parseExportNamed"),g=n(function*(t){t.exported?yield{exportedName:t.exported.name,from:"self",type:"named"}:yield{from:"other",source:t.source.value,type:"barrel"}},"parseExportAll"),b=n(function*(){yield{exportedName:"default",from:"self",type:"named"}},"parseExportDefault"),E=n(t=>/\.tsx$/.test(t)?"tsx":/\.[cm]?ts$/.test(t)?"ts":/\.jsx$/.test(t)?"jsx":"js","langForId"),f=n(function(t,e){c.ok(e.code!==null,`Module ${e.id} doesn't have associated code`);let a;try{a=t.parse(e.code,{lang:E(e.id)})}catch{return[]}const r=[];for(const o of a.body)switch(o.type){case"ExportAllDeclaration":{r.push(...g(o));break}case"ExportDefaultDeclaration":{r.push(...b());break}case"ExportNamedDeclaration":{r.push(...N(o));break}}return r},"collectExports"),k=n(function(t,e,a){if(!a)return f(t,e);const r=a.get(e.id);if(r!==void 0)return r;const o=f(t,e);return a.set(e.id,o),o},"parseExports");var $=Object.defineProperty,i=d((t,e)=>$(t,"name",{value:e,configurable:!0}),"i");const m=i(async function(t,e,a){const r=await t.resolve(e,a.id);if(c.ok(r,`Rollup can't resolve ${e} from ${a.id}`),r.external)return;const o=await t.load(r);return c.ok(o,`Rollup doesn't have a module for id ${r.id}`),o},"getImportedModule"),w=i(async function*(t,e,a,r){const o=await m(t,e.source,a);o&&(yield*l(t,o,r))},"gatherBarrelReExports"),D=i(async function*(t,e,a,r){const o=await m(t,e.source,a);if(!o)return;const u=new Map(e.bindings.map(s=>[s.importedName,s]));for await(const s of l(t,o,r)){const p=u.get(s.exportedName);p&&(yield{...s,exportedName:p.exportedName})}},"gatherNamedReExports"),j=i(function*(t,e){yield{exportedName:e.exportedName,id:t.id,sourceName:e.exportedName}},"gatherNamedSelfExports"),l=i(async function*(t,e,a){if(!a.visited.has(e.id)){a.visited.add(e.id);try{for(const r of k(t,e,a.parseCache))r.from==="self"?yield*j(e,r):r.type==="barrel"?yield*w(t,r,e,a):yield*D(t,r,e,a)}finally{a.visited.delete(e.id)}}},"gatherExportsWithState"),S=i(function(t,e){return l(t,e,{parseCache:new Map,visited:new Set})},"gatherExports");var M=Object.defineProperty,P=d((t,e)=>M(t,"name",{value:e,configurable:!0}),"r");const F=P(()=>({moduleParsed:{async handler(t){if(t.isEntry)for await(const e of S(this,t))e.id!==t.id&&this.emitFile({id:e.id,name:e.exportedName,preserveSignature:"exports-only",type:"chunk"})},order:"post"},name:"packem:chunk-splitter"}),"chunkSplitter");export{F as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
2
|
-
module.exports.default =
|
|
1
|
+
var c=Object.defineProperty;var l=(e,t)=>c(e,"name",{value:t,configurable:!0});import m from"magic-string";var g=Object.defineProperty,p=l((e,t)=>g(e,"name",{value:t,configurable:!0}),"s");const y=/\bexports\b/,x=p(e=>{if(e?.type==="Identifier")return e.name;if(e?.type==="Literal"&&typeof e.value=="string")return e.value},"staticPropertyName"),b=p(e=>{if(e?.type!=="MemberExpression"||e.object===void 0)return;const t=x(e.property);if(t!==void 0){if(e.object.type==="Identifier"&&e.object.name==="module"&&t==="exports")return{kind:"module"};if(e.object.type==="Identifier"&&e.object.name==="exports")return{kind:"exports",name:t}}},"resolveExportTarget"),j=p((e,t)=>{const n={changed:!1,sawDefault:!1};if(t.type!=="ExpressionStatement")return n;const{expression:o}=t;if(o?.type!=="AssignmentExpression"||o.operator!=="=")return n;const s=b(o.left);if(s===void 0||s.kind==="module")return n;const r=o.left;return typeof r.start!="number"||typeof r.end!="number"?n:s.name==="default"?(e.overwrite(r.start,r.end,"module.exports"),{changed:!0,sawDefault:!0}):(e.overwrite(r.start,r.end,`module.exports.${s.name??""}`),{changed:!0,sawDefault:!1})},"rewriteExportAssignment"),w=p(({addDefaultProperty:e=!1,logger:t})=>({name:"packem:cjs-interop",renderChunk(n,o,s){if(!o.isEntry||s.format!=="cjs"||s.exports!=="auto"||!y.test(n))return;let r;try{r=this.parse(n)}catch{return}const a=new m(n);let i=!1,u=!1;for(const d of r.body){const f=j(a,d);i=i||f.changed,u=u||f.sawDefault}if(u&&(e&&(a.append(`
|
|
2
|
+
module.exports.default = module.exports;`),i=!0),!!i))return t.debug({message:`Applied CommonJS interop to entry chunk ${o.fileName}.`,prefix:"plugin:cjs-interop"}),{code:a.toString(),map:a.generateMap({hires:!0})}}}),"cjsInteropPlugin");export{w as cjsInteropPlugin};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{default as l}from"../../packem_shared/browserslistToEsbuild-HD6SaWPt.js";import{default as r}from"../../packem_shared/esbuildPlugin-
|
|
1
|
+
import{default as l}from"../../packem_shared/browserslistToEsbuild-HD6SaWPt.js";import{default as r}from"../../packem_shared/esbuildPlugin-D_vSjXWg.js";export{l as browserslistToEsbuild,r as esbuildPlugin};
|
package/dist/plugins/json.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var l=Object.defineProperty;var r=(t,o)=>l(t,"name",{value:o,configurable:!0});import i from"@rollup/plugin-json";var u=Object.defineProperty,d=r((t,o)=>u(t,"name",{value:o,configurable:!0}),"s");const a="export default ",f=/\.json$/,g=d(t=>{const o=i(t);return{...o,name:"packem:json",transform:{filter:{id:f},handler(s,c){const n=o.transform,e=(typeof n=="function"?n:n?.handler)?.call(this,s,c);return e&&typeof e!="string"&&"code"in e&&e.code?.startsWith(a)&&(e.code=e.code.replace(a,"module.exports = ")),e}}}},"JsonPlugin");export{g as JsonPlugin};
|
|
@@ -2,10 +2,26 @@ import { Plugin } from 'rollup';
|
|
|
2
2
|
type JSXRemoveAttributesPlugin = {
|
|
3
3
|
attributes: string[];
|
|
4
4
|
};
|
|
5
|
+
/**
|
|
6
|
+
* Remove JSX attributes (e.g. `data-testid`) from automatic-runtime JSX calls.
|
|
7
|
+
*
|
|
8
|
+
* Two modes, because the bundlers run their JSX transform at different times:
|
|
9
|
+
* - `"transform"` (rollup): packem's transformer adapter runs as an earlier
|
|
10
|
+
* transform plugin, so by the time this transform hook runs the per-module
|
|
11
|
+
* source already contains `jsx(...)` calls and `this.parse` sees plain JS.
|
|
12
|
+
* - `"renderChunk"` (rolldown): rolldown's native oxc transform runs AFTER
|
|
13
|
+
* plugin transform hooks, so a transform hook would see raw JSX and
|
|
14
|
+
* `this.parse` would throw. The emitted chunk, however, is fully transpiled —
|
|
15
|
+
* so the same AST walk runs there instead.
|
|
16
|
+
*/
|
|
5
17
|
declare const jsxRemoveAttributes: ({
|
|
6
18
|
attributes,
|
|
7
|
-
logger
|
|
19
|
+
logger,
|
|
20
|
+
mode,
|
|
21
|
+
sourcemap
|
|
8
22
|
}: JSXRemoveAttributesPlugin & {
|
|
9
23
|
logger: Console;
|
|
24
|
+
mode?: "renderChunk" | "transform";
|
|
25
|
+
sourcemap?: boolean;
|
|
10
26
|
}) => Plugin;
|
|
11
27
|
export { JSXRemoveAttributesPlugin, jsxRemoveAttributes };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var b=Object.defineProperty;var c=(e,t)=>b(e,"name",{value:t,configurable:!0});import{w as g}from"../packem_shared/index-Dq8IUFTs.js";import h from"magic-string";var j=Object.defineProperty,p=c((e,t)=>j(e,"name",{value:t,configurable:!0}),"p");const k=/\.[jt]sx$/,v=/\s/,w=new Set(["jsx","jsxDEV","jsxs"]),d=p((e,t)=>{let r=t;for(;r<e.length&&v.test(e[r]);)r+=1;return e[r]===","&&(r+=1),r},"scanPastTrailingComma"),R=p((e,t,r,n,s)=>{if(s){e.remove(r,d(t,n));return}let a=r;for(;a>0&&v.test(t[a-1]);)a-=1;if(t[a-1]===","){e.remove(a-1,n);return}e.remove(r,d(t,n))},"removeProperty"),f=p((e,t,r,n,s)=>{const a=new h(t);let u=!1;return g(e,{enter(i){if(i.type==="CallExpression"&&i.callee.type==="Identifier"&&w.has(i.callee.name)){const l=i.arguments.filter(o=>o.type==="ObjectExpression"&&Array.isArray(o.properties));for(const o of l)for(const m of o.properties){if(m.type!=="Property"||m.key.type!=="Literal"||!r.includes(m.key.value))continue;if(m.value.type!=="Literal"){s.debug({message:`skipping attribute "${String(m.key.value)}": value is "${m.value.type}", not a literal.`,prefix:"plugin:jsx-remove-attributes"});continue}const{end:y,start:x}=m;R(a,t,x,y,n),u=!0}}}}),u?a:void 0},"stripAttributes"),O=p(({attributes:e,logger:t,mode:r="transform",sourcemap:n=!0})=>{if(!Array.isArray(e)||e.length===0)throw new Error("[packem:jsx-remove-attributes]: attributes must be a non-empty array of strings.");return r==="renderChunk"?{name:"packem:jsx-remove-attributes",renderChunk:{handler(s,a,{sourcemap:u}){if(!(s.includes("jsx(")||s.includes("jsxs(")||s.includes("jsxDEV("))||!e.some(o=>s.includes(o)))return;let i;try{i=this.parse(s,{allowReturnOutsideFunction:!0})}catch(o){this.warn({code:"PARSE_ERROR",message:`[packem:jsx-remove-attributes]: failed to parse chunk "${a.fileName}" and remove the jsx attribute.`}),t.warn(o);return}const l=f(i,s,e,!0,t);if(l!==void 0)return{code:l.toString(),map:u?l.generateMap({hires:!0}):void 0}},order:"post"}}:{name:"packem:jsx-remove-attributes",transform:{filter:{id:k},handler(s,a){let u;try{u=this.parse(s,{allowReturnOutsideFunction:!0})}catch(l){this.warn({code:"PARSE_ERROR",message:`[packem:jsx-remove-attributes]: failed to parse "${a}" and remove the jsx attribute.`}),t.warn(l);return}const i=f(u,s,e,!1,t);if(i!==void 0)return{code:i.toString(),map:n?i.generateMap({hires:!0}):void 0}}}}},"jsxRemoveAttributes");export{O as jsxRemoveAttributes};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
var
|
|
1
|
+
var M=Object.defineProperty;var k=(t,l)=>M(t,"name",{value:l,configurable:!0});import{createFilter as $}from"@rollup/pluginutils";import b from"magic-string";var D=Object.defineProperty,h=k((t,l)=>D(t,"name",{value:l,configurable:!0}),"m");const S=new Set([" "," ","\f","\v"," ","\uFEFF"]),m=new Set([`
|
|
2
|
+
`,"\r","\u2028","\u2029"]),x=/"([^"]*)"|'([^']*)'/,I=h(t=>{const l=[],{length:v}=t;let e=0;const g=h(a=>{for(;e<v;){const f=t[e];if(S.has(f))e+=1;else if(m.has(f)){if(!a)return;e+=1}else if(f==="/"&&t[e+1]==="/")for(e+=2;e<v&&!m.has(t[e]);)e+=1;else if(f==="/"&&t[e+1]==="*"){for(e+=2;e<v&&!(t[e]==="*"&&t[e+1]==="/");)e+=1;e+=2}else return}},"skipTrivia");for(;e<v&&(g(!0),!(e>=v));){const a=t[e];if(a!=='"'&&a!=="'")break;const f=e;e+=1;let s=!1;for(;e<v;){const u=t[e];if(u==="\\"){e+=2;continue}if(u===a){e+=1,s=!0;break}if(m.has(u))break;e+=1}if(!s)break;const i=e,c=t.slice(f+1,i-1);g(!1);const o=t[e];if(o===";"){e+=1,l.push({end:e,start:f,value:c});continue}if(e>=v||m.has(o)||o==="}"){l.push({end:i,start:f,value:c});continue}break}return l},"scanLeadingDirectives"),y=h(({directiveRegex:t,exclude:l=[],include:v=[],logger:e})=>{const g={},a={},f=$(v,l);return{name:"packem:preserve-directives",onLog(s,i){if(i.code==="MODULE_LEVEL_DIRECTIVE"&&s==="warn"){const c=x.exec(i.message),o=c?.[1]??c?.[2];if(o!==void 0&&t.test(`"${o}"`))return!1}},renderChunk:{handler(s,i,{sourcemap:c}){const o=h(r=>{const n=this.getModuleInfo(r)?.meta?.preserveDirectives?.directives;return n&&n.length>0?new Set(n):g[r]},"directivesForId"),u=i.moduleIds.map(r=>o(r)).reduce((r,n)=>(n&&n.forEach(w=>{r.add(w)}),r),new Set),d=new b(s);for(const{value:r}of I(s))u.delete(r);u.size>0&&(e.debug({message:`directives for chunk "${i.fileName}" are preserved.`,prefix:"plugin:preserve-directives"}),d.prepend(`${Array.from(u,r=>`'${r.replace(/\\/g,"\\\\").replace(/'/g,"\\'")}';`).join(`
|
|
2
3
|
`)}
|
|
3
|
-
`));let
|
|
4
|
-
`)),!(
|
|
4
|
+
`));let p;if(i.facadeModuleId){const r=this.getModuleInfo(i.facadeModuleId)?.meta?.preserveDirectives?.shebang;typeof r=="string"?p=r:typeof a[i.facadeModuleId]=="string"&&(p=a[i.facadeModuleId])}if(p&&(e.debug({message:`shebang for chunk "${i.fileName}" is preserved.`,prefix:"plugin:preserve-directives"}),d.prepend(`${p}
|
|
5
|
+
`)),!(u.size===0&&p===void 0))return{code:d.toString(),map:c?d.generateMap({hires:!0}):void 0}},order:"post"},transform(s,i){if(!f(i))return;delete g[i],delete a[i];let c=!1,o;if(s.startsWith("#")&&s[1]==="!"){let d=s.length;for(let p=s.length,r=2;r<p;r+=1){const n=s.codePointAt(r);if(n===10||n===13||n===8232||n===8233){d=r;break}}d>0&&(a[i]=s.slice(0,d),o=new b(s),o.remove(0,Math.min(d+1,s.length)),c=!0,e.debug({message:`shebang for module "${i}" is preserved.`,prefix:"plugin:preserve-directives"}))}const u=o===void 0?s:o.toString();for(const{end:d,start:p,value:r}of I(u)){if(r==="use strict"||!t.test(`"${r}"`))continue;const n=g[i];n?n.add(r):g[i]=new Set([r]),o??=new b(s),o.remove(p,d),c=!0,e.debug({message:`directive "${r}" for module "${i}" is preserved.`,prefix:"plugin:preserve-directives"})}if(!(!c||o===void 0))return{code:o.toString(),map:o.generateMap({hires:!0}),meta:{preserveDirectives:{directives:[...g[i]??[]],shebang:a[i]??void 0}}}}}},"preserveDirectivesPlugin");export{y as preserveDirectivesPlugin};
|
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
import { Plugin } from 'rollup';
|
|
2
2
|
/**
|
|
3
|
-
* A
|
|
4
|
-
*
|
|
3
|
+
* A plugin that adds `/* @__PURE__ * /` annotations so consumers can tree-shake
|
|
4
|
+
* unused calls/instantiations.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
6
|
+
* Two modes, because rolldown and rollup expose pure-annotation timing differently:
|
|
7
|
+
* - `"transform"` (rollup, default): annotates `new Constructor(...)`
|
|
8
|
+
* (`NewExpression`) only — `rollup-plugin-pure` handles the `CallExpression`
|
|
9
|
+
* side separately. Runs `order: "post"` so `this.parse` sees transpiled JS.
|
|
10
|
+
* - `"renderChunk"` (rolldown): `rollup-plugin-pure` is transform-only and can't
|
|
11
|
+
* run under rolldown (its native oxc transform runs after plugin transforms),
|
|
12
|
+
* so this single renderChunk pass annotates BOTH `NewExpression` (constructors)
|
|
13
|
+
* and `CallExpression` (functions) on the final transpiled chunk.
|
|
7
14
|
*/
|
|
8
15
|
declare const pureNewExpressionPlugin: (options: {
|
|
9
16
|
constructors: string[];
|
|
17
|
+
functions?: (RegExp | string)[];
|
|
18
|
+
logger?: Console;
|
|
19
|
+
mode?: "renderChunk" | "transform";
|
|
10
20
|
sourcemap?: boolean;
|
|
11
21
|
}) => Plugin;
|
|
12
22
|
export { pureNewExpressionPlugin };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var b=Object.defineProperty;var x=(e,r)=>b(e,"name",{value:r,configurable:!0});import{w as E}from"../packem_shared/index-Dq8IUFTs.js";import _ from"magic-string";var R=Object.defineProperty,u=x((e,r)=>R(e,"name",{value:r,configurable:!0}),"a");const k=24,v=u(e=>{if(e){if(e.type==="Identifier")return e.name;if(e.type==="MemberExpression"&&!e.computed&&e.property?.type==="Identifier"){const r=v(e.object);return r===void 0?void 0:`${r}.${e.property.name}`}}},"calleeToName"),P=u((e,r)=>e.slice(Math.max(0,r-k),r).includes("__PURE__"),"isAlreadyPure"),I=u(e=>{const r=e.constructors.filter(t=>t.includes(".")),y=(e.functions??[]).filter(t=>t instanceof RegExp);(r.length>0||y.length>0)&&e.logger&&e.logger.warn({message:`ignoring unsupported entries — dotted constructor names (${r.join(", ")||"none"}) and ${String(y.length)} RegExp function/constructor matchers are not supported and were skipped.`,prefix:"plugin:pure-new-expression"});const a=new Set(e.constructors.filter(t=>!t.includes("."))),h=new Set((e.functions??[]).filter(t=>typeof t=="string")),S=u(t=>t.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`),"escapeForRegExp"),f=new Set(a);for(const t of h)f.add(t.split(".")[0]);const c=f.size>0?new RegExp(String.raw`\b(?:${[...f].map(t=>S(t)).join("|")})\b`):void 0;return e.mode==="renderChunk"?{name:"packem:pure-new-expression",renderChunk:{handler(t,d,{sourcemap:o}){if(c===void 0||!c.test(t))return;let i;try{i=this.parse(t)}catch{return}const p=new _(t);let s=!1;if(E(i,{enter(l,m){const n=l;if(typeof n.start!="number"||m?.type==="ExpressionStatement")return;let g=!1;if(n.type==="NewExpression"&&n.callee?.type==="Identifier"&&typeof n.callee.name=="string"&&a.has(n.callee.name))g=!0;else if(n.type==="CallExpression"){const w=v(n.callee);w!==void 0&&h.has(w)&&(g=!0)}g&&!P(t,n.start)&&(p.prependLeft(n.start,"/* @__PURE__ */ "),s=!0)}}),!!s)return{code:p.toString(),map:o?p.generateMap({hires:!0}):void 0}},order:"post"}}:{name:"packem:pure-new-expression",transform:{handler(t){if(a.size===0||c===void 0||!c.test(t))return;let d;try{d=this.parse(t)}catch{return}const o=new _(t);let i=!1;if(E(d,{enter(p){const s=p,l=s.callee?.name,m=s._rollupAnnotations;s.type==="NewExpression"&&s.callee?.type==="Identifier"&&typeof l=="string"&&a.has(l)&&!m?.some(n=>n.type==="pure")&&typeof s.start=="number"&&(o.prependLeft(s.start,"/* @__PURE__ */ "),i=!0)}}),!!i)return{code:o.toString(),map:e.sourcemap?o.generateMap({hires:!0}):void 0}},order:"post"}}},"pureNewExpressionPlugin");export{I as pureNewExpressionPlugin};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var l=Object.defineProperty;var o=(e,r)=>l(e,"name",{value:r,configurable:!0});import{createFilter as p}from"@rollup/pluginutils";import{EXCLUDE_REGEXP as t}from"@visulima/packem-share/constants";import{transform as f}from"sucrase";var d=Object.defineProperty,E=o((e,r)=>d(e,"name",{value:r,configurable:!0}),"t");const c=E(({exclude:e,include:r,...n})=>{const i=p(r,e??t);return{name:"packem:sucrase",transform:{filter:{id:{exclude:e??t,include:r}},handler(s,a){if(!i(a))return;const{code:u,sourceMap:m}=f(s,{...n,filePath:a,sourceMapOptions:{compiledFilename:a}});return{code:u,map:m}}}}},"sucraseTransformPlugin");c.NAME="sucrase";const M=c;export{M as sucrasePlugin};
|
|
@@ -4,7 +4,7 @@ import { T as TransformerFn } from "../../packem_shared/types.d-DrgzeMBs.d-CG9J1
|
|
|
4
4
|
import '@visulima/packem-share/types';
|
|
5
5
|
import '@rollup/plugin-alias';
|
|
6
6
|
import '@visulima/package';
|
|
7
|
-
import { S as SwcPluginConfig } from "../../packem_shared/types.d-
|
|
7
|
+
import { S as SwcPluginConfig } from "../../packem_shared/types.d-DukC_8rF.js";
|
|
8
8
|
import '@rollup/pluginutils';
|
|
9
9
|
import '@swc/types';
|
|
10
10
|
declare const _default: TransformerFn<SwcPluginConfig>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{default as f}from"../../packem_shared/swcPlugin-
|
|
1
|
+
import{default as f}from"../../packem_shared/swcPlugin-BdHPQBN4.js";export{f as swcPlugin};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visulima/packem-rollup",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.73",
|
|
4
4
|
"description": "Rollup plugins for packem",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"visulima",
|
|
@@ -81,6 +81,7 @@
|
|
|
81
81
|
"dist"
|
|
82
82
|
],
|
|
83
83
|
"dependencies": {
|
|
84
|
+
"@babel/core": "7.29.7",
|
|
84
85
|
"@rollup/plugin-alias": "6.0.0",
|
|
85
86
|
"@rollup/plugin-commonjs": "29.0.3",
|
|
86
87
|
"@rollup/plugin-dynamic-import-vars": "2.1.5",
|
|
@@ -89,16 +90,18 @@
|
|
|
89
90
|
"@rollup/plugin-replace": "6.0.3",
|
|
90
91
|
"@rollup/plugin-wasm": "6.2.2",
|
|
91
92
|
"@rollup/pluginutils": "5.4.0",
|
|
93
|
+
"@swc/types": "0.1.26",
|
|
92
94
|
"@visulima/find-cache-dir": "3.0.0-alpha.9",
|
|
93
95
|
"@visulima/fs": "5.0.0-alpha.24",
|
|
94
96
|
"@visulima/package": "5.0.0-alpha.23",
|
|
95
|
-
"@visulima/packem-share": "1.0.0-alpha.
|
|
97
|
+
"@visulima/packem-share": "1.0.0-alpha.50",
|
|
96
98
|
"@visulima/path": "3.0.0-alpha.10",
|
|
97
|
-
"@visulima/rollup-plugin-dts": "1.0.0-alpha.
|
|
99
|
+
"@visulima/rollup-plugin-dts": "1.0.0-alpha.34",
|
|
98
100
|
"clean-css": "^5.3.3",
|
|
99
101
|
"html-minifier-next": "6.2.7",
|
|
100
102
|
"magic-string": "0.30.21",
|
|
101
103
|
"oxc-resolver": "11.20.0",
|
|
104
|
+
"oxc-transform": "0.133.0",
|
|
102
105
|
"rollup-plugin-import-trace": "1.0.1",
|
|
103
106
|
"rollup-plugin-polyfill-node": "0.13.0",
|
|
104
107
|
"rollup-plugin-pure": "^0.4.0",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var x=Object.defineProperty;var l=(e,r)=>x(e,"name",{value:r,configurable:!0});import{createFilter as k}from"@rollup/pluginutils";import{DEFAULT_LOADERS as O}from"@visulima/packem-share/constants";import{join as E,extname as M}from"@visulima/path";import{formatMessages as A,transform as D,build as S}from"esbuild";import{findCacheDirSync as P}from"@visulima/find-cache-dir";import{readFileSync as R}from"@visulima/fs";import*as F from"rs-module-lexer";var C=Object.defineProperty,L=l((e,r)=>C(e,"name",{value:r,configurable:!0}),"n");const _=L(async(e,r)=>{r.length>0&&(await A(r,{color:!0,kind:"warning"})).forEach(s=>{e.warn(s)})},"warn");var W=Object.defineProperty,z=l((e,r)=>W(e,"name",{value:r,configurable:!0}),"t");const $=z(e=>{if(e==="es")return"esm";if(e==="cjs")return e},"getEsbuildFormat"),I=z(({sourceMap:e=!0,...r})=>async function(s,n,i){if(r.minify||r.minifyWhitespace||r.minifyIdentifiers||r.minifySyntax){const t=$(i.format),c=await D(s,{format:t,loader:"js",sourcemap:e,...r});if(await _(this,c.warnings),c.code)return{code:c.code,map:c.map||void 0}}},"getRenderChunk");var T=Object.defineProperty,j=l((e,r)=>T(e,"name",{value:r,configurable:!0}),"o");const w=j(e=>e.replaceAll("\\","/"),"slash"),{parseAsync:q}=F,y=/.*/,N=j(async e=>{const r=P("@visulima/packem/optimize-deps",{create:!0,cwd:e.cwd});if(!r)throw new Error('[packem:optimize-deps]: failed to find or create cache directory "node_modules/.cache/packem/optimize_deps".');await S({absWorkingDir:e.cwd,bundle:!0,entryPoints:e.include,format:"esm",ignoreAnnotations:!0,metafile:!0,outdir:r,sourcemap:e.sourceMap,splitting:!0,...e.esbuildOptions,plugins:[{name:"optimize-deps",setup(n){n.onResolve({filter:y},async i=>{if(e.exclude?.includes(i.path))return{external:!0};if(!i.pluginData?.__resolving_dep_path__&&e.include.includes(i.path)){const t=await n.resolve(i.path,{kind:"import-statement",pluginData:{__resolving_dep_path__:!0},resolveDir:i.resolveDir});return t.errors.length>0||t.warnings.length>0?t:{namespace:"optimize-deps",path:i.path,pluginData:{absolute:t.path,resolveDir:i.resolveDir}}}}),n.onLoad({filter:y,namespace:"optimize-deps"},async i=>{const{absolute:t,resolveDir:c}=i.pluginData,p=R(t),{output:g}=await q({input:[{code:p,filename:t}]});return{contents:(g[0]?.exports??[]).length>0?`export * from '${w(t)}'`:`module.exports = require('${w(t)}')`,resolveDir:c}})}},...e.esbuildOptions?.plugins??[]]});const s=new Map;for(const n of e.include)s.set(n,{file:E(r,`${n}.js`)});return{cacheDir:r,optimized:s}},"optimizeDeps");var U=Object.defineProperty,B=l((e,r)=>U(e,"name",{value:r,configurable:!0}),"E");const G=/\.[cm]ts/,H=B(({exclude:e,include:r,loaders:s,logger:n,optimizeDeps:i,sourceMap:t,...c})=>{const p=O;if(s!==void 0)for(const[o,a]of Object.entries(s)){const d=o.startsWith(".")?o:`.${o}`;typeof a=="string"?p[d]=a:delete p[d]}const g=Object.keys(p),v=new RegExp(String.raw`\.(${g.map(o=>o.slice(1)).join("|")})$`),h=r||e?k(r??v,e):void 0;let u,b=process.cwd();return{async buildStart(){!i||u||(u=await N({cwd:b,sourceMap:t??!1,...i}),n.debug("optimized %O",u.optimized))},name:"packem:esbuild",options({context:o}){o&&(b=o)},renderChunk:I({...c,sourceMap:t}),resolveId(o){if(u?.optimized.has(o)){const a=u.optimized.get(o);if(a)return n.debug("resolved %s to %s",o,a.file),a.file}},transform:{filter:{id:v},async handler(o,a){if(h&&!h(a)||u?.optimized.has(a))return;const d=M(a),m=p[d];if(n.debug("transforming %s with %s loader",a,m),!m)return;const f=await D(o,{format:["base64","binary","dataurl","text","json"].includes(m)?"esm":void 0,loader:m,sourcefile:a.replace(G,".ts"),sourcemap:t,...c});if(await _(this,f.warnings),f.code)return{code:f.code,map:f.map||void 0}}}}},"esbuildTransformer");H.NAME="esbuild";export{H as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var s=Object.defineProperty;var c=(e,r)=>s(e,"name",{value:r,configurable:!0});import{createFilter as f}from"@rollup/pluginutils";import{transform as l}from"@swc/core";import{EXCLUDE_REGEXP as u}from"@visulima/packem-share/constants";var p=Object.defineProperty,d=c((e,r)=>p(e,"name",{value:r,configurable:!0}),"i");const w=d(({exclude:e,include:r,...t})=>{const n=f(r,e??u);return{name:"packem:swc",async transform(o,a){if(!n(a))return;const{code:m,map:i}=await l(o,{...t,configFile:!1,filename:a,swcrc:!1});return{code:m,map:i}}}},"swcPlugin");w.NAME="swc";export{w as default};
|