@visulima/packem-share 1.0.0-alpha.1
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 +15 -0
- package/LICENSE.md +644 -0
- package/README.md +259 -0
- package/dist/constants/index.d.mts +38 -0
- package/dist/constants/index.d.ts +38 -0
- package/dist/constants/index.mjs +1 -0
- package/dist/index.d.mts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.mjs +1 -0
- package/dist/packem_shared/FileCache-DdOdmeil.mjs +1 -0
- package/dist/packem_shared/arrayIncludes-Car4Lj1a.mjs +1 -0
- package/dist/packem_shared/arrayify-CJp87iG7.mjs +1 -0
- package/dist/packem_shared/createRollupLogger-DyOYcur8.mjs +1 -0
- package/dist/packem_shared/enhanceRollupError-DmItfx-U.mjs +7 -0
- package/dist/packem_shared/getChunkFilename-C1wUJsM7.mjs +1 -0
- package/dist/packem_shared/getEntryFileNames-DF1zHqbH.mjs +1 -0
- package/dist/packem_shared/getHash-C4PDVNN_.mjs +1 -0
- package/dist/packem_shared/getPackageName-CwjDzCnN.mjs +1 -0
- package/dist/packem_shared/getRegexMatches-CIyZXB3k.mjs +1 -0
- package/dist/packem_shared/memoize-BTaub_3L.mjs +1 -0
- package/dist/packem_shared/replaceContentWithinMarker-DqHE825x.mjs +3 -0
- package/dist/packem_shared/sortUserPlugins-BeSpxWa9.mjs +1 -0
- package/dist/packem_shared/svgEncoder-BHLRmBWl.mjs +1 -0
- package/dist/packem_shared/warn-B6AJDQdJ.mjs +1 -0
- package/dist/types/index.d.mts +2605 -0
- package/dist/types/index.d.ts +2605 -0
- package/dist/types/index.mjs +0 -0
- package/dist/utils/index.d.mts +87 -0
- package/dist/utils/index.d.ts +87 -0
- package/dist/utils/index.mjs +1 -0
- package/package.json +75 -0
package/README.md
ADDED
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<h3>@visulima/packem-share</h3>
|
|
3
|
+
<p>
|
|
4
|
+
Shared utilities, constants, and types for the Packem ecosystem
|
|
5
|
+
</p>
|
|
6
|
+
</div>
|
|
7
|
+
|
|
8
|
+
<br />
|
|
9
|
+
|
|
10
|
+
<div align="center">
|
|
11
|
+
|
|
12
|
+
[![typescript-image]][typescript-url] [![npm-image]][npm-url] [![license-image]][license-url]
|
|
13
|
+
|
|
14
|
+
</div>
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
<div align="center">
|
|
19
|
+
<p>
|
|
20
|
+
<sup>
|
|
21
|
+
Daniel Bannert's open source work is supported by the community on <a href="https://github.com/sponsors/prisis">GitHub Sponsors</a>
|
|
22
|
+
</sup>
|
|
23
|
+
</p>
|
|
24
|
+
</div>
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## About
|
|
29
|
+
|
|
30
|
+
`@visulima/packem-share` is a shared utility library that provides common functionality used across the Packem ecosystem. It eliminates code duplication by centralizing frequently used utilities, constants, and TypeScript types.
|
|
31
|
+
|
|
32
|
+
This package was created as part of a code deduplication effort that eliminated ~20KB of duplicate code across multiple Packem packages while maintaining full backward compatibility.
|
|
33
|
+
|
|
34
|
+
## Install
|
|
35
|
+
|
|
36
|
+
```sh
|
|
37
|
+
npm install @visulima/packem-share
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
```sh
|
|
41
|
+
yarn add @visulima/packem-share
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
```sh
|
|
45
|
+
pnpm add @visulima/packem-share
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Usage
|
|
49
|
+
|
|
50
|
+
The package provides multiple import patterns for maximum flexibility:
|
|
51
|
+
|
|
52
|
+
### Direct Named Imports
|
|
53
|
+
```typescript
|
|
54
|
+
import { arrayify, getHash, FileCache, Environment, Mode } from "@visulima/packem-share";
|
|
55
|
+
|
|
56
|
+
// Use utilities directly
|
|
57
|
+
const result = arrayify("single-value"); // ["single-value"]
|
|
58
|
+
const hash = getHash("content");
|
|
59
|
+
const cache = new FileCache("/path", "/cache", "key", logger);
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Module-based Imports
|
|
63
|
+
```typescript
|
|
64
|
+
import { constants, types, utils } from "@visulima/packem-share";
|
|
65
|
+
|
|
66
|
+
// Access grouped exports
|
|
67
|
+
const extensions = constants.DEFAULT_EXTENSIONS;
|
|
68
|
+
const mode: types.Mode = "build";
|
|
69
|
+
const normalized = utils.arrayify([1, 2, 3]);
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Namespace Imports
|
|
73
|
+
```typescript
|
|
74
|
+
import * as PackemShare from "@visulima/packem-share";
|
|
75
|
+
|
|
76
|
+
// Access everything through namespace
|
|
77
|
+
const result = PackemShare.arrayify("value");
|
|
78
|
+
const hash = PackemShare.getHash("content");
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Individual Module Imports
|
|
82
|
+
```typescript
|
|
83
|
+
import * as constants from "@visulima/packem-share/constants";
|
|
84
|
+
import * as types from "@visulima/packem-share/types";
|
|
85
|
+
import * as utils from "@visulima/packem-share/utils";
|
|
86
|
+
|
|
87
|
+
// Import specific modules
|
|
88
|
+
const extensions = constants.DEFAULT_EXTENSIONS;
|
|
89
|
+
const normalized = utils.arrayify("value");
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## API Reference
|
|
93
|
+
|
|
94
|
+
### Constants
|
|
95
|
+
|
|
96
|
+
Core constants used throughout the Packem ecosystem:
|
|
97
|
+
|
|
98
|
+
```typescript
|
|
99
|
+
import {
|
|
100
|
+
DEFAULT_EXTENSIONS,
|
|
101
|
+
DEFAULT_LOADERS,
|
|
102
|
+
PRODUCTION_ENV,
|
|
103
|
+
DEVELOPMENT_ENV,
|
|
104
|
+
RUNTIME_EXPORT_CONVENTIONS,
|
|
105
|
+
SPECIAL_EXPORT_CONVENTIONS,
|
|
106
|
+
EXCLUDE_REGEXP,
|
|
107
|
+
ENDING_REGEX,
|
|
108
|
+
CHUNKS_PACKEM_FOLDER,
|
|
109
|
+
SHARED_PACKEM_FOLDER,
|
|
110
|
+
ALLOWED_TRANSFORM_EXTENSIONS_REGEX
|
|
111
|
+
} from "@visulima/packem-share";
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Types
|
|
115
|
+
|
|
116
|
+
TypeScript type definitions for the Packem ecosystem:
|
|
117
|
+
|
|
118
|
+
```typescript
|
|
119
|
+
import type { Environment, Mode, Format, Runtime } from "@visulima/packem-share";
|
|
120
|
+
|
|
121
|
+
type Environment = "production" | "development" | undefined;
|
|
122
|
+
type Mode = "build" | "jit" | "watch";
|
|
123
|
+
type Format = "cjs" | "esm";
|
|
124
|
+
type Runtime = "browser" | "bun" | "deno" | "edge-light" | "electron" | "node" | "react-native" | "react-server" | "workerd" | undefined;
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### Utilities
|
|
128
|
+
|
|
129
|
+
#### Array Utilities
|
|
130
|
+
```typescript
|
|
131
|
+
import { arrayify, arrayIncludes } from "@visulima/packem-share";
|
|
132
|
+
|
|
133
|
+
// Convert single values to arrays
|
|
134
|
+
arrayify("single") // ["single"]
|
|
135
|
+
arrayify(["already", "array"]) // ["already", "array"]
|
|
136
|
+
arrayify(null) // []
|
|
137
|
+
|
|
138
|
+
// Array search with RegExp support
|
|
139
|
+
arrayIncludes(["test.js", "test.ts"], /\.ts$/) // true
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
#### File System Utilities
|
|
143
|
+
```typescript
|
|
144
|
+
import {
|
|
145
|
+
FileCache,
|
|
146
|
+
getChunkFilename,
|
|
147
|
+
getEntryFileNames,
|
|
148
|
+
getHash
|
|
149
|
+
} from "@visulima/packem-share";
|
|
150
|
+
|
|
151
|
+
// File caching
|
|
152
|
+
const cache = new FileCache(cwd, cachePath, hashKey, logger);
|
|
153
|
+
cache.set("key", data);
|
|
154
|
+
const cached = cache.get("key");
|
|
155
|
+
|
|
156
|
+
// Filename generation
|
|
157
|
+
const chunkName = getChunkFilename("chunk", hash, format);
|
|
158
|
+
const entryNames = getEntryFileNames(entries, format);
|
|
159
|
+
|
|
160
|
+
// Content hashing
|
|
161
|
+
const hash = getHash("file content");
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
#### String and Content Utilities
|
|
165
|
+
```typescript
|
|
166
|
+
import {
|
|
167
|
+
getPackageName,
|
|
168
|
+
getRegexMatches,
|
|
169
|
+
replaceContentWithinMarker,
|
|
170
|
+
svgEncoder,
|
|
171
|
+
warn
|
|
172
|
+
} from "@visulima/packem-share";
|
|
173
|
+
|
|
174
|
+
// Package name extraction
|
|
175
|
+
getPackageName("@scope/package/path") // "@scope/package"
|
|
176
|
+
getPackageName("package/path") // "package"
|
|
177
|
+
|
|
178
|
+
// Regex utilities
|
|
179
|
+
const matches = getRegexMatches(/pattern/g, "text");
|
|
180
|
+
|
|
181
|
+
// Content replacement
|
|
182
|
+
const updated = replaceContentWithinMarker(content, "marker", newContent);
|
|
183
|
+
|
|
184
|
+
// SVG encoding
|
|
185
|
+
const encoded = svgEncoder(svgContent);
|
|
186
|
+
|
|
187
|
+
// Warning utilities
|
|
188
|
+
warn(logger, "Warning message", "prefix");
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
#### Performance Utilities
|
|
192
|
+
```typescript
|
|
193
|
+
import { memoize, memoizeByKey } from "@visulima/packem-share";
|
|
194
|
+
|
|
195
|
+
// Function memoization
|
|
196
|
+
const memoized = memoize(expensiveFunction);
|
|
197
|
+
const keyMemoized = memoizeByKey(expensiveFunction)("cache-key");
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
#### Build System Utilities
|
|
201
|
+
```typescript
|
|
202
|
+
import {
|
|
203
|
+
enhanceRollupError,
|
|
204
|
+
sortUserPlugins
|
|
205
|
+
} from "@visulima/packem-share";
|
|
206
|
+
|
|
207
|
+
// Error enhancement
|
|
208
|
+
const enhanced = enhanceRollupError(error, context);
|
|
209
|
+
|
|
210
|
+
// Plugin sorting
|
|
211
|
+
const [pre, normal, post] = sortUserPlugins(plugins, hookName);
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
## Migration from Individual Packages
|
|
215
|
+
|
|
216
|
+
If you were previously importing utilities from `@visulima/packem` or `@visulima/packem-rollup`, you can now import them directly from this shared package:
|
|
217
|
+
|
|
218
|
+
```typescript
|
|
219
|
+
// Before
|
|
220
|
+
import { arrayify } from "@visulima/packem/utils";
|
|
221
|
+
import { getHash } from "@visulima/packem-rollup/utils";
|
|
222
|
+
|
|
223
|
+
// After
|
|
224
|
+
import { arrayify, getHash } from "@visulima/packem-share";
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
Note: The original packages still re-export these utilities for backward compatibility.
|
|
228
|
+
|
|
229
|
+
## Related
|
|
230
|
+
|
|
231
|
+
- [@visulima/packem](https://www.npmjs.com/package/@visulima/packem) - Modern JavaScript bundler
|
|
232
|
+
- [@visulima/packem-rollup](https://www.npmjs.com/package/@visulima/packem-rollup) - Rollup-based bundling utilities
|
|
233
|
+
|
|
234
|
+
## Supported Node.js Versions
|
|
235
|
+
|
|
236
|
+
Libraries in this ecosystem make the best effort to track [Node.js' release schedule](https://github.com/nodejs/release#release-schedule).
|
|
237
|
+
Here's [a post on why we think this is important](https://medium.com/the-node-js-collection/maintainers-should-consider-following-node-js-release-schedule-ab08ed4de71a).
|
|
238
|
+
|
|
239
|
+
## Contributing
|
|
240
|
+
|
|
241
|
+
If you would like to help take a look at the [list of issues](https://github.com/visulima/packem/issues) and check our [Contributing](.github/CONTRIBUTING.md) guidelines.
|
|
242
|
+
|
|
243
|
+
> **Note:** please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.
|
|
244
|
+
|
|
245
|
+
## Credits
|
|
246
|
+
|
|
247
|
+
- [Daniel Bannert](https://github.com/prisis)
|
|
248
|
+
- [All Contributors](https://github.com/visulima/packem/graphs/contributors)
|
|
249
|
+
|
|
250
|
+
## License
|
|
251
|
+
|
|
252
|
+
The @visulima/packem-share is open-sourced software licensed under the [MIT][license-url]
|
|
253
|
+
|
|
254
|
+
[typescript-image]: https://img.shields.io/badge/Typescript-294E80.svg?style=for-the-badge&logo=typescript
|
|
255
|
+
[typescript-url]: "typescript"
|
|
256
|
+
[license-image]: https://img.shields.io/npm/l/@visulima/packem-share?color=blueviolet&style=for-the-badge
|
|
257
|
+
[license-url]: LICENSE.md "license"
|
|
258
|
+
[npm-image]: https://img.shields.io/npm/v/@visulima/packem-share/latest.svg?style=for-the-badge&logo=npm
|
|
259
|
+
[npm-url]: https://www.npmjs.com/package/@visulima/packem-share/v/latest "npm"
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
type Loader = 'base64' | 'binary' | 'copy' | 'css' | 'dataurl' | 'default' | 'empty' | 'file' | 'js' | 'json' | 'jsx' | 'local-css' | 'text' | 'ts' | 'tsx'
|
|
2
|
+
|
|
3
|
+
// Note: These declarations exist to avoid type errors when you omit "dom" from
|
|
4
|
+
// "lib" in your "tsconfig.json" file. TypeScript confusingly declares the
|
|
5
|
+
// global "WebAssembly" type in "lib.dom.d.ts" even though it has nothing to do
|
|
6
|
+
// with the browser DOM and is present in many non-browser JavaScript runtimes
|
|
7
|
+
// (e.g. node and deno). Declaring it here allows esbuild's API to be used in
|
|
8
|
+
// these scenarios.
|
|
9
|
+
//
|
|
10
|
+
// There's an open issue about getting this problem corrected (although these
|
|
11
|
+
// declarations will need to remain even if this is fixed for backward
|
|
12
|
+
// compatibility with older TypeScript versions):
|
|
13
|
+
//
|
|
14
|
+
// https://github.com/microsoft/TypeScript-DOM-lib-generator/issues/826
|
|
15
|
+
//
|
|
16
|
+
declare global {
|
|
17
|
+
namespace WebAssembly {
|
|
18
|
+
interface Module {
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
interface URL {
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
declare const VALID_EXPORT_EXTENSIONS: ReadonlyArray<string>;
|
|
26
|
+
declare const DEFAULT_EXTENSIONS: string[];
|
|
27
|
+
declare const DEFAULT_LOADERS: Record<string, Loader>;
|
|
28
|
+
declare const PRODUCTION_ENV: string;
|
|
29
|
+
declare const DEVELOPMENT_ENV: string;
|
|
30
|
+
declare const RUNTIME_EXPORT_CONVENTIONS: Set<string>;
|
|
31
|
+
declare const SPECIAL_EXPORT_CONVENTIONS: Set<string>;
|
|
32
|
+
declare const EXCLUDE_REGEXP: RegExp;
|
|
33
|
+
declare const ENDING_REGEX: RegExp;
|
|
34
|
+
declare const CHUNKS_PACKEM_FOLDER: string;
|
|
35
|
+
declare const SHARED_PACKEM_FOLDER: string;
|
|
36
|
+
declare const ALLOWED_TRANSFORM_EXTENSIONS_REGEX: RegExp;
|
|
37
|
+
|
|
38
|
+
export { ALLOWED_TRANSFORM_EXTENSIONS_REGEX, CHUNKS_PACKEM_FOLDER, DEFAULT_EXTENSIONS, DEFAULT_LOADERS, DEVELOPMENT_ENV, ENDING_REGEX, EXCLUDE_REGEXP, PRODUCTION_ENV, RUNTIME_EXPORT_CONVENTIONS, SHARED_PACKEM_FOLDER, SPECIAL_EXPORT_CONVENTIONS, VALID_EXPORT_EXTENSIONS };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
type Loader = 'base64' | 'binary' | 'copy' | 'css' | 'dataurl' | 'default' | 'empty' | 'file' | 'js' | 'json' | 'jsx' | 'local-css' | 'text' | 'ts' | 'tsx'
|
|
2
|
+
|
|
3
|
+
// Note: These declarations exist to avoid type errors when you omit "dom" from
|
|
4
|
+
// "lib" in your "tsconfig.json" file. TypeScript confusingly declares the
|
|
5
|
+
// global "WebAssembly" type in "lib.dom.d.ts" even though it has nothing to do
|
|
6
|
+
// with the browser DOM and is present in many non-browser JavaScript runtimes
|
|
7
|
+
// (e.g. node and deno). Declaring it here allows esbuild's API to be used in
|
|
8
|
+
// these scenarios.
|
|
9
|
+
//
|
|
10
|
+
// There's an open issue about getting this problem corrected (although these
|
|
11
|
+
// declarations will need to remain even if this is fixed for backward
|
|
12
|
+
// compatibility with older TypeScript versions):
|
|
13
|
+
//
|
|
14
|
+
// https://github.com/microsoft/TypeScript-DOM-lib-generator/issues/826
|
|
15
|
+
//
|
|
16
|
+
declare global {
|
|
17
|
+
namespace WebAssembly {
|
|
18
|
+
interface Module {
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
interface URL {
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
declare const VALID_EXPORT_EXTENSIONS: ReadonlyArray<string>;
|
|
26
|
+
declare const DEFAULT_EXTENSIONS: string[];
|
|
27
|
+
declare const DEFAULT_LOADERS: Record<string, Loader>;
|
|
28
|
+
declare const PRODUCTION_ENV: string;
|
|
29
|
+
declare const DEVELOPMENT_ENV: string;
|
|
30
|
+
declare const RUNTIME_EXPORT_CONVENTIONS: Set<string>;
|
|
31
|
+
declare const SPECIAL_EXPORT_CONVENTIONS: Set<string>;
|
|
32
|
+
declare const EXCLUDE_REGEXP: RegExp;
|
|
33
|
+
declare const ENDING_REGEX: RegExp;
|
|
34
|
+
declare const CHUNKS_PACKEM_FOLDER: string;
|
|
35
|
+
declare const SHARED_PACKEM_FOLDER: string;
|
|
36
|
+
declare const ALLOWED_TRANSFORM_EXTENSIONS_REGEX: RegExp;
|
|
37
|
+
|
|
38
|
+
export { ALLOWED_TRANSFORM_EXTENSIONS_REGEX, CHUNKS_PACKEM_FOLDER, DEFAULT_EXTENSIONS, DEFAULT_LOADERS, DEVELOPMENT_ENV, ENDING_REGEX, EXCLUDE_REGEXP, PRODUCTION_ENV, RUNTIME_EXPORT_CONVENTIONS, SHARED_PACKEM_FOLDER, SPECIAL_EXPORT_CONVENTIONS, VALID_EXPORT_EXTENSIONS };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const s=[".js",".mjs",".cjs",".ts",".mts",".cts",".d.ts",".d.mts",".d.cts",".jsx",".tsx",".json",".node"],_=[...s,".ctsx",".mtsx"],N={".aac":"file",".cjs":"js",".cts":"ts",".ctsx":"tsx",".eot":"file",".flac":"file",".js":"js",".jsx":"jsx",".mjs":"js",".mp3":"file",".mp4":"file",".mts":"ts",".mtsx":"tsx",".ogg":"file",".otf":"file",".ts":"ts",".tsx":"tsx",".ttf":"file",".wav":"file",".webm":"file",".woff":"file",".woff2":"file"},t="production",E="development",e=new Set(["edge-light","react-native","react-server"]),f=new Set([E,t,...e]),c=/node_modules/,O=/(?:\.d\.[mc]?tsx?|\.\w+)$/,l="packem_chunks",m="packem_shared",i=/\.(?:m|c)?(?:j|t)sx?$/;export{i as ALLOWED_TRANSFORM_EXTENSIONS_REGEX,l as CHUNKS_PACKEM_FOLDER,_ as DEFAULT_EXTENSIONS,N as DEFAULT_LOADERS,E as DEVELOPMENT_ENV,O as ENDING_REGEX,c as EXCLUDE_REGEXP,t as PRODUCTION_ENV,e as RUNTIME_EXPORT_CONVENTIONS,m as SHARED_PACKEM_FOLDER,f as SPECIAL_EXPORT_CONVENTIONS,s as VALID_EXPORT_EXTENSIONS};
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { ALLOWED_TRANSFORM_EXTENSIONS_REGEX, CHUNKS_PACKEM_FOLDER, DEFAULT_EXTENSIONS, DEFAULT_LOADERS, DEVELOPMENT_ENV, ENDING_REGEX, EXCLUDE_REGEXP, PRODUCTION_ENV, RUNTIME_EXPORT_CONVENTIONS, SHARED_PACKEM_FOLDER, SPECIAL_EXPORT_CONVENTIONS, VALID_EXPORT_EXTENSIONS } from './constants/index.mjs';
|
|
2
|
+
export { BuildContext, BuildContextBuildAssetAndChunk, BuildContextBuildEntry, BuildHooks, Environment, Format, Mode, Runtime } from './types/index.mjs';
|
|
3
|
+
export { FileCache, RollupLogger, arrayIncludes, arrayify, createRollupLogger, enhanceRollupError, getChunkFilename, getEntryFileNames, getHash, getPackageName, getRegexMatches, memoize, memoizeByKey, replaceContentWithinMarker, sortUserPlugins, svgEncoder, warn } from './utils/index.mjs';
|
|
4
|
+
import '@visulima/package';
|
|
5
|
+
import '@visulima/colorize';
|
|
6
|
+
import 'rollup';
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { ALLOWED_TRANSFORM_EXTENSIONS_REGEX, CHUNKS_PACKEM_FOLDER, DEFAULT_EXTENSIONS, DEFAULT_LOADERS, DEVELOPMENT_ENV, ENDING_REGEX, EXCLUDE_REGEXP, PRODUCTION_ENV, RUNTIME_EXPORT_CONVENTIONS, SHARED_PACKEM_FOLDER, SPECIAL_EXPORT_CONVENTIONS, VALID_EXPORT_EXTENSIONS } from './constants/index.js';
|
|
2
|
+
export { BuildContext, BuildContextBuildAssetAndChunk, BuildContextBuildEntry, BuildHooks, Environment, Format, Mode, Runtime } from './types/index.js';
|
|
3
|
+
export { FileCache, RollupLogger, arrayIncludes, arrayify, createRollupLogger, enhanceRollupError, getChunkFilename, getEntryFileNames, getHash, getPackageName, getRegexMatches, memoize, memoizeByKey, replaceContentWithinMarker, sortUserPlugins, svgEncoder, warn } from './utils/index.js';
|
|
4
|
+
import '@visulima/package';
|
|
5
|
+
import '@visulima/colorize';
|
|
6
|
+
import 'rollup';
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{ALLOWED_TRANSFORM_EXTENSIONS_REGEX as a,CHUNKS_PACKEM_FOLDER as o,DEFAULT_EXTENSIONS as t,DEFAULT_LOADERS as E,DEVELOPMENT_ENV as f,ENDING_REGEX as l,EXCLUDE_REGEXP as m,PRODUCTION_ENV as N,RUNTIME_EXPORT_CONVENTIONS as s,SHARED_PACKEM_FOLDER as p,SPECIAL_EXPORT_CONVENTIONS as _,VALID_EXPORT_EXTENSIONS as u}from"./constants/index.mjs";import{default as x}from"./packem_shared/arrayIncludes-Car4Lj1a.mjs";import{default as d}from"./packem_shared/arrayify-CJp87iG7.mjs";import{default as S}from"./packem_shared/enhanceRollupError-DmItfx-U.mjs";import{default as D}from"./packem_shared/FileCache-DdOdmeil.mjs";import{default as g}from"./packem_shared/getChunkFilename-C1wUJsM7.mjs";import{default as I}from"./packem_shared/getEntryFileNames-DF1zHqbH.mjs";import{default as A}from"./packem_shared/getHash-C4PDVNN_.mjs";import{default as i}from"./packem_shared/getPackageName-CwjDzCnN.mjs";import{default as F}from"./packem_shared/getRegexMatches-CIyZXB3k.mjs";import{default as U}from"./packem_shared/replaceContentWithinMarker-DqHE825x.mjs";import{default as y}from"./packem_shared/sortUserPlugins-BeSpxWa9.mjs";import{default as G}from"./packem_shared/svgEncoder-BHLRmBWl.mjs";import{default as k}from"./packem_shared/warn-B6AJDQdJ.mjs";import{createRollupLogger as z}from"./packem_shared/createRollupLogger-DyOYcur8.mjs";import{memoize as v,memoizeByKey as w}from"./packem_shared/memoize-BTaub_3L.mjs";export{a as ALLOWED_TRANSFORM_EXTENSIONS_REGEX,o as CHUNKS_PACKEM_FOLDER,t as DEFAULT_EXTENSIONS,E as DEFAULT_LOADERS,f as DEVELOPMENT_ENV,l as ENDING_REGEX,m as EXCLUDE_REGEXP,D as FileCache,N as PRODUCTION_ENV,s as RUNTIME_EXPORT_CONVENTIONS,p as SHARED_PACKEM_FOLDER,_ as SPECIAL_EXPORT_CONVENTIONS,u as VALID_EXPORT_EXTENSIONS,x as arrayIncludes,d as arrayify,z as createRollupLogger,S as enhanceRollupError,g as getChunkFilename,I as getEntryFileNames,A as getHash,i as getPackageName,F as getRegexMatches,v as memoize,w as memoizeByKey,U as replaceContentWithinMarker,y as sortUserPlugins,G as svgEncoder,k as warn};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var S=Object.defineProperty;var n=(r,e)=>S(r,"name",{value:e,configurable:!0});import{isAccessibleSync as g,readFileSync as k,writeFileSync as M}from"@visulima/fs";import{toNamespacedPath as m,join as P}from"@visulima/path";var W=Object.defineProperty,b=n(r=>{throw TypeError(r)},"y"),y=n((r,e)=>W(r,"name",{value:e,configurable:!0}),"d"),w=n((r,e,t)=>e.has(r)||b("Cannot "+t),"m"),a=n((r,e,t)=>(w(r,e,"read from private field"),t?t.call(r):e.get(r)),"r"),p=n((r,e,t)=>e.has(r)?b("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),"a"),u=n((r,e,t,s)=>(w(r,e,"write to private field"),e.set(r,t),t),"f");const C=y(r=>{try{JSON.parse(r)}catch{return!1}return!0},"isJson");var d,h,f,o,l,c;const F=(c=class{constructor(e,t,s,i){p(this,d),p(this,h),p(this,f),p(this,o,!0),p(this,l,new Map),u(this,d,e),u(this,f,s),t===void 0?i.debug({message:"Could not create cache directory."}):(u(this,h,t),i.debug({message:`Cache path is: ${a(this,h)}`}))}set isEnabled(e){u(this,o,e)}get isEnabled(){return a(this,o)}has(e,t){return!a(this,o)||a(this,h)===void 0?!1:g(this.getFilePath(e,t))}get(e,t){if(!a(this,o)||a(this,h)===void 0)return;const s=this.getFilePath(e,t);if(a(this,l).has(s))return a(this,l).get(s);if(!g(s))return;const i=k(s);if(C(i)){const v=JSON.parse(i);return a(this,l).set(s,v),v}return a(this,l).set(s,i),i}set(e,t,s){if(!a(this,o)||a(this,h)===void 0||t===void 0)return;const i=this.getFilePath(e,s);(typeof t=="object"||typeof t=="number"||typeof t=="boolean")&&(t=JSON.stringify(t)),M(i,t,{overwrite:!0})}getFilePath(e,t){let s=e.replaceAll(m(a(this,d)),"");return s=s.replaceAll(":","-"),P(a(this,h),a(this,f),t?.replaceAll(":","-")??"",m(s))}},n(c,"p"),c);d=new WeakMap,h=new WeakMap,f=new WeakMap,o=new WeakMap,l=new WeakMap,y(F,"FileCache");let O=F;export{O as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var t=Object.defineProperty;var n=(a,e)=>t(a,"name",{value:e,configurable:!0});var s=Object.defineProperty,c=n((a,e)=>s(a,"name",{value:e,configurable:!0}),"a");const u=c((a,e)=>a.some(r=>r instanceof RegExp?r.test(e):r===e),"arrayIncludes");export{u as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var n=Object.defineProperty;var r=(a,e)=>n(a,"name",{value:e,configurable:!0});var t=Object.defineProperty,l=r((a,e)=>t(a,"name",{value:e,configurable:!0}),"a");const y=l(a=>a==null?[]:Array.isArray(a)?a:[a],"arrayify");export{y as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var a=Object.defineProperty;var u=(e,r)=>a(e,"name",{value:r,configurable:!0});var l=Object.defineProperty,o=u((e,r)=>l(e,"name",{value:r,configurable:!0}),"s");const i=o((e,r)=>({debug:o(n=>{e.debug({...n,plugin:r})},"debug"),error:o(n=>{e.error({...n,plugin:r})},"error"),info:o(n=>{e.info({...n,plugin:r})},"info"),warn:o(n=>{e.warn({...n,plugin:r})},"warn")}),"createRollupLogger");export{i as createRollupLogger};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
var c=Object.defineProperty;var s=(e,r)=>c(e,"name",{value:r,configurable:!0});import{cyan as i,yellow as m}from"@visulima/colorize";var u=Object.defineProperty,l=s((e,r)=>u(e,"name",{value:r,configurable:!0}),"i");const $=l(e=>{const{message:r,name:a="Error",stack:t}=e;if(!t)return;const o=`${a}: ${r}
|
|
2
|
+
`;return t.startsWith(o)?t.slice(o.length):t},"extractStack"),g=l(e=>`
|
|
3
|
+
${e.replaceAll(/^\n|\n$/g,"")}
|
|
4
|
+
`,"normalizeCodeFrame"),d=l(e=>{const r=$(e);let a=(e.plugin?`[${e.plugin}] `:"")+e.message;e.id&&(a+=`
|
|
5
|
+
file: ${i(e.id+(e.loc?`:${e.loc.line}:${e.loc.column}`:""))}`),e.frame&&(a+=`
|
|
6
|
+
${m(g(e.frame))}`),e.message=a,r!==void 0&&(e.stack=`${e.message}
|
|
7
|
+
${r}`)},"enhanceRollupError");export{d as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var t=Object.defineProperty;var n=(e,a)=>t(e,"name",{value:a,configurable:!0});import{CHUNKS_PACKEM_FOLDER as r,SHARED_PACKEM_FOLDER as m}from"../constants/index.mjs";var i=Object.defineProperty,o=n((e,a)=>i(e,"name",{value:a,configurable:!0}),"n");const $=o((e,a)=>e.isDynamicEntry?`${r}/[name].${a}`:`${m}/${e.name}-[hash].${a}`,"getChunkFilename");export{$ as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var l=Object.defineProperty;var a=(r,e)=>l(r,"name",{value:e,configurable:!0});var s=Object.defineProperty,t=a((r,e)=>s(r,"name",{value:e,configurable:!0}),"o");const d=process.platform==="win32",m=t((r,e)=>{const o=d?"\\":"/";for(let n of Array.isArray(r.names)?r.names:[]){if(n.includes(`node_modules${o}.pnpm`))return n=`${n.replace(`node_modules${o}.pnpm`,"external")}.${e}`,n.replace(`node_modules${o}`,"");if(n.includes("node_modules"))return`${n.replace("node_modules","external")}.${e}`}return`[name].${e}`},"getEntryFileNames");export{m as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var r=Object.defineProperty;var t=(e,a)=>r(e,"name",{value:a,configurable:!0});import{createHash as o}from"node:crypto";var s=Object.defineProperty,i=t((e,a)=>s(e,"name",{value:a,configurable:!0}),"t");const d=i(e=>o("sha256").update(e).digest("hex"),"getHash");export{d as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var r=Object.defineProperty;var a=(t,e)=>r(t,"name",{value:e,configurable:!0});var n=Object.defineProperty,s=a((t,e)=>n(t,"name",{value:e,configurable:!0}),"a");const o=s((t="")=>{const e=t.split("/");return e[0].startsWith("@")?`${e[0]}/${e[1]}`:e[0]},"getPackageName");export{o as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var c=Object.defineProperty;var l=(e,t)=>c(e,"name",{value:t,configurable:!0});var s=Object.defineProperty,u=l((e,t)=>s(e,"name",{value:t,configurable:!0}),"r");const f=u((e,t)=>{const r=e,n=[];let a;for(;(a=r.exec(t))!==null;)a.index===r.lastIndex&&r.lastIndex++,a.forEach(o=>{n.push(o)});return n.filter(Boolean)},"getRegexMatches");export{f as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var u=Object.defineProperty;var s=(t,e)=>u(t,"name",{value:e,configurable:!0});var y=Object.defineProperty,c=s((t,e)=>y(t,"name",{value:e,configurable:!0}),"s");const f=c((t,e,n)=>{const r=n??new Map;return(...o)=>{const i=e?typeof e=="function"?e(...o):e:JSON.stringify({args:o}),a=r.get(i);if(a!==void 0)return a;const m=t(...o);return r.set(i,m),m}},"memoize"),g=c(t=>{const e=new Map;return n=>f(t,n,e)},"memoizeByKey");export{f as memoize,g as memoizeByKey};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
var c=Object.defineProperty;var a=(e,r)=>c(e,"name",{value:r,configurable:!0});var o=Object.defineProperty,s=a((e,r)=>o(e,"name",{value:r,configurable:!0}),"r");const l=s((e,r,n)=>{const t=new RegExp(`(<!-- ${r} -->)[\\s\\S]*?(<!-- /${r} -->)`,"g");if(t.test(e))return e.replace(t,`$1
|
|
2
|
+
${n}
|
|
3
|
+
$2`)},"replaceContentWithinMarker");export{l as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var i=Object.defineProperty;var p=(r,t)=>i(r,"name",{value:t,configurable:!0});var s=Object.defineProperty,a=p((r,t)=>s(r,"name",{value:t,configurable:!0}),"t");const n=a((r,t)=>{const o=[],u=[],l=[];return r&&r.filter(Boolean).filter(e=>e.type===t?!0:t==="build"&&e.type===void 0).forEach(e=>{e.enforce==="pre"?o.push(e.plugin):e.enforce==="post"?u.push(e.plugin):l.push(e.plugin)}),[o,l,u]},"sortUserPlugins");export{n as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var t=Object.defineProperty;var l=(r,e)=>t(r,"name",{value:e,configurable:!0});var a=Object.defineProperty,s=l((r,e)=>a(r,"name",{value:e,configurable:!0}),"r");const g=s(r=>{let e=r.toString("utf8");return e=e.replaceAll("//gs",""),e=e.replaceAll(/\s*\bclass\s*=\s*(?:"[^"]*"|'[^']*')/gi,""),e=e.replaceAll(/\s{2,}/g," "),e=e.replaceAll(/[\n\r\t]/g," "),e=e.replaceAll(/\s{2,}/g," "),e=e.trim(),Buffer.from(e,"utf8").toString("base64")},"svgEncoder");export{g as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var n=Object.defineProperty;var r=(a,e)=>n(a,"name",{value:e,configurable:!0});var t=Object.defineProperty,i=r((a,e)=>t(a,"name",{value:e,configurable:!0}),"i");const d=i((a,e)=>{a.warnings.has(e)||a.warnings.add(e)},"warn");export{d as default};
|