@visulima/packem 2.0.0-alpha.4 → 2.0.0-alpha.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/CHANGELOG.md +480 -1
  2. package/LICENSE.md +6393 -1445
  3. package/README.md +16 -12
  4. package/dist/builder/typedoc/index.d.ts +3 -26
  5. package/dist/builder/typedoc/index.js +160 -3
  6. package/dist/cli/index.d.ts +1 -0
  7. package/dist/cli/index.js +1379 -43
  8. package/dist/config/index.d.ts +48 -28
  9. package/dist/config/index.js +4 -1
  10. package/dist/config/preset/react.d.ts +59 -0
  11. package/dist/config/preset/react.js +43 -0
  12. package/dist/config/preset/solid.d.ts +101 -0
  13. package/dist/config/preset/solid.js +72 -0
  14. package/dist/config/preset/svelte.d.ts +71 -0
  15. package/dist/config/preset/svelte.js +44 -0
  16. package/dist/config/preset/vue.d.ts +53 -0
  17. package/dist/config/preset/vue.js +33 -0
  18. package/dist/index.d.ts +45 -32
  19. package/dist/index.js +30 -1
  20. package/dist/packem/node10-compatibility.d.ts +7 -0
  21. package/dist/packem_shared/create-or-update-key-storage-Dd7b8-t1.js +36 -0
  22. package/dist/packem_shared/default-79SPobLI.js +12 -0
  23. package/dist/packem_shared/default-DWBYeUSC.js +210 -0
  24. package/dist/packem_shared/default-DaU6CQEi.js +28 -0
  25. package/dist/packem_shared/default-DavaZMwC.js +32 -0
  26. package/dist/packem_shared/default-DeYZ934H.js +32 -0
  27. package/dist/packem_shared/default-tUOOZ8w7.js +42 -0
  28. package/dist/packem_shared/default-wScAfTaq.js +27 -0
  29. package/dist/packem_shared/index-CTIRxV2x.js +63 -0
  30. package/dist/packem_shared/index-DzTDn4ad.js +9521 -0
  31. package/dist/rollup/plugins/css/loaders/less.d.ts +1 -1
  32. package/dist/rollup/plugins/css/loaders/less.js +1 -1
  33. package/dist/rollup/plugins/css/loaders/lightningcss.d.ts +1 -1
  34. package/dist/rollup/plugins/css/loaders/lightningcss.js +1 -1
  35. package/dist/rollup/plugins/css/loaders/postcss.d.ts +1 -1
  36. package/dist/rollup/plugins/css/loaders/postcss.js +1 -1
  37. package/dist/rollup/plugins/css/loaders/sass.d.ts +1 -1
  38. package/dist/rollup/plugins/css/loaders/sass.js +1 -1
  39. package/dist/rollup/plugins/css/loaders/sourcemap.d.ts +1 -8
  40. package/dist/rollup/plugins/css/loaders/sourcemap.js +1 -1
  41. package/dist/rollup/plugins/css/loaders/stylus.d.ts +1 -1
  42. package/dist/rollup/plugins/css/loaders/stylus.js +1 -1
  43. package/dist/rollup/plugins/css/loaders/tailwindcss.d.ts +1 -0
  44. package/dist/rollup/plugins/css/loaders/tailwindcss.js +1 -0
  45. package/dist/rollup/plugins/css/minifiers/cssnano.d.ts +1 -1
  46. package/dist/rollup/plugins/css/minifiers/cssnano.js +1 -1
  47. package/dist/rollup/plugins/css/minifiers/lightningcss.d.ts +1 -1
  48. package/dist/rollup/plugins/css/minifiers/lightningcss.js +1 -1
  49. package/dist/rollup/plugins/esbuild/index.d.ts +2 -24
  50. package/dist/rollup/plugins/esbuild/index.js +1 -1
  51. package/dist/rollup/plugins/oxc/isolated-declarations-oxc-transformer.d.ts +1 -25
  52. package/dist/rollup/plugins/oxc/isolated-declarations-oxc-transformer.js +1 -1
  53. package/dist/rollup/plugins/oxc/oxc-transformer.d.ts +2 -20
  54. package/dist/rollup/plugins/oxc/oxc-transformer.js +1 -1
  55. package/dist/rollup/plugins/resolve-externals-plugin.d.ts +60 -0
  56. package/dist/rollup/plugins/sucrase/index.d.ts +2 -19
  57. package/dist/rollup/plugins/sucrase/index.js +1 -1
  58. package/dist/rollup/plugins/swc/isolated-declarations-swc-transformer.d.ts +1 -20
  59. package/dist/rollup/plugins/swc/isolated-declarations-swc-transformer.js +1 -1
  60. package/dist/rollup/plugins/swc/swc-plugin.d.ts +2 -26
  61. package/dist/rollup/plugins/swc/swc-plugin.js +1 -1
  62. package/dist/rollup/plugins/typescript/isolated-declarations-typescript-transformer.d.ts +1 -24
  63. package/dist/rollup/plugins/typescript/isolated-declarations-typescript-transformer.js +1 -1
  64. package/dist/types.d.ts +329 -0
  65. package/files.d.ts +37 -0
  66. package/package.json +190 -29
  67. package/dist/packem_shared/browserslistToEsbuild-C0IWmbNe-C6xPL1oW.js +0 -1
  68. package/dist/packem_shared/create-or-update-key-storage-GwAIWW7R.js +0 -3
  69. package/dist/packem_shared/default-B6X7-Lx3.js +0 -1
  70. package/dist/packem_shared/default-B_dUKZ_J.js +0 -1
  71. package/dist/packem_shared/default-C3sdXf4G.js +0 -1
  72. package/dist/packem_shared/default-DR5Fia_R.js +0 -1
  73. package/dist/packem_shared/default-DqRcOUe1.js +0 -1
  74. package/dist/packem_shared/esbuildPlugin-BAwyhG6L-yty60jMl.js +0 -3
  75. package/dist/packem_shared/index-CUp9WuCG.js +0 -1
  76. package/dist/packem_shared/index-DySckW0r.d.ts +0 -5227
  77. package/dist/packem_shared/index-VKZ7e6tb.js +0 -138
  78. package/dist/packem_shared/isolatedDeclarationsOxcTransformer-WbfE6cGu-NeZOx2Y7.js +0 -1
  79. package/dist/packem_shared/isolatedDeclarationsSwcTransformer-Ch2AgtWC-B-0lOgFf.js +0 -1
  80. package/dist/packem_shared/isolatedDeclarationsTypescriptTransformer-DkuEkofo-Cwe3ODMG.js +0 -3
  81. package/dist/packem_shared/oxcResolvePlugin-BJpi-eSG-BsYx9cDO.js +0 -1
  82. package/dist/packem_shared/oxcTransformPlugin-DfVQouIB-Cpfv95eA.js +0 -4
  83. package/dist/packem_shared/resolveTypescriptMjsCtsPlugin-DcZrZTmM-BEkYWTsH.js +0 -6
  84. package/dist/packem_shared/swcPlugin-Boip4lWG-CwJ-HVJc.js +0 -1
  85. package/dist/packem_shared/types-CaBbG-vU.d.ts +0 -163
@@ -1,28 +1,48 @@
1
- import { B as BuildConfig, c as BuildConfigFunction, d as BuildPreset } from '../packem_shared/types-CaBbG-vU.js';
2
- export { d as BuildHooks } from '../packem_shared/index-DySckW0r.js';
3
- import '@visulima/rollup-css-plugin';
4
- import 'jiti';
5
- import 'typedoc';
6
- import '@rollup/plugin-alias';
7
- import '@rollup/plugin-commonjs';
8
- import '@rollup/plugin-json';
9
- import '@rollup/plugin-node-resolve';
10
- import '@rollup/plugin-replace';
11
- import '@rollup/plugin-wasm';
12
- import '@rollup/pluginutils';
13
- import 'rollup';
14
- import 'rollup-plugin-dts';
15
- import 'rollup-plugin-polyfill-node';
16
- import 'rollup-plugin-pure';
17
- import 'rollup-plugin-visualizer';
18
- import 'esbuild';
19
- import '@visulima/package';
20
- import '@visulima/colorize';
21
- import 'oxc-resolver';
22
- import 'oxc-transform';
23
- import 'sucrase';
24
-
25
- declare const defineConfig: (config: BuildConfig | BuildConfigFunction) => BuildConfig | BuildConfigFunction;
26
- declare const definePreset: (preset: BuildPreset) => BuildPreset;
27
-
28
- export { BuildConfig, BuildConfigFunction, BuildPreset, defineConfig, definePreset };
1
+ import type { BuildConfig, BuildConfigFunction, BuildPreset } from "../types.d.ts";
2
+ export type { BuildConfig, BuildConfigFunction, BuildPreset } from "../types.d.ts";
3
+ export type { BuildHooks } from "@visulima/packem-share/types";
4
+ /**
5
+ * Defines a build configuration for Packem.
6
+ * Supports both static configuration objects and dynamic configuration functions.
7
+ * @param config Static build configuration object or function returning configuration
8
+ * @returns The provided configuration
9
+ * @example
10
+ * ```typescript
11
+ * // Static configuration
12
+ * export default defineConfig({
13
+ * entries: ['./src/index.ts'],
14
+ * outDir: './dist'
15
+ * });
16
+ *
17
+ * // Dynamic configuration
18
+ * export default defineConfig((env, mode) => ({
19
+ * entries: ['./src/index.ts'],
20
+ * outDir: env === 'production' ? './dist' : './dev'
21
+ * }));
22
+ * ```
23
+ * @public
24
+ */
25
+ export declare const defineConfig: (config: BuildConfig | BuildConfigFunction) => BuildConfig | BuildConfigFunction;
26
+ /**
27
+ * Defines a build preset for Packem.
28
+ * Build presets provide reusable configuration templates that can be shared across projects.
29
+ * @param preset Build preset configuration
30
+ * @returns The provided preset configuration
31
+ * @example
32
+ * ```typescript
33
+ * export default definePreset({
34
+ * name: 'my-preset',
35
+ * defaults: {
36
+ * entries: ['./src/index.ts'],
37
+ * outDir: './dist'
38
+ * },
39
+ * hooks: {
40
+ * 'build:before': (context) => {
41
+ * // Custom build preparation logic
42
+ * }
43
+ * }
44
+ * });
45
+ * ```
46
+ * @public
47
+ */
48
+ export declare const definePreset: (preset: BuildPreset) => BuildPreset;
@@ -1 +1,4 @@
1
- var i=Object.defineProperty;var r=(e,n)=>i(e,"name",{value:n,configurable:!0});var t=Object.defineProperty,f=r((e,n)=>t(e,"name",{value:n,configurable:!0}),"e");const a=f(e=>e,"defineConfig"),d=f(e=>e,"definePreset");export{a as defineConfig,d as definePreset};
1
+ const defineConfig = (config) => config;
2
+ const definePreset = (preset) => preset;
3
+
4
+ export { defineConfig, definePreset };
@@ -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,43 @@
1
+ const createReactPreset = (options = {}) => {
2
+ const { compiler = false, plugins = [], presets = [] } = options;
3
+ const babelPlugins = [];
4
+ const babelPresets = [];
5
+ if (compiler) {
6
+ const compilerOptions = typeof compiler === "object" ? compiler : {};
7
+ babelPlugins.push([
8
+ "babel-plugin-react-compiler",
9
+ {
10
+ compilationMode: compilerOptions.compilationMode ?? "infer",
11
+ panicThreshold: compilerOptions.panicThreshold ?? "critical_errors"
12
+ }
13
+ ]);
14
+ }
15
+ babelPresets.push([
16
+ "@babel/preset-react",
17
+ {
18
+ runtime: "automatic"
19
+ }
20
+ ]);
21
+ const finalPlugins = [...babelPlugins, ...Array.isArray(plugins) ? plugins : []];
22
+ const finalPresets = [...babelPresets, ...Array.isArray(presets) ? presets : []];
23
+ return {
24
+ rollup: {
25
+ babel: {
26
+ plugins: finalPlugins.length > 0 ? finalPlugins : void 0,
27
+ presets: finalPresets.length > 0 ? finalPresets : void 0
28
+ }
29
+ },
30
+ validation: {
31
+ dependencies: {
32
+ hoisted: {
33
+ exclude: []
34
+ },
35
+ unused: {
36
+ exclude: ["react", "react-dom"]
37
+ }
38
+ }
39
+ }
40
+ };
41
+ };
42
+
43
+ export { 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,72 @@
1
+ const buildSolidPresetOptions = (solidOptions) => {
2
+ const presetOptions = {
3
+ contextToCustomElements: solidOptions?.contextToCustomElements ?? true,
4
+ delegateEvents: solidOptions?.delegateEvents ?? true,
5
+ generate: solidOptions?.generate ?? "dom",
6
+ hydratable: solidOptions?.hydratable ?? false,
7
+ moduleName: solidOptions?.moduleName ?? "solid-js/web",
8
+ wrapConditionals: solidOptions?.wrapConditionals ?? true
9
+ };
10
+ if (solidOptions?.builtIns !== void 0) {
11
+ presetOptions.builtIns = solidOptions.builtIns;
12
+ }
13
+ return presetOptions;
14
+ };
15
+ const mergeUserBabelOptions = (baseConfig, userBabelOptions, basePlugins, basePresets) => {
16
+ if (!userBabelOptions || typeof userBabelOptions === "function") {
17
+ return baseConfig;
18
+ }
19
+ let mergedPlugins = basePlugins;
20
+ if (userBabelOptions.plugins) {
21
+ const userPluginsArray = Array.isArray(userBabelOptions.plugins) ? userBabelOptions.plugins : [];
22
+ mergedPlugins = [...basePlugins || [], ...userPluginsArray];
23
+ }
24
+ let mergedPresets = basePresets;
25
+ if (userBabelOptions.presets) {
26
+ const userPresetsArray = Array.isArray(userBabelOptions.presets) ? userBabelOptions.presets : [];
27
+ mergedPresets = [...basePresets || [], ...userPresetsArray];
28
+ }
29
+ return {
30
+ ...baseConfig,
31
+ ...userBabelOptions,
32
+ plugins: mergedPlugins && mergedPlugins.length > 0 ? mergedPlugins : void 0,
33
+ presets: mergedPresets && mergedPresets.length > 0 ? mergedPresets : void 0
34
+ };
35
+ };
36
+ const createSolidPreset = (options = {}) => {
37
+ const { babel: userBabelOptions, plugins = [], presets = [], solidOptions = {} } = options;
38
+ const babelPlugins = [];
39
+ const babelPresets = [];
40
+ const solidPresetOptions = buildSolidPresetOptions(solidOptions);
41
+ const solidPreset = ["babel-preset-solid", solidPresetOptions];
42
+ babelPresets.push(solidPreset);
43
+ const finalPlugins = [...babelPlugins, ...Array.isArray(plugins) ? plugins : []];
44
+ const finalPresets = [...babelPresets, ...Array.isArray(presets) ? presets : []];
45
+ const babelConfig = {
46
+ ast: false,
47
+ babelrc: false,
48
+ configFile: false,
49
+ plugins: finalPlugins.length > 0 ? finalPlugins : void 0,
50
+ presets: finalPresets.length > 0 ? finalPresets : void 0,
51
+ sourceMaps: true
52
+ };
53
+ const mergedBabelConfig = mergeUserBabelOptions(babelConfig, userBabelOptions, finalPlugins, finalPresets);
54
+ return {
55
+ externals: ["solid-js", "solid-js/web", "solid-js/store"],
56
+ rollup: {
57
+ babel: mergedBabelConfig
58
+ },
59
+ validation: {
60
+ dependencies: {
61
+ hoisted: {
62
+ exclude: []
63
+ },
64
+ unused: {
65
+ exclude: ["solid-js"]
66
+ }
67
+ }
68
+ }
69
+ };
70
+ };
71
+
72
+ export { 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
+ /**
12
+ * Custom element mode
13
+ * @default false
14
+ */
15
+ customElement?: boolean;
16
+ /**
17
+ * Enable dev mode
18
+ * @default false
19
+ */
20
+ dev?: boolean;
21
+ /**
22
+ * Generate mode: "client" for client-side rendering, "server" for SSR
23
+ * @default "client"
24
+ */
25
+ generate?: "client" | "server" | false;
26
+ /**
27
+ * Enable hydratable output
28
+ * @default false
29
+ */
30
+ hydratable?: boolean;
31
+ [key: string]: unknown;
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,44 @@
1
+ import svelte from 'rollup-plugin-svelte';
2
+ import { D as DEFAULT_EXTENSIONS } from '../../packem_shared/index-CTIRxV2x.js';
3
+
4
+ const createSveltePreset = (options = {}) => {
5
+ const { pluginOptions = {} } = options;
6
+ return {
7
+ rollup: {
8
+ plugins: [
9
+ {
10
+ enforce: "pre",
11
+ plugin: svelte({
12
+ compilerOptions: {
13
+ generate: "client",
14
+ runes: true,
15
+ ...pluginOptions.compilerOptions
16
+ },
17
+ emitCss: false,
18
+ extensions: [".svelte"],
19
+ exclude: pluginOptions.exclude,
20
+ include: pluginOptions.include ?? [/\.svelte$/],
21
+ preprocess: pluginOptions.preprocess
22
+ })
23
+ }
24
+ ],
25
+ resolve: {
26
+ browser: true,
27
+ exportConditions: ["svelte"],
28
+ extensions: [...DEFAULT_EXTENSIONS, ".svelte"]
29
+ }
30
+ },
31
+ validation: {
32
+ dependencies: {
33
+ hoisted: {
34
+ exclude: []
35
+ },
36
+ unused: {
37
+ exclude: ["svelte"]
38
+ }
39
+ }
40
+ }
41
+ };
42
+ };
43
+
44
+ export { createSveltePreset };
@@ -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,33 @@
1
+ import Vue from 'unplugin-vue/rollup';
2
+
3
+ const createVuePreset = (options = {}) => {
4
+ const { pluginOptions = {} } = options;
5
+ return {
6
+ rollup: {
7
+ plugins: [
8
+ {
9
+ enforce: "pre",
10
+ plugin: Vue({
11
+ customElement: pluginOptions.customElement ?? false,
12
+ exclude: pluginOptions.exclude,
13
+ include: pluginOptions.include ?? [/\.vue$/],
14
+ template: pluginOptions.template,
15
+ exportMode: "default"
16
+ })
17
+ }
18
+ ]
19
+ },
20
+ validation: {
21
+ dependencies: {
22
+ hoisted: {
23
+ exclude: []
24
+ },
25
+ unused: {
26
+ exclude: ["vue"]
27
+ }
28
+ }
29
+ }
30
+ };
31
+ };
32
+
33
+ export { createVuePreset };
package/dist/index.d.ts CHANGED
@@ -1,36 +1,49 @@
1
- import { ConstructorOptions } from '@visulima/pail';
2
- import { B as BuildConfig } from './packem_shared/types-CaBbG-vU.js';
3
- export { a as BuildEntry, b as BuildOptions, R as RollupBuildOptions } from './packem_shared/types-CaBbG-vU.js';
4
- import { E as Environment, M as Mode } from './packem_shared/index-DySckW0r.js';
5
- export { B as BuildContext, b as BuildContextBuildAssetAndChunk, c as BuildContextBuildEntry, d as BuildHooks, I as IsolatedDeclarationsTransformer, R as Runtime, T as TransformerFn, a as TransformerName } from './packem_shared/index-DySckW0r.js';
6
- import '@visulima/rollup-css-plugin';
7
- import 'jiti';
8
- import 'typedoc';
9
- import '@rollup/plugin-alias';
10
- import '@rollup/plugin-commonjs';
11
- import '@rollup/plugin-json';
12
- import '@rollup/plugin-node-resolve';
13
- import '@rollup/plugin-replace';
14
- import '@rollup/plugin-wasm';
15
- import '@rollup/pluginutils';
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
- declare const packem: (rootDirectory: string, options?: PackemOptions) => Promise<void>;
34
-
35
- export { Environment, Mode, packem };
36
- export type { PackemOptions };
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,30 @@
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{y as g}from"./packem_shared/index-VKZ7e6tb.js";var f=Object.defineProperty,l=o((e,r)=>f(e,"name",{value:r,configurable:!0}),"r");const y=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{y as packem};
1
+ import { createPail } from '@visulima/pail';
2
+ import { SimpleReporter } from '@visulima/pail/reporter';
3
+ import { p as packem$1 } from './packem_shared/index-DzTDn4ad.js';
4
+
5
+ const packem = async (rootDirectory, options = {}) => {
6
+ const { debug, environment, logger, mode, tsconfigPath, ...inputConfig } = {
7
+ debug: false,
8
+ environment: "production",
9
+ logger: {},
10
+ mode: "build",
11
+ tsconfigPath: void 0,
12
+ ...options
13
+ };
14
+ const pail = createPail({
15
+ reporters: [
16
+ new SimpleReporter({
17
+ error: {
18
+ hideErrorCauseCodeView: true,
19
+ hideErrorCodeView: true,
20
+ hideErrorErrorsCodeView: true
21
+ }
22
+ })
23
+ ],
24
+ scope: "packem",
25
+ ...logger
26
+ });
27
+ await packem$1(rootDirectory, mode, environment, pail, debug, inputConfig, tsconfigPath);
28
+ };
29
+
30
+ export { packem };