@visulima/packem 2.0.0-alpha.6 → 2.0.0-alpha.60
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 +732 -2
- package/LICENSE.md +552 -2582
- package/README.md +58 -12
- package/dist/builder/typedoc/generate-reference-documentation.d.ts +4 -0
- package/dist/builder/typedoc/index.d.ts +3 -26
- package/dist/builder/typedoc/index.js +3 -3
- package/dist/cli/commands/add.d.ts +4 -0
- package/dist/cli/commands/build.d.ts +21 -0
- package/dist/cli/commands/init.d.ts +3 -0
- package/dist/cli/commands/migrate.d.ts +21 -0
- package/dist/cli/commands/utils/css-loader-dependencies.d.ts +2 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +50 -37
- package/dist/config/index.d.ts +48 -28
- package/dist/config/preset/auto.d.ts +3 -0
- package/dist/config/preset/preact.d.ts +18 -0
- package/dist/config/preset/preact.js +2 -0
- package/dist/config/preset/react.d.ts +59 -0
- package/dist/config/preset/react.js +1 -0
- package/dist/config/preset/solid.d.ts +101 -0
- package/dist/config/preset/solid.js +1 -0
- package/dist/config/preset/svelte.d.ts +71 -0
- package/dist/config/preset/svelte.js +1 -0
- package/dist/config/preset/utils/infer-entries.d.ts +12 -0
- package/dist/config/preset/utils/overwrite-with-publish-config.d.ts +4 -0
- package/dist/config/preset/vue.d.ts +53 -0
- package/dist/config/preset/vue.js +1 -0
- package/dist/config/utils/find-packem-file.d.ts +2 -0
- package/dist/config/utils/load-env-file.d.ts +15 -0
- package/dist/config/utils/load-package-json.d.ts +6 -0
- package/dist/config/utils/load-packem-config.d.ts +7 -0
- package/dist/config/utils/load-preset.d.ts +4 -0
- package/dist/config/utils/load-tsconfig.d.ts +5 -0
- package/dist/config/utils/prepare-entries.d.ts +4 -0
- package/dist/index.d.ts +45 -32
- package/dist/index.js +1 -1
- package/dist/jit/create-stub.d.ts +4 -0
- package/dist/lib/concurrency.d.ts +6 -0
- package/dist/packem/build.d.ts +21 -0
- package/dist/packem/index.d.ts +24 -0
- package/dist/packem/node10-compatibility.d.ts +7 -0
- package/dist/packem/utils/brotli-size.d.ts +2 -0
- package/dist/packem/utils/group-by-keys.d.ts +12 -0
- package/dist/packem/utils/gzip-size.d.ts +2 -0
- package/dist/packem_shared/create-or-update-key-storage-U4wgANkm.js +1 -0
- package/dist/packem_shared/index-Bm8Oe89l.js +83 -0
- package/dist/rollup/build-types.d.ts +5 -0
- package/dist/rollup/build.d.ts +5 -0
- package/dist/rollup/get-rollup-options.d.ts +5 -0
- package/dist/rollup/plugins/css/loaders/less.d.ts +1 -1
- package/dist/rollup/plugins/css/loaders/less.js +1 -1
- package/dist/rollup/plugins/css/loaders/lightningcss.d.ts +1 -1
- package/dist/rollup/plugins/css/loaders/lightningcss.js +1 -1
- package/dist/rollup/plugins/css/loaders/postcss.d.ts +1 -1
- package/dist/rollup/plugins/css/loaders/postcss.js +1 -1
- package/dist/rollup/plugins/css/loaders/sass.d.ts +1 -1
- package/dist/rollup/plugins/css/loaders/sass.js +1 -1
- package/dist/rollup/plugins/css/loaders/sourcemap.d.ts +1 -8
- package/dist/rollup/plugins/css/loaders/sourcemap.js +1 -1
- package/dist/rollup/plugins/css/loaders/stylus.d.ts +1 -1
- package/dist/rollup/plugins/css/loaders/stylus.js +1 -1
- package/dist/rollup/plugins/css/loaders/tailwindcss.d.ts +1 -0
- package/dist/rollup/plugins/css/loaders/tailwindcss.js +1 -0
- package/dist/rollup/plugins/css/minifiers/cssnano.d.ts +1 -1
- package/dist/rollup/plugins/css/minifiers/cssnano.js +1 -1
- package/dist/rollup/plugins/css/minifiers/lightningcss.d.ts +1 -1
- package/dist/rollup/plugins/css/minifiers/lightningcss.js +1 -1
- package/dist/rollup/plugins/esbuild/index.d.ts +2 -24
- package/dist/rollup/plugins/esbuild/index.js +1 -1
- package/dist/rollup/plugins/externalize-dependencies.d.ts +28 -0
- package/dist/rollup/plugins/oxc/isolated-declarations-oxc-transformer.d.ts +1 -25
- package/dist/rollup/plugins/oxc/isolated-declarations-oxc-transformer.js +1 -1
- package/dist/rollup/plugins/oxc/oxc-transformer.d.ts +2 -20
- package/dist/rollup/plugins/oxc/oxc-transformer.js +1 -1
- package/dist/rollup/plugins/resolve-externals-plugin.d.ts +62 -0
- package/dist/rollup/plugins/resolve-implicit-externals.d.ts +21 -0
- package/dist/rollup/plugins/sucrase/index.d.ts +2 -19
- package/dist/rollup/plugins/sucrase/index.js +1 -1
- package/dist/rollup/plugins/swc/isolated-declarations-swc-transformer.d.ts +1 -20
- package/dist/rollup/plugins/swc/isolated-declarations-swc-transformer.js +1 -1
- package/dist/rollup/plugins/swc/swc-plugin.d.ts +2 -26
- package/dist/rollup/plugins/swc/swc-plugin.js +1 -1
- package/dist/rollup/plugins/typescript/isolated-declarations-typescript-transformer.d.ts +1 -24
- package/dist/rollup/plugins/typescript/isolated-declarations-typescript-transformer.js +1 -1
- package/dist/rollup/utils/resolve-aliases.d.ts +4 -0
- package/dist/rollup/watch.d.ts +5 -0
- package/dist/types.d.ts +335 -0
- package/dist/utils/clean-distribution-directories.d.ts +4 -0
- package/dist/utils/create-defu-with-hooks-merger.d.ts +14 -0
- package/dist/utils/create-or-update-key-storage.d.ts +3 -0
- package/dist/utils/extract-export-filenames.d.ts +16 -0
- package/dist/utils/find-alternatives.d.ts +2 -0
- package/dist/utils/get-package-side-effect.d.ts +3 -0
- package/dist/utils/import-specifier.d.ts +20 -0
- package/dist/utils/infer-export-type.d.ts +3 -0
- package/dist/utils/kill-process.d.ts +14 -0
- package/dist/utils/log-build-errors.d.ts +4 -0
- package/dist/utils/remove-old-cache-folders.d.ts +3 -0
- package/dist/utils/warn-legacy-cjs.d.ts +8 -0
- package/dist/validator/attw.d.ts +7 -0
- package/dist/validator/package-json/index.d.ts +4 -0
- package/dist/validator/package-json/validate-dependencies.d.ts +4 -0
- package/dist/validator/package-json/validate-engines.d.ts +4 -0
- package/dist/validator/package-json/validate-package-entries.d.ts +4 -0
- package/dist/validator/package-json/validate-package-fields.d.ts +4 -0
- package/dist/validator/validate-alias-entries.d.ts +3 -0
- package/dist/validator/validate-bundle-size.d.ts +4 -0
- package/files.d.ts +37 -0
- package/package.json +90 -36
- package/dist/packem_shared/browserslistToEsbuild-C0IWmbNe-C6xPL1oW.js +0 -1
- package/dist/packem_shared/create-or-update-key-storage-GwAIWW7R.js +0 -3
- package/dist/packem_shared/default-B6X7-Lx3.js +0 -1
- package/dist/packem_shared/default-B_dUKZ_J.js +0 -1
- package/dist/packem_shared/default-C3sdXf4G.js +0 -1
- package/dist/packem_shared/default-DR5Fia_R.js +0 -1
- package/dist/packem_shared/default-DqRcOUe1.js +0 -1
- package/dist/packem_shared/esbuildPlugin-BAwyhG6L-yty60jMl.js +0 -3
- package/dist/packem_shared/index-BHVpfOuE.js +0 -138
- package/dist/packem_shared/index-CUp9WuCG.js +0 -1
- package/dist/packem_shared/index-zikl8Yu3.d.ts +0 -5229
- package/dist/packem_shared/isolatedDeclarationsOxcTransformer-WbfE6cGu-NeZOx2Y7.js +0 -1
- package/dist/packem_shared/isolatedDeclarationsSwcTransformer-Ch2AgtWC-B-0lOgFf.js +0 -1
- package/dist/packem_shared/isolatedDeclarationsTypescriptTransformer-DkuEkofo-Cwe3ODMG.js +0 -3
- package/dist/packem_shared/oxcResolvePlugin-BJpi-eSG-BsYx9cDO.js +0 -1
- package/dist/packem_shared/oxcTransformPlugin-DfVQouIB-Cpfv95eA.js +0 -4
- package/dist/packem_shared/resolveTypescriptMjsCtsPlugin-DcZrZTmM-BEkYWTsH.js +0 -6
- package/dist/packem_shared/swcPlugin-Boip4lWG-CwJ-HVJc.js +0 -1
- package/dist/packem_shared/types-Dn9KmF6u.d.ts +0 -163
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { BabelPluginConfig } from "@visulima/packem-rollup/babel";
|
|
2
|
+
import type { BuildConfig } from "../../types.d.ts";
|
|
3
|
+
export interface ReactPresetOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Enable React Compiler optimization
|
|
6
|
+
* @default false
|
|
7
|
+
*/
|
|
8
|
+
compiler?: boolean | {
|
|
9
|
+
/**
|
|
10
|
+
* React Compiler compilation mode
|
|
11
|
+
* @default "infer"
|
|
12
|
+
*/
|
|
13
|
+
compilationMode?: "infer" | "annotation";
|
|
14
|
+
/**
|
|
15
|
+
* React Compiler panic threshold
|
|
16
|
+
* @default "critical_errors"
|
|
17
|
+
*/
|
|
18
|
+
panicThreshold?: "critical_errors" | "all_errors";
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Custom Babel plugins to add
|
|
22
|
+
*/
|
|
23
|
+
plugins?: BabelPluginConfig["plugins"];
|
|
24
|
+
/**
|
|
25
|
+
* Custom Babel presets to add
|
|
26
|
+
*/
|
|
27
|
+
presets?: BabelPluginConfig["presets"];
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* React preset for Packem. Configures Babel with React presets and optionally React Compiler.
|
|
31
|
+
* @description This preset configures Babel to run before your main transformer (esbuild/SWC/etc.).
|
|
32
|
+
* Babel handles JSX transformation, while TypeScript is handled by the transformer via parser plugins.
|
|
33
|
+
* This matches the approach used by @vitejs/plugin-react.
|
|
34
|
+
* @example
|
|
35
|
+
* ```typescript
|
|
36
|
+
* // Basic usage
|
|
37
|
+
* export default defineConfig({
|
|
38
|
+
* preset: "react"
|
|
39
|
+
* });
|
|
40
|
+
*
|
|
41
|
+
* // With React Compiler
|
|
42
|
+
* import { createReactPreset } from "@visulima/packem/config/preset/react";
|
|
43
|
+
* export default defineConfig({
|
|
44
|
+
* preset: createReactPreset({
|
|
45
|
+
* compiler: true
|
|
46
|
+
* })
|
|
47
|
+
* });
|
|
48
|
+
*
|
|
49
|
+
* // With custom options
|
|
50
|
+
* export default defineConfig({
|
|
51
|
+
* preset: createReactPreset({
|
|
52
|
+
* compiler: {
|
|
53
|
+
* compilationMode: "annotation"
|
|
54
|
+
* }
|
|
55
|
+
* })
|
|
56
|
+
* });
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export declare const createReactPreset: (options?: ReactPresetOptions) => BuildConfig;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var f=Object.defineProperty;var d=(o,e)=>f(o,"name",{value:e,configurable:!0});var m=Object.defineProperty,b=d((o,e)=>m(o,"name",{value:e,configurable:!0}),"s");const v=b((o={})=>{const{compiler:e=!1,plugins:a=[],presets:l=[]}=o,i=[],p=[];if(e){const s=typeof e=="object"?e:{};i.push(["babel-plugin-react-compiler",{compilationMode:s.compilationMode??"infer",panicThreshold:s.panicThreshold??"critical_errors"}])}p.push(["@babel/preset-react",{runtime:"automatic"}]);const c=[...i,...Array.isArray(a)?a:[]],u=[...p,...Array.isArray(l)?l:[]];return{hooks:{"rollup:options":b((s,h)=>{const r=s.options.rollup.babel;if(r&&typeof r=="object"&&r.presets){const n=r.presets.findIndex(t=>Array.isArray(t)&&t[0]==="@babel/preset-react");if(n!==-1){const t=r.presets[n];r.presets[n]=[t[0],{...typeof t[1]=="object"&&t[1]!==null?t[1]:{},development:s.environment==="development"}]}}},"rollup:options")},rollup:{babel:{plugins:c.length>0?c:void 0,presets:u.length>0?u:void 0}},validation:{dependencies:{hoisted:{exclude:[]},unused:{exclude:["react","react-dom"]}}}}},"createReactPreset");export{v as createReactPreset};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import type { BabelPluginConfig } from "@visulima/packem-rollup/babel";
|
|
2
|
+
import type { BuildConfig } from "../../types.d.ts";
|
|
3
|
+
export interface SolidPresetOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Pass any additional babel transform options. They will be merged with
|
|
6
|
+
* the transformations required by Solid.
|
|
7
|
+
*/
|
|
8
|
+
babel?: BabelPluginConfig | ((source: string, id: string) => BabelPluginConfig | Promise<BabelPluginConfig>);
|
|
9
|
+
/**
|
|
10
|
+
* Custom Babel plugins to add
|
|
11
|
+
*/
|
|
12
|
+
plugins?: BabelPluginConfig["plugins"];
|
|
13
|
+
/**
|
|
14
|
+
* Custom Babel presets to add
|
|
15
|
+
*/
|
|
16
|
+
presets?: BabelPluginConfig["presets"];
|
|
17
|
+
/**
|
|
18
|
+
* SolidJS-specific options for babel-preset-solid
|
|
19
|
+
*/
|
|
20
|
+
solidOptions?: {
|
|
21
|
+
/**
|
|
22
|
+
* Array of Component exports from module, that aren't included by default with the library.
|
|
23
|
+
* This plugin will automatically import them if it comes across them in the JSX.
|
|
24
|
+
* @default ["For","Show","Switch","Match","Suspense","SuspenseList","Portal","Index","Dynamic","ErrorBoundary"]
|
|
25
|
+
*/
|
|
26
|
+
builtIns?: string[];
|
|
27
|
+
/**
|
|
28
|
+
* Boolean indicates whether to set current render context on Custom Elements and slots.
|
|
29
|
+
* Useful for seemless Context API with Web Components.
|
|
30
|
+
* @default true
|
|
31
|
+
*/
|
|
32
|
+
contextToCustomElements?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Boolean to indicate whether to enable automatic event delegation on camelCase.
|
|
35
|
+
* @default true
|
|
36
|
+
*/
|
|
37
|
+
delegateEvents?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* The output mode of the compiler.
|
|
40
|
+
* Can be:
|
|
41
|
+
* - "dom" is standard output
|
|
42
|
+
* - "ssr" is for server side rendering of strings.
|
|
43
|
+
* - "universal" is for using custom renderers from solid-js/universal
|
|
44
|
+
* @default "dom"
|
|
45
|
+
*/
|
|
46
|
+
generate?: "ssr" | "dom" | "universal";
|
|
47
|
+
/**
|
|
48
|
+
* Indicate whether the output should contain hydratable markers.
|
|
49
|
+
* @default false
|
|
50
|
+
*/
|
|
51
|
+
hydratable?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* The name of the runtime module to import the methods from.
|
|
54
|
+
* @default "solid-js/web"
|
|
55
|
+
*/
|
|
56
|
+
moduleName?: string;
|
|
57
|
+
/**
|
|
58
|
+
* Boolean indicates whether smart conditional detection should be used.
|
|
59
|
+
* This optimizes simple boolean expressions and ternaries in JSX.
|
|
60
|
+
* @default true
|
|
61
|
+
*/
|
|
62
|
+
wrapConditionals?: boolean;
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* SolidJS preset for Packem. Configures Babel with babel-preset-solid.
|
|
67
|
+
* @description This preset configures Babel to run before your main transformer (esbuild/SWC/etc.).
|
|
68
|
+
* Babel handles JSX transformation for SolidJS using babel-preset-solid. TypeScript is handled
|
|
69
|
+
* automatically via parser plugins based on file extensions (no preset needed).
|
|
70
|
+
* @example
|
|
71
|
+
* ```typescript
|
|
72
|
+
* // Basic usage
|
|
73
|
+
* export default defineConfig({
|
|
74
|
+
* preset: "solid"
|
|
75
|
+
* });
|
|
76
|
+
*
|
|
77
|
+
* // With custom Solid options
|
|
78
|
+
* import { createSolidPreset } from "@visulima/packem/config/preset/solid";
|
|
79
|
+
* export default defineConfig({
|
|
80
|
+
* preset: createSolidPreset({
|
|
81
|
+
* solidOptions: {
|
|
82
|
+
* generate: "ssr",
|
|
83
|
+
* hydratable: true
|
|
84
|
+
* }
|
|
85
|
+
* })
|
|
86
|
+
* });
|
|
87
|
+
*
|
|
88
|
+
* // With custom Babel options
|
|
89
|
+
* export default defineConfig({
|
|
90
|
+
* preset: createSolidPreset({
|
|
91
|
+
* solidOptions: {
|
|
92
|
+
* moduleName: "solid-js/web"
|
|
93
|
+
* },
|
|
94
|
+
* babel: {
|
|
95
|
+
* // Additional babel options
|
|
96
|
+
* }
|
|
97
|
+
* })
|
|
98
|
+
* });
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
export declare const createSolidPreset: (options?: SolidPresetOptions) => BuildConfig;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var j=Object.defineProperty;var g=(o,e)=>j(o,"name",{value:e,configurable:!0});var O=Object.defineProperty,a=g((o,e)=>O(o,"name",{value:e,configurable:!0}),"a");const N=a(o=>{const e={contextToCustomElements:o?.contextToCustomElements??!0,delegateEvents:o?.delegateEvents??!0,generate:o?.generate??"dom",hydratable:o?.hydratable??!1,moduleName:o?.moduleName??"solid-js/web",wrapConditionals:o?.wrapConditionals??!0};return o?.builtIns!==void 0&&(e.builtIns=o.builtIns),e},"buildSolidPresetOptions"),E=a((o,e,n,l)=>{if(!e||typeof e=="function")return o;let s=n;if(e.plugins){const i=Array.isArray(e.plugins)?e.plugins:[];s=[...n||[],...i]}let r=l;if(e.presets){const i=Array.isArray(e.presets)?e.presets:[];r=[...l||[],...i]}return{...o,...e,plugins:s&&s.length>0?s:void 0,presets:r&&r.length>0?r:void 0}},"mergeUserBabelOptions"),x=a((o={})=>{const{babel:e,plugins:n=[],presets:l=[],solidOptions:s={}}=o,r=[],i=[],m=["babel-preset-solid",N(s)];i.push(m);const u=[...r,...Array.isArray(n)?n:[]],d=[...i,...Array.isArray(l)?l:[]],b={ast:!1,babelrc:!1,configFile:!1,plugins:u.length>0?u:void 0,presets:d.length>0?d:void 0,sourceMaps:!0},f={babel:E(b,e,u,d),resolve:{exportConditions:["solid"]}};return{externals:["solid-js","solid-js/web","solid-js/store"],hooks:{"rollup:options":a((t,h)=>{const c=t.environment==="development"?"development":"production",p=c==="development",{runtime:y}=t.options,v=y==="node";t.options.rollup.replace||(t.options.rollup.replace={preventAssignment:!0,values:{}}),t.options.rollup.replace.values||(t.options.rollup.replace.values={});const S={[["import","meta","env","DEV"].join(".")]:p,[["import","meta","env","NODE_ENV"].join(".")]:JSON.stringify(c),[["import","meta","env","PROD"].join(".")]:!p,[["import","meta","env","SSR"].join(".")]:v,[["process","env","DEV"].join(".")]:JSON.stringify(String(p)),[["process","env","NODE_ENV"].join(".")]:JSON.stringify(c),[["process","env","PROD"].join(".")]:JSON.stringify(String(!p)),[["process","env","SSR"].join(".")]:JSON.stringify(String(v))};Object.assign(t.options.rollup.replace.values,S)},"rollup:options")},rollup:f,validation:{dependencies:{hoisted:{exclude:[]},unused:{exclude:["solid-js"]}}}}},"createSolidPreset");export{x as createSolidPreset};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { BuildConfig } from "../../types.d.ts";
|
|
2
|
+
export interface SveltePresetOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Svelte plugin options
|
|
5
|
+
*/
|
|
6
|
+
pluginOptions?: {
|
|
7
|
+
/**
|
|
8
|
+
* Svelte compiler options
|
|
9
|
+
*/
|
|
10
|
+
compilerOptions?: {
|
|
11
|
+
[key: string]: unknown;
|
|
12
|
+
/**
|
|
13
|
+
* Custom element mode
|
|
14
|
+
* @default false
|
|
15
|
+
*/
|
|
16
|
+
customElement?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Enable dev mode
|
|
19
|
+
* @default false
|
|
20
|
+
*/
|
|
21
|
+
dev?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Generate mode: "client" for client-side rendering, "server" for SSR
|
|
24
|
+
* @default "client"
|
|
25
|
+
*/
|
|
26
|
+
generate?: "client" | "server" | false;
|
|
27
|
+
/**
|
|
28
|
+
* Enable hydratable output
|
|
29
|
+
* @default false
|
|
30
|
+
*/
|
|
31
|
+
hydratable?: boolean;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Exclude patterns for Svelte files
|
|
35
|
+
*/
|
|
36
|
+
exclude?: RegExp | RegExp[];
|
|
37
|
+
/**
|
|
38
|
+
* Include patterns for Svelte files
|
|
39
|
+
* @default [/\.svelte$/]
|
|
40
|
+
*/
|
|
41
|
+
include?: RegExp | RegExp[];
|
|
42
|
+
/**
|
|
43
|
+
* Preprocessor options
|
|
44
|
+
*/
|
|
45
|
+
preprocess?: unknown;
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Svelte preset for Packem. Configures Rollup with rollup-plugin-svelte.
|
|
50
|
+
* @description This preset configures the Svelte plugin to handle .svelte file compilation.
|
|
51
|
+
* @example
|
|
52
|
+
* ```typescript
|
|
53
|
+
* // Basic usage
|
|
54
|
+
* export default defineConfig({
|
|
55
|
+
* preset: "svelte"
|
|
56
|
+
* });
|
|
57
|
+
*
|
|
58
|
+
* // With custom options
|
|
59
|
+
* import { createSveltePreset } from "@visulima/packem/config/preset/svelte";
|
|
60
|
+
* export default defineConfig({
|
|
61
|
+
* preset: createSveltePreset({
|
|
62
|
+
* pluginOptions: {
|
|
63
|
+
* compilerOptions: {
|
|
64
|
+
* hydratable: true
|
|
65
|
+
* }
|
|
66
|
+
* }
|
|
67
|
+
* })
|
|
68
|
+
* });
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
export declare const createSveltePreset: (options?: SveltePresetOptions) => BuildConfig;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var s=Object.defineProperty;var t=(r,e)=>s(r,"name",{value:e,configurable:!0});import{DEFAULT_EXTENSIONS as n}from"@visulima/packem-share/constants";import o from"rollup-plugin-svelte";var l=Object.defineProperty,i=t((r,e)=>l(r,"name",{value:e,configurable:!0}),"t");const d=i((r={})=>{const{pluginOptions:e={}}=r;return{rollup:{plugins:[{enforce:"pre",plugin:o({compilerOptions:{generate:"client",runes:!0,...e.compilerOptions},emitCss:!1,exclude:e.exclude,extensions:[".svelte"],include:e.include??[/\.svelte$/],preprocess:e.preprocess})}],resolve:{browser:!0,exportConditions:["svelte"],extensions:[...n,".svelte"]}},validation:{dependencies:{hoisted:{exclude:[]},unused:{exclude:["svelte"]}}}}},"createSveltePreset");export{d as createSveltePreset};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { PackageJson } from "@visulima/package";
|
|
2
|
+
import type { BuildContext } from "@visulima/packem-share/types";
|
|
3
|
+
import type { InferEntriesResult, InternalBuildOptions } from "../../../types.d.ts";
|
|
4
|
+
/**
|
|
5
|
+
* Infer entries from package files.
|
|
6
|
+
* @param packageJson
|
|
7
|
+
* @param sourceFiles A list of source files to use for inferring entries.
|
|
8
|
+
* @param context
|
|
9
|
+
* @returns
|
|
10
|
+
*/
|
|
11
|
+
declare const inferEntries: (packageJson: PackageJson, sourceFiles: string[], context: BuildContext<InternalBuildOptions>) => Promise<InferEntriesResult>;
|
|
12
|
+
export default inferEntries;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { NormalizedPackageJson } from "@visulima/package";
|
|
2
|
+
import type { BuildConfig } from "../../../types.d.ts";
|
|
3
|
+
declare const overwriteWithPublishConfig: (packageJson: NormalizedPackageJson, declaration?: BuildConfig["declaration"]) => NormalizedPackageJson;
|
|
4
|
+
export default overwriteWithPublishConfig;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { BuildConfig } from "../../types.d.ts";
|
|
2
|
+
export interface VuePresetOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Vue plugin options
|
|
5
|
+
*/
|
|
6
|
+
pluginOptions?: {
|
|
7
|
+
/**
|
|
8
|
+
* Enable custom elements mode
|
|
9
|
+
* @default false
|
|
10
|
+
*/
|
|
11
|
+
customElement?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Exclude patterns for Vue files
|
|
14
|
+
*/
|
|
15
|
+
exclude?: RegExp | RegExp[];
|
|
16
|
+
/**
|
|
17
|
+
* Include patterns for Vue files
|
|
18
|
+
* @default [/\.vue$/]
|
|
19
|
+
*/
|
|
20
|
+
include?: RegExp | RegExp[];
|
|
21
|
+
/**
|
|
22
|
+
* Template compiler options
|
|
23
|
+
*/
|
|
24
|
+
template?: {
|
|
25
|
+
compilerOptions?: {
|
|
26
|
+
[key: string]: unknown;
|
|
27
|
+
isCustomElement?: (tag: string) => boolean;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Vue preset for Packem. Configures Rollup with unplugin-vue.
|
|
34
|
+
* @description This preset configures the Vue plugin to handle .vue file compilation.
|
|
35
|
+
* @example
|
|
36
|
+
* ```typescript
|
|
37
|
+
* // Basic usage
|
|
38
|
+
* export default defineConfig({
|
|
39
|
+
* preset: "vue"
|
|
40
|
+
* });
|
|
41
|
+
*
|
|
42
|
+
* // With custom options
|
|
43
|
+
* import { createVuePreset } from "@visulima/packem/config/preset/vue";
|
|
44
|
+
* export default defineConfig({
|
|
45
|
+
* preset: createVuePreset({
|
|
46
|
+
* pluginOptions: {
|
|
47
|
+
* customElement: true
|
|
48
|
+
* }
|
|
49
|
+
* })
|
|
50
|
+
* });
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
export declare const createVuePreset: (options?: VuePresetOptions) => BuildConfig;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var n=Object.defineProperty;var u=(t,e)=>n(t,"name",{value:e,configurable:!0});import l from"unplugin-vue/rollup";var r=Object.defineProperty,c=u((t,e)=>r(t,"name",{value:e,configurable:!0}),"n");const a=c((t={})=>{const{pluginOptions:e={}}=t;return{rollup:{plugins:[{enforce:"pre",plugin:l({customElement:e.customElement??!1,exclude:e.exclude,include:e.include??[/\.vue$/],template:e.template})}]},validation:{dependencies:{hoisted:{exclude:[]},unused:{exclude:["vue"]}}}}},"createVuePreset");export{a as createVuePreset};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loads environment variables from a .env file with optional prefix filtering.
|
|
3
|
+
* Uses Node.js built-in `util.parseEnv` to parse the file content without modifying `process.env`.
|
|
4
|
+
* @param envFilePath Path to the .env file (relative to rootDirectory or absolute)
|
|
5
|
+
* @param rootDirectory Root directory for resolving relative paths
|
|
6
|
+
* @param prefix Optional prefix to filter environment variables (e.g., "PACKEM_")
|
|
7
|
+
* @returns Record of environment variables with keys formatted as "process.env.KEY"
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* const envVars = await loadEnvFile(".env", "/path/to/project", "PACKEM_");
|
|
11
|
+
* // Returns: { "process.env.PACKEM_API_URL": "\"https://api.example.com\"" }
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
declare const loadEnvFile: (envFilePath: string, rootDirectory: string, prefix?: string) => Promise<Record<string, string>>;
|
|
15
|
+
export default loadEnvFile;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Jiti } from "jiti";
|
|
2
|
+
import type { BuildConfig, Environment, Mode } from "../../types.d.ts";
|
|
3
|
+
declare const loadPackemConfig: (jiti: Jiti, rootDirectory: string, environment: Environment, mode: Mode, configPath?: string) => Promise<{
|
|
4
|
+
config: BuildConfig;
|
|
5
|
+
path: string;
|
|
6
|
+
}>;
|
|
7
|
+
export default loadPackemConfig;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { NormalizedPackageJson } from "@visulima/package";
|
|
2
|
+
import type { Pail } from "@visulima/pail";
|
|
3
|
+
import type { TsConfigResult } from "@visulima/tsconfig";
|
|
4
|
+
declare const loadTsconfig: (rootDirectory: string, packageJson: NormalizedPackageJson, logger: Pail, tsconfigPath?: string) => Promise<TsConfigResult | undefined>;
|
|
5
|
+
export default loadTsconfig;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,36 +1,49 @@
|
|
|
1
|
-
import { ConstructorOptions } from
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
import 'rollup';
|
|
17
|
-
import 'rollup-plugin-dts';
|
|
18
|
-
import 'rollup-plugin-polyfill-node';
|
|
19
|
-
import 'rollup-plugin-pure';
|
|
20
|
-
import 'rollup-plugin-visualizer';
|
|
21
|
-
import 'esbuild';
|
|
22
|
-
import '@visulima/package';
|
|
23
|
-
import '@visulima/colorize';
|
|
24
|
-
import 'oxc-resolver';
|
|
25
|
-
import 'oxc-transform';
|
|
26
|
-
import 'sucrase';
|
|
27
|
-
|
|
28
|
-
interface PackemOptions extends BuildConfig {
|
|
1
|
+
import type { ConstructorOptions } from "@visulima/pail";
|
|
2
|
+
import type { BuildConfig, Environment, Mode } from "./types.d.ts";
|
|
3
|
+
/**
|
|
4
|
+
* Configuration options for Packem bundler.
|
|
5
|
+
* @interface PackemOptions
|
|
6
|
+
* @augments {BuildConfig}
|
|
7
|
+
*/
|
|
8
|
+
export interface PackemOptions extends BuildConfig {
|
|
9
|
+
/**
|
|
10
|
+
* The environment to build for
|
|
11
|
+
* Determines the build environment configuration
|
|
12
|
+
* @default "production"
|
|
13
|
+
* @type {Environment}
|
|
14
|
+
* @memberof PackemOptions
|
|
15
|
+
*/
|
|
29
16
|
environment?: Environment;
|
|
17
|
+
/**
|
|
18
|
+
* Logger configuration options
|
|
19
|
+
* Used to customize the logging behavior and output format
|
|
20
|
+
* @type {ConstructorOptions<string, string>}
|
|
21
|
+
* @memberof PackemOptions
|
|
22
|
+
*/
|
|
30
23
|
logger?: ConstructorOptions<string, string>;
|
|
24
|
+
/**
|
|
25
|
+
* The mode to run Packem in
|
|
26
|
+
* Controls how the bundler processes and optimizes the code
|
|
27
|
+
* @default "build"
|
|
28
|
+
* @type {Mode}
|
|
29
|
+
* @memberof PackemOptions
|
|
30
|
+
*/
|
|
31
31
|
mode?: Mode;
|
|
32
32
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
/**
|
|
34
|
+
* Runs the Packem bundler with the specified options
|
|
35
|
+
* @param rootDirectory The root directory of the project to bundle
|
|
36
|
+
* @param options Configuration options for the bundler
|
|
37
|
+
* @returns Promise that resolves with the build result
|
|
38
|
+
* @example
|
|
39
|
+
* ```typescript
|
|
40
|
+
* const result = await packem("./src", {
|
|
41
|
+
* mode: "build",
|
|
42
|
+
* environment: "production"
|
|
43
|
+
* });
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export declare const packem: (rootDirectory: string, options?: PackemOptions) => Promise<void>;
|
|
47
|
+
export type { BuildEntry, BuildOptions, RollupBuildOptions } from "./types.d.ts";
|
|
48
|
+
export type { IsolatedDeclarationsTransformer, TransformerFn, TransformerName } from "@visulima/packem-rollup";
|
|
49
|
+
export type { BuildContext, BuildContextBuildAssetAndChunk, BuildContextBuildEntry, BuildHooks, Environment, Mode, Runtime, } from "@visulima/packem-share/types";
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var c=Object.defineProperty;var o=(e,r)=>c(e,"name",{value:r,configurable:!0});import{createPail as s}from"@visulima/pail";import{SimpleReporter as u}from"@visulima/pail/reporter";import{
|
|
1
|
+
var c=Object.defineProperty;var o=(e,r)=>c(e,"name",{value:r,configurable:!0});import{createPail as s}from"@visulima/pail";import{SimpleReporter as u}from"@visulima/pail/reporter/simple";import{S as g}from"./packem_shared/index-Bm8Oe89l.js";var f=Object.defineProperty,l=o((e,r)=>f(e,"name",{value:r,configurable:!0}),"r");const C=l(async(e,r={})=>{const{debug:t,environment:i,logger:a,mode:n,tsconfigPath:m,...d}={debug:!1,environment:"production",logger:{},mode:"build",tsconfigPath:void 0,...r},p=s({reporters:[new u({error:{hideErrorCauseCodeView:!0,hideErrorCodeView:!0,hideErrorErrorsCodeView:!0}})],scope:"packem",...a});await g(e,n,i,p,t,d,m)},"packem");export{C as packem};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Run async tasks with a concurrency limit to prevent memory overflow.
|
|
3
|
+
* Useful for limiting parallel rollup builds, especially DTS generation.
|
|
4
|
+
*/
|
|
5
|
+
declare const runWithConcurrency: <T>(tasks: (() => Promise<T>)[], limit: number) => Promise<T[]>;
|
|
6
|
+
export default runWithConcurrency;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { FileCache } from "@visulima/packem-share";
|
|
2
|
+
import type { BuildContext } from "@visulima/packem-share/types";
|
|
3
|
+
import type { InternalBuildOptions } from "../types.d.ts";
|
|
4
|
+
/**
|
|
5
|
+
* Main build function that orchestrates the entire build process.
|
|
6
|
+
* Handles both JavaScript/TypeScript compilation and type definition generation.
|
|
7
|
+
* @param context Build context containing configuration and state
|
|
8
|
+
* @param fileCache Cache instance for file operations
|
|
9
|
+
* @returns Promise resolving to a boolean indicating build success
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* const success = await build(BuildContext<InternalBuildOptions>, new FileCache());
|
|
13
|
+
* if (success) {
|
|
14
|
+
* console.log('Build completed successfully');
|
|
15
|
+
* }
|
|
16
|
+
* ```
|
|
17
|
+
* @throws {Error} If the build process encounters critical errors
|
|
18
|
+
* @public
|
|
19
|
+
*/
|
|
20
|
+
declare const build: (context: BuildContext<InternalBuildOptions>, fileCache: FileCache) => Promise<boolean>;
|
|
21
|
+
export default build;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Pail } from "@visulima/pail";
|
|
2
|
+
import type { BuildConfig, Environment, Mode } from '../types.d.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Main entry point for the Packem bundler.
|
|
5
|
+
* Handles the complete build process including configuration loading, validation,
|
|
6
|
+
* and execution of the build/watch process.
|
|
7
|
+
* @param rootDirectory Root directory of the project
|
|
8
|
+
* @param mode Build mode (build/watch)
|
|
9
|
+
* @param environment Build environment (development/production)
|
|
10
|
+
* @param logger Logger instance for output
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* import packem from 'packem';
|
|
14
|
+
*
|
|
15
|
+
* await packem('/path/to/project', 'build', 'production', logger, {
|
|
16
|
+
* debug: true,
|
|
17
|
+
* configPath: './packem.config.js'
|
|
18
|
+
* });
|
|
19
|
+
* ```
|
|
20
|
+
* @throws {Error} If configuration validation fails or build process encounters errors
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
23
|
+
declare const packem: (rootDirectory: string, mode: Mode, environment: Environment, logger: Pail, debug: boolean, config: BuildConfig, tsconfigPath?: string) => Promise<void>;
|
|
24
|
+
export default packem;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { BuildContext } from "@visulima/packem-share/types";
|
|
2
|
+
import type { InternalBuildOptions } from "../types.d.ts";
|
|
3
|
+
export type Node10CompatibilityOptions = {
|
|
4
|
+
typeScriptVersion?: string;
|
|
5
|
+
writeToPackageJson?: boolean;
|
|
6
|
+
};
|
|
7
|
+
export declare const node10Compatibility: (logger: BuildContext<InternalBuildOptions>["logger"], entries: BuildContext<InternalBuildOptions>["options"]["entries"], outDirectory: string, rootDirectory: string, mode: "console" | "file", typeScriptVersion: string) => Promise<void>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
type Key = number | string | symbol;
|
|
2
|
+
/**
|
|
3
|
+
* Groups an array of objects by multiple keys, creating nested objects.
|
|
4
|
+
* Supports 2 or 3 keys for grouping.
|
|
5
|
+
* @param array Array of objects to group
|
|
6
|
+
* @param key1 First key to group by
|
|
7
|
+
* @param key2 Second key to group by
|
|
8
|
+
* @param key3 Optional third key to group by
|
|
9
|
+
* @returns Nested object grouped by the specified keys
|
|
10
|
+
*/
|
|
11
|
+
declare const groupByKeys: <T extends Record<Key, unknown>>(array: T[], key1: Key, key2: Key, key3?: Key) => Record<string, Record<string, T[]>> | Record<string, Record<string, Record<string, T[]>>>;
|
|
12
|
+
export default groupByKeys;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var s=Object.defineProperty;var a=(r,t)=>s(r,"name",{value:t,configurable:!0});import{isAccessibleSync as i,readJsonSync as y,writeJsonSync as m}from"@visulima/fs";import{join as d}from"@visulima/path";var g=Object.defineProperty,p=a((r,t)=>g(r,"name",{value:t,configurable:!0}),"i");const v=p((r,t,c,n)=>{try{let e={};const o=d(t,"keystore.json");n&&i(o)&&(e=y(o)),e[r]===void 0&&(e[r]=new Date().toISOString()),m(o,e,{overwrite:!0})}catch(e){c.debug({context:[e],message:e.message,prefix:"cache-key-store"})}},"createOrUpdateKeyStorage");export{v as d};
|