@visulima/packem-rollup 1.0.0-alpha.7 → 1.0.0-alpha.71
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 +704 -0
- package/LICENSE.md +8 -791
- package/README.md +89 -2
- package/dist/index.d.ts +752 -51
- package/dist/index.js +1 -0
- package/dist/packem_shared/browserslistToEsbuild-HD6SaWPt.js +1 -0
- package/dist/packem_shared/esbuildPlugin-BStpbA6S.js +1 -0
- package/dist/packem_shared/swcPlugin-DBBN5mct.js +1 -0
- package/dist/packem_shared/types.d-Dmpk2asd.d.ts +7 -0
- package/dist/packem_shared/types.d-DrgzeMBs.d-CG9J1x6q.d.ts +6 -0
- package/dist/packem_shared/types.d-KBgVO47q.d.ts +658 -0
- package/dist/plugins/chunk-splitter/index.d.ts +3 -0
- package/dist/plugins/chunk-splitter/index.js +1 -0
- package/dist/plugins/cjs-interop.d.ts +11 -0
- package/dist/plugins/cjs-interop.js +2 -0
- package/dist/plugins/esbuild/index.d.ts +9 -23
- package/dist/plugins/esbuild/index.js +1 -0
- package/dist/plugins/json.d.ts +5 -0
- package/dist/plugins/json.js +1 -0
- package/dist/plugins/jsx-remove-attributes.d.ts +11 -0
- package/dist/plugins/jsx-remove-attributes.js +1 -0
- package/dist/plugins/preserve-directives.d.ts +15 -0
- package/dist/plugins/preserve-directives.js +4 -0
- package/dist/plugins/pure-new-expression-plugin.d.ts +12 -0
- package/dist/plugins/pure-new-expression-plugin.js +1 -0
- package/dist/plugins/sucrase/index.d.ts +100 -17
- package/dist/plugins/sucrase/index.js +1 -0
- package/dist/plugins/swc/index.d.ts +9 -24
- package/dist/plugins/swc/index.js +1 -0
- package/package.json +52 -53
- package/dist/index.d.mts +0 -56
- package/dist/index.mjs +0 -1
- package/dist/packem_shared/browserslist-to-esbuild-DY9HwYtp.d.mts +0 -3
- package/dist/packem_shared/browserslist-to-esbuild-DY9HwYtp.d.ts +0 -3
- package/dist/packem_shared/browserslistToEsbuild-C0IWmbNe.mjs +0 -1
- package/dist/packem_shared/cachingPlugin-D0BBFJPD.mjs +0 -1
- package/dist/packem_shared/chunkSplitter-DWAy1JkE.mjs +0 -1
- package/dist/packem_shared/cjsInteropPlugin-D5wyoQ_B.mjs +0 -2
- package/dist/packem_shared/copyPlugin--6RITp1-.mjs +0 -1
- package/dist/packem_shared/createSplitChunks-CGDk55G3.mjs +0 -1
- package/dist/packem_shared/dataUriPlugin-BOjv6O2O.mjs +0 -1
- package/dist/packem_shared/esbuildPlugin-BAwyhG6L.mjs +0 -1
- package/dist/packem_shared/esmShimCjsSyntaxPlugin-DjKqX4DE.mjs +0 -11
- package/dist/packem_shared/fix-dts-default-cjs-exports-BQc0nwIG.mjs +0 -26
- package/dist/packem_shared/fixDtsDefaultCjsExportsPlugin-Dp1UcHVR.mjs +0 -1
- package/dist/packem_shared/fixDynamicImportExtension-BBGNRniz.mjs +0 -1
- package/dist/packem_shared/getCustomModuleLayer-d8i66lfh.mjs +0 -1
- package/dist/packem_shared/getModuleLayer-rF9RxnJ5.mjs +0 -1
- package/dist/packem_shared/index-Cj1Okk1t.mjs +0 -1
- package/dist/packem_shared/isolatedDeclarationsOxcTransformer-WbfE6cGu.mjs +0 -1
- package/dist/packem_shared/isolatedDeclarationsPlugin-A0wmmw3Y.mjs +0 -3
- package/dist/packem_shared/isolatedDeclarationsSwcTransformer-Ch2AgtWC.mjs +0 -1
- package/dist/packem_shared/isolatedDeclarationsTypescriptTransformer-DkuEkofo.mjs +0 -3
- package/dist/packem_shared/jsonPlugin-BAi3Da-h.mjs +0 -1
- package/dist/packem_shared/jsxRemoveAttributes-B1PLPffj.mjs +0 -1
- package/dist/packem_shared/licensePlugin-C5yzUqe-.mjs +0 -13
- package/dist/packem_shared/makeExecutable-6aOVHoJR.mjs +0 -4
- package/dist/packem_shared/metafilePlugin-ObS4J7mO.mjs +0 -1
- package/dist/packem_shared/oxcResolvePlugin-BJpi-eSG.mjs +0 -1
- package/dist/packem_shared/oxcTransformPlugin-DfVQouIB.mjs +0 -4
- package/dist/packem_shared/patchTypescriptTypes-BEdkvKxL.mjs +0 -6
- package/dist/packem_shared/preserveDirectivesPlugin-B49Cbykd.mjs +0 -4
- package/dist/packem_shared/rawPlugin-BqlR6ZOI.mjs +0 -1
- package/dist/packem_shared/resolveFileUrlPlugin-BkpjVHeK.mjs +0 -1
- package/dist/packem_shared/resolveTsconfigPathsPlugin-Crf4lzxq.mjs +0 -1
- package/dist/packem_shared/resolveTsconfigRootDirectoriesPlugin-_93afm2q.mjs +0 -1
- package/dist/packem_shared/resolveTypescriptMjsCtsPlugin-DcZrZTmM.mjs +0 -1
- package/dist/packem_shared/sourcemapsPlugin-B4W3J79w.mjs +0 -1
- package/dist/packem_shared/swcPlugin-Boip4lWG.mjs +0 -1
- package/dist/packem_shared/types-BKqesFEF.d.mts +0 -4548
- package/dist/packem_shared/types-BKqesFEF.d.ts +0 -4548
- package/dist/packem_shared/urlPlugin-Bm2IE00y.mjs +0 -1
- package/dist/plugins/esbuild/index.d.mts +0 -25
- package/dist/plugins/esbuild/index.mjs +0 -1
- package/dist/plugins/oxc/index.d.mts +0 -28
- package/dist/plugins/oxc/index.d.ts +0 -28
- package/dist/plugins/oxc/index.mjs +0 -1
- package/dist/plugins/sucrase/index.d.mts +0 -19
- package/dist/plugins/sucrase/index.mjs +0 -1
- package/dist/plugins/swc/index.d.mts +0 -26
- package/dist/plugins/swc/index.mjs +0 -1
- package/dist/plugins/typescript/index.d.mts +0 -29
- package/dist/plugins/typescript/index.d.ts +0 -29
- package/dist/plugins/typescript/index.mjs +0 -1
- /package/dist/packem_shared/{index-Dq8IUFTs.mjs → index-Dq8IUFTs.js} +0 -0
package/README.md
CHANGED
|
@@ -41,6 +41,93 @@ pnpm add @visulima/packem-rollup
|
|
|
41
41
|
|
|
42
42
|
## Usage
|
|
43
43
|
|
|
44
|
+
### Data URI Plugin
|
|
45
|
+
|
|
46
|
+
The `dataUriPlugin` converts files to data URIs for inline embedding. It supports configurable SVG encoding strategies via query parameters.
|
|
47
|
+
|
|
48
|
+
```typescript
|
|
49
|
+
import { dataUriPlugin } from "@visulima/packem-rollup";
|
|
50
|
+
|
|
51
|
+
export default {
|
|
52
|
+
plugins: [dataUriPlugin()],
|
|
53
|
+
};
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
#### Query Parameters
|
|
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
|
|
62
|
+
|
|
63
|
+
#### Examples
|
|
64
|
+
|
|
65
|
+
```typescript
|
|
66
|
+
// Tiny SVG encoding (default)
|
|
67
|
+
import icon from "./icon.svg?data-uri";
|
|
68
|
+
|
|
69
|
+
// CSS-optimized SVG encoding
|
|
70
|
+
import icon from "./icon.svg?data-uri&encoding=css";
|
|
71
|
+
|
|
72
|
+
// Tiny SVG with srcset compatibility
|
|
73
|
+
import icon from "./icon.svg?data-uri&srcset";
|
|
74
|
+
|
|
75
|
+
// CSS encoding with srcset compatibility
|
|
76
|
+
import icon from "./icon.svg?data-uri&encoding=css&srcset";
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Lazy Barrel Plugin
|
|
80
|
+
|
|
81
|
+
The `lazyBarrelPlugin` implements lazy barrel optimization similar to Rspack's `lazyBarrel` experiment. It identifies side-effect-free barrel files and marks their re-export dependencies as lazy, only building them when their exports are actually requested.
|
|
82
|
+
|
|
83
|
+
```typescript
|
|
84
|
+
import { lazyBarrelPlugin } from "@visulima/packem-rollup";
|
|
85
|
+
|
|
86
|
+
export default {
|
|
87
|
+
plugins: [
|
|
88
|
+
lazyBarrelPlugin({
|
|
89
|
+
sideEffectsCheck: true,
|
|
90
|
+
lazyThreshold: 2,
|
|
91
|
+
include: [/\.ts$/, /\.js$/],
|
|
92
|
+
exclude: [/\.test\.ts$/],
|
|
93
|
+
}),
|
|
94
|
+
],
|
|
95
|
+
};
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
#### Features
|
|
99
|
+
|
|
100
|
+
- **Barrel Detection**: Automatically identifies files with multiple re-exports
|
|
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
|
|
105
|
+
|
|
106
|
+
#### How It Works
|
|
107
|
+
|
|
108
|
+
1. **Analysis**: Parses module code to detect barrel export patterns
|
|
109
|
+
2. **Side Effects Check**: Verifies if the module is marked as side-effect-free
|
|
110
|
+
3. **Lazy Marking**: Marks re-export dependencies as lazy for deferred building
|
|
111
|
+
4. **Code Generation**: Creates lazy loading wrappers for unused exports
|
|
112
|
+
5. **Optimization**: Only builds modules when their exports are actually requested
|
|
113
|
+
|
|
114
|
+
### URL Plugin
|
|
115
|
+
|
|
116
|
+
The `urlPlugin` handles asset URLs, either inlining them as data URIs or copying them to a destination directory. SVG files are optimized using the shared `svgEncoder` utility before being base64 encoded.
|
|
117
|
+
|
|
118
|
+
```typescript
|
|
119
|
+
import { urlPlugin } from "@visulima/packem-rollup";
|
|
120
|
+
|
|
121
|
+
export default {
|
|
122
|
+
plugins: [
|
|
123
|
+
urlPlugin({
|
|
124
|
+
limit: 14336, // 14kb
|
|
125
|
+
fileName: "[hash][extname]",
|
|
126
|
+
}),
|
|
127
|
+
],
|
|
128
|
+
};
|
|
129
|
+
```
|
|
130
|
+
|
|
44
131
|
## Related
|
|
45
132
|
|
|
46
133
|
## Supported Node.js Versions
|
|
@@ -56,8 +143,8 @@ If you would like to help take a look at the [list of issues](https://github.com
|
|
|
56
143
|
|
|
57
144
|
## Credits
|
|
58
145
|
|
|
59
|
-
-
|
|
60
|
-
-
|
|
146
|
+
- [Daniel Bannert](https://github.com/prisis)
|
|
147
|
+
- [All Contributors](https://github.com/visulima/packem/graphs/contributors)
|
|
61
148
|
|
|
62
149
|
## License
|
|
63
150
|
|