@basmilius/vite-preset 3.7.1 → 3.9.0

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.
@@ -0,0 +1,52 @@
1
+ import { Plugin } from "vite";
2
+
3
+ //#region src/advancedAppChunk.d.ts
4
+ type AdvancedChunk$1 = {
5
+ readonly name: string;
6
+ readonly test: (moduleId: string) => boolean;
7
+ };
8
+ declare const _default: (name: string, moduleIds: string[]) => AdvancedChunk$1;
9
+ //#endregion
10
+ //#region src/advancedLibraryChunk.d.ts
11
+ type AdvancedChunk = {
12
+ readonly name: string;
13
+ readonly test: (moduleId: string) => boolean;
14
+ };
15
+ declare const _default$1: (name: string, moduleIds: string[]) => AdvancedChunk;
16
+ //#endregion
17
+ //#region src/closeBundle.d.ts
18
+ declare const _default$2: () => Plugin;
19
+ //#endregion
20
+ //#region src/composeLibrary.d.ts
21
+ type ComposePlugin = () => Plugin;
22
+ type PathGenerator = (name: string) => string;
23
+ type Options$1 = {
24
+ readonly alias: string;
25
+ readonly isolated?: boolean;
26
+ readonly name: string;
27
+ readonly sourcesPathGenerator?: PathGenerator;
28
+ readonly tsAliasPathGenerator?: PathGenerator;
29
+ };
30
+ declare const _default$3: (options: Options$1) => ComposePlugin;
31
+ //#endregion
32
+ //#region src/preset.d.ts
33
+ type Options = {
34
+ readonly cssModules?: {
35
+ readonly classNames?: "mangled" | "camel" | "kebab";
36
+ readonly generateScopedName?: (name: string, filename: string, css: string) => string;
37
+ };
38
+ readonly assetFileNames?: string;
39
+ readonly fileNames?: "hashes" | "actual";
40
+ readonly isLibrary?: boolean;
41
+ readonly tsconfigPath?: string;
42
+ };
43
+ declare const _default$4: (options?: Options) => Plugin[];
44
+ //#endregion
45
+ //#region src/libraries.d.ts
46
+ type LibraryPlugin = () => Plugin;
47
+ declare const flux: LibraryPlugin;
48
+ declare const fluxDashboard: LibraryPlugin;
49
+ declare const fluxStatistics: LibraryPlugin;
50
+ //#endregion
51
+ export { _default as advancedAppChunk, _default$1 as advancedLibraryChunk, _default$2 as closeBundle, _default$3 as composeLibrary, flux, fluxDashboard, fluxStatistics, _default$4 as preset };
52
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/advancedAppChunk.ts","../src/advancedLibraryChunk.ts","../src/closeBundle.ts","../src/composeLibrary.ts","../src/preset.ts","../src/libraries.ts"],"mappings":";;;KAAK,eAAA;EAAA,SACQ,IAAA;EAAA,SACA,IAAA,GAAO,QAAA;AAAA;AAAA,cAGpB,QAAA,GAAgB,IAAA,UAAc,SAAA,eAAsB,eAAA;;;KCL/C,aAAA;EAAA,SACQ,IAAA;EAAA,SACA,IAAA,GAAO,QAAA;AAAA;AAAA,cAGpB,UAAA,GAAgB,IAAA,UAAc,SAAA,eAAsB,aAAA;;;cCHpD,UAAA,QAAmB,MAAA;;;KCGd,aAAA,SAAsB,MAAA;AAAA,KACtB,aAAA,IAAiB,IAAA;AAAA,KAEjB,SAAA;EAAA,SACQ,KAAA;EAAA,SACA,QAAA;EAAA,SACA,IAAA;EAAA,SACA,oBAAA,GAAuB,aAAA;EAAA,SACvB,oBAAA,GAAuB,aAAA;AAAA;AAAA,cAMpC,UAAA,GAAgB,OAAA,EAAS,SAAA,KAAU,aAAA;;;KCR9B,OAAA;EAAA,SACQ,UAAA;IAAA,SACI,UAAA;IAAA,SACA,kBAAA,IAAsB,IAAA,UAAc,QAAA,UAAkB,GAAA;EAAA;EAAA,SAE1D,cAAA;EAAA,SACA,SAAA;EAAA,SACA,SAAA;EAAA,SACA,YAAA;AAAA;AAAA,cA8Eb,UAAA,GAAgB,OAAA,GAAS,OAAA,KAAe,MAAA;;;KC9FnC,aAAA,SAAsB,MAAA;AAAA,cAEd,IAAA,EAAM,aAAA;AAAA,cAKN,aAAA,EAAe,aAAA;AAAA,cAKf,cAAA,EAAgB,aAAA"}
package/dist/index.mjs ADDED
@@ -0,0 +1,2 @@
1
+ import{existsSync as e,readFileSync as t,writeFileSync as n}from"node:fs";import{join as r,relative as i,resolve as a}from"node:path";import{searchForWorkspaceRoot as o}from"vite";import{camelCase as s,kebabCase as c}from"change-case";import{patchCssModules as l}from"vite-css-modules";import u from"css-class-generator";import d from"@laynezh/vite-plugin-lib-assets";import f from"vite-plugin-dts";var p=(e,t)=>({name:e,test:e=>!!t.find(t=>e.includes(`/src/${t}`))}),m=(e,t)=>({name:e,test:e=>!!t.find(t=>e.includes(`/node_modules/${t}/`))}),h=()=>({name:`@basmilius/vite-preset/close-bundle`,closeBundle(){process.exit(0)}});const g=[`tsconfig.app.json`,`tsconfig.json`],_=process.cwd();var v=s=>{let c=o(_),l=r(s.isolated?_:i(_,c),`node_modules`),u=s.sourcesPathGenerator??(e=>a(_,`${l}/${e}/src`)),d=s.tsAliasPathGenerator??(e=>`${l}/${e}/src/*`),f=u(s.name);return()=>({name:s.name,config:()=>({optimizeDeps:{exclude:[s.name]},resolve:{alias:{[s.name]:f,[s.alias]:f}},server:{fs:{allow:[f]}}}),configResolved(i){let a;for(let t of g){let n=r(i.root,t);if(e(n)){a=n;break}}a||(i.logger.error(`[${s.name}] A tsconfig.json is required for this library. Please create one.`),process.exit(1));let o=`${s.alias}/*`,c=t(a,{encoding:`utf-8`}),l=JSON.parse(c);l.compilerOptions.paths??={},!(o in l.compilerOptions.paths)&&(l.compilerOptions.paths[o]=[d(s.name)],n(a,JSON.stringify(l,null,4),{encoding:`utf-8`}))}})};const y=[],b=e=>{function t(t){return t.startsWith(`i__const_`)&&(t=t.substring(9),t=t.substring(0,t.length-2)),e.cssModules?.classNames===`camel`?s(t):e.cssModules?.classNames===`kebab`?c(t):y.includes(t)?u(y.indexOf(t)):u(y.push(t)-1)}return{name:`@basmilius/vite-preset`,config:()=>({build:{assetsInlineLimit:0,cssMinify:e.isLibrary?!1:`lightningcss`,minify:e.isLibrary?!1:`oxc`,rolldownOptions:{output:{assetFileNames:e.fileNames===`actual`||e.isLibrary?void 0:`[hash].[ext]`,chunkFileNames:e.fileNames===`actual`||e.isLibrary?void 0:`[hash].js`,entryFileNames:e.fileNames===`actual`||e.isLibrary?void 0:`[hash].js`,minifyInternalExports:!0}}},css:{preprocessorMaxWorkers:!0,preprocessorOptions:{scss:{api:`modern-compiler`}},modules:{generateScopedName:e.cssModules?.generateScopedName??t}},json:{stringify:!0},resolve:{alias:{"@":a(process.cwd(),`./src`)},extensions:[`.js`,`.ts`,`.json`,`.vue`]},server:{fs:{allow:[o(process.cwd())]}}})}};var x=(e={})=>[l(),b(e),e.isLibrary&&d({limit:0,name:e.assetFileNames??`[contenthash:8].[ext]`}),e.isLibrary&&f({cleanVueFileName:!1,copyDtsFiles:!0,staticImport:!0,tsconfigPath:e.tsconfigPath})];const S=v({name:`@flux-ui/components`,alias:`$flux`}),C=v({name:`@flux-ui/dashboard`,alias:`$fluxDashboard`}),w=v({name:`@flux-ui/statistics`,alias:`$fluxStatistics`});export{p as advancedAppChunk,m as advancedLibraryChunk,h as closeBundle,v as composeLibrary,S as flux,C as fluxDashboard,w as fluxStatistics,x as preset};
2
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":["composeLibrary"],"sources":["../src/advancedAppChunk.ts","../src/advancedLibraryChunk.ts","../src/closeBundle.ts","../src/composeLibrary.ts","../src/preset.ts","../src/libraries.ts"],"sourcesContent":["type AdvancedChunk = {\n readonly name: string;\n readonly test: (moduleId: string) => boolean;\n};\n\nexport default (name: string, moduleIds: string[]): AdvancedChunk => ({\n name: name,\n test: moduleId => !!moduleIds.find(module => moduleId.includes(`/src/${module}`))\n});\n","type AdvancedChunk = {\n readonly name: string;\n readonly test: (moduleId: string) => boolean;\n};\n\nexport default (name: string, moduleIds: string[]): AdvancedChunk => ({\n name: name,\n test: moduleId => !!moduleIds.find(module => moduleId.includes(`/node_modules/${module}/`))\n});\n","import type { Plugin } from 'vite';\n\nexport default (): Plugin => ({\n name: '@basmilius/vite-preset/close-bundle',\n\n closeBundle() {\n process.exit(0);\n }\n});\n","import { existsSync, readFileSync, writeFileSync } from 'node:fs';\nimport { join, relative, resolve } from 'node:path';\nimport type { Plugin, UserConfig } from 'vite';\nimport { searchForWorkspaceRoot } from 'vite';\n\ntype ComposePlugin = () => Plugin;\ntype PathGenerator = (name: string) => string;\n\ntype Options = {\n readonly alias: string;\n readonly isolated?: boolean;\n readonly name: string;\n readonly sourcesPathGenerator?: PathGenerator;\n readonly tsAliasPathGenerator?: PathGenerator;\n};\n\nconst TSCONFIG_FILES = ['tsconfig.app.json', 'tsconfig.json'] as const;\nconst WORKING_DIR = process.cwd();\n\nexport default (options: Options): ComposePlugin => {\n const WORKSPACE_ROOT = searchForWorkspaceRoot(WORKING_DIR);\n const WORKSPACE_NODE_MODULES = join(options.isolated ? WORKING_DIR : relative(WORKING_DIR, WORKSPACE_ROOT), 'node_modules');\n\n const sourcesPathGenerator = options.sourcesPathGenerator ?? (name => resolve(WORKING_DIR, `${WORKSPACE_NODE_MODULES}/${name}/src`));\n const tsAliasPathGenerator = options.tsAliasPathGenerator ?? (name => `${WORKSPACE_NODE_MODULES}/${name}/src/*`);\n\n const src = sourcesPathGenerator(options.name);\n\n return (): Plugin => ({\n name: options.name,\n\n config: (): UserConfig => ({\n optimizeDeps: {\n exclude: [options.name]\n },\n resolve: {\n alias: {\n [options.name]: src,\n [options.alias]: src\n }\n },\n server: {\n fs: {\n allow: [src]\n }\n }\n }),\n\n configResolved(config): void {\n let tsconfigPath: string | undefined;\n\n for (const file of TSCONFIG_FILES) {\n const path = join(config.root, file);\n\n if (existsSync(path)) {\n tsconfigPath = path;\n break;\n }\n }\n\n if (!tsconfigPath) {\n config.logger.error(`[${options.name}] A tsconfig.json is required for this library. Please create one.`);\n process.exit(1);\n }\n\n const key = `${options.alias}/*`;\n const tsconfigData = readFileSync(tsconfigPath, {encoding: 'utf-8'});\n const tsconfig = JSON.parse(tsconfigData);\n tsconfig.compilerOptions.paths ??= {};\n\n if (key in tsconfig.compilerOptions.paths) {\n return;\n }\n\n tsconfig.compilerOptions.paths[key] = [tsAliasPathGenerator(options.name)];\n\n writeFileSync(tsconfigPath, JSON.stringify(tsconfig, null, 4), {encoding: 'utf-8'});\n }\n });\n};\n","import { resolve } from 'node:path';\nimport { camelCase, kebabCase } from 'change-case';\nimport { patchCssModules } from 'vite-css-modules';\nimport type { Plugin } from 'vite';\nimport { searchForWorkspaceRoot } from 'vite';\nimport className from 'css-class-generator';\nimport libAssets from '@laynezh/vite-plugin-lib-assets';\nimport libDts from 'vite-plugin-dts';\n\nconst VISITED_CLASSES: string[] = [];\n\ntype Options = {\n readonly cssModules?: {\n readonly classNames?: 'mangled' | 'camel' | 'kebab';\n readonly generateScopedName?: (name: string, filename: string, css: string) => string;\n };\n readonly assetFileNames?: string;\n readonly fileNames?: 'hashes' | 'actual';\n readonly isLibrary?: boolean;\n readonly tsconfigPath?: string;\n};\n\nconst preset = (options: Options): Plugin => {\n function generateScopedName(name: string): string {\n if (name.startsWith('i__const_')) {\n name = name.substring(9);\n name = name.substring(0, name.length - 2);\n }\n\n if (options.cssModules?.classNames === 'camel') {\n return camelCase(name);\n }\n\n if (options.cssModules?.classNames === 'kebab') {\n return kebabCase(name);\n }\n\n if (VISITED_CLASSES.includes(name)) {\n return className(VISITED_CLASSES.indexOf(name));\n }\n\n return className(VISITED_CLASSES.push(name) - 1);\n }\n\n return {\n name: '@basmilius/vite-preset',\n\n config: () => ({\n build: {\n assetsInlineLimit: 0,\n cssMinify: options.isLibrary ? false : 'lightningcss',\n minify: options.isLibrary ? false : 'oxc',\n rolldownOptions: {\n output: {\n assetFileNames: options.fileNames === 'actual' || options.isLibrary ? undefined : '[hash].[ext]',\n chunkFileNames: options.fileNames === 'actual' || options.isLibrary ? undefined : '[hash].js',\n entryFileNames: options.fileNames === 'actual' || options.isLibrary ? undefined : '[hash].js',\n minifyInternalExports: true\n }\n }\n },\n css: {\n preprocessorMaxWorkers: true,\n preprocessorOptions: {\n scss: {\n api: 'modern-compiler'\n }\n },\n modules: {\n generateScopedName: options.cssModules?.generateScopedName ?? generateScopedName\n }\n },\n json: {\n stringify: true\n },\n resolve: {\n alias: {\n '@': resolve(process.cwd(), './src')\n },\n extensions: [\n '.js',\n '.ts',\n '.json',\n '.vue'\n ]\n },\n server: {\n fs: {\n allow: [\n searchForWorkspaceRoot(process.cwd())\n ]\n }\n }\n })\n };\n};\n\nexport default (options: Options = {}): Plugin[] => [\n patchCssModules() as unknown as Plugin,\n preset(options),\n\n (options.isLibrary && libAssets({\n limit: 0,\n name: options.assetFileNames ?? '[contenthash:8].[ext]'\n })) as unknown as Plugin,\n\n (options.isLibrary && libDts({\n cleanVueFileName: false,\n copyDtsFiles: true,\n staticImport: true,\n tsconfigPath: options.tsconfigPath\n })) as unknown as Plugin\n] satisfies Plugin[];\n","import type { Plugin } from 'vite';\nimport composeLibrary from './composeLibrary';\n\ntype LibraryPlugin = () => Plugin;\n\nexport const flux: LibraryPlugin = composeLibrary({\n name: '@flux-ui/components',\n alias: '$flux'\n});\n\nexport const fluxDashboard: LibraryPlugin = composeLibrary({\n name: '@flux-ui/dashboard',\n alias: '$fluxDashboard'\n});\n\nexport const fluxStatistics: LibraryPlugin = composeLibrary({\n name: '@flux-ui/statistics',\n alias: '$fluxStatistics'\n});\n"],"mappings":"+YAKA,IAAA,GAAgB,EAAc,KAAwC,CAC5D,OACN,KAAM,GAAY,CAAC,CAAC,EAAU,KAAK,GAAU,EAAS,SAAS,QAAQ,IAAS,CAAC,CACpF,ECHD,GAAgB,EAAc,KAAwC,CAC5D,OACN,KAAM,GAAY,CAAC,CAAC,EAAU,KAAK,GAAU,EAAS,SAAS,iBAAiB,EAAO,GAAG,CAAC,CAC9F,ECND,OAA8B,CAC1B,KAAM,sCAEN,aAAc,CACV,QAAQ,KAAK,EAAE,EAEtB,ECQD,MAAM,EAAiB,CAAC,oBAAqB,gBAAgB,CACvD,EAAc,QAAQ,KAAK,CAEjC,IAAA,EAAgB,GAAoC,CAChD,IAAM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AM,sBACN,MAAO,QACV,CAAC,CAEW,EAA+BA,EAAe,CACvD,KAAM,qBACN,MAAO,iBACV,CAAC,CAEW,EAAgCA,EAAe,CACxD,KAAM,sBACN,MAAO,kBACV,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@basmilius/vite-preset",
3
3
  "description": "Commonly used presets used in Vite + Vue setups.",
4
- "version": "3.7.1",
4
+ "version": "3.9.0",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "funding": "https://github.com/sponsors/basmilius",
@@ -32,15 +32,15 @@
32
32
  "provenance": true
33
33
  },
34
34
  "scripts": {
35
- "build": "tsgo --noEmit && bun -b build.ts"
35
+ "build": "tsgo --noEmit && tsdown"
36
36
  },
37
- "main": "./dist/index.js",
38
- "types": "./dist/index.d.ts",
39
- "typings": "./dist/index.d.ts",
37
+ "main": "./dist/index.mjs",
38
+ "types": "./dist/index.d.mts",
39
+ "typings": "./dist/index.d.mts",
40
40
  "exports": {
41
41
  ".": {
42
- "types": "./dist/index.d.ts",
43
- "default": "./dist/index.js"
42
+ "types": "./dist/index.d.mts",
43
+ "default": "./dist/index.mjs"
44
44
  }
45
45
  },
46
46
  "dependencies": {
@@ -48,11 +48,11 @@
48
48
  "change-case": "^5.4.4",
49
49
  "css-class-generator": "^2.0.0",
50
50
  "lightningcss": "^1.31.1",
51
+ "vite": "^8.0.0-beta.16",
51
52
  "vite-css-modules": "^1.13.0",
52
53
  "vite-plugin-dts": "^4.5.4"
53
54
  },
54
55
  "devDependencies": {
55
- "@basmilius/tools": "3.7.1",
56
- "vite": "^8.0.0-beta.15"
56
+ "tsdown": "^0.21.0-beta.2"
57
57
  }
58
58
  }
@@ -1,6 +0,0 @@
1
- type AdvancedChunk = {
2
- readonly name: string;
3
- readonly test: (moduleId: string) => boolean;
4
- };
5
- declare const _default: (name: string, moduleIds: string[]) => AdvancedChunk;
6
- export default _default;
@@ -1,6 +0,0 @@
1
- type AdvancedChunk = {
2
- readonly name: string;
3
- readonly test: (moduleId: string) => boolean;
4
- };
5
- declare const _default: (name: string, moduleIds: string[]) => AdvancedChunk;
6
- export default _default;
@@ -1,3 +0,0 @@
1
- import type { Plugin } from "vite";
2
- declare const _default: () => Plugin;
3
- export default _default;
@@ -1,12 +0,0 @@
1
- import type { Plugin } from "vite";
2
- type ComposePlugin = () => Plugin;
3
- type PathGenerator = (name: string) => string;
4
- type Options = {
5
- readonly alias: string;
6
- readonly isolated?: boolean;
7
- readonly name: string;
8
- readonly sourcesPathGenerator?: PathGenerator;
9
- readonly tsAliasPathGenerator?: PathGenerator;
10
- };
11
- declare const _default: (options: Options) => ComposePlugin;
12
- export default _default;
package/dist/index.d.ts DELETED
@@ -1,7 +0,0 @@
1
- import advancedAppChunk from "./advancedAppChunk";
2
- import advancedLibraryChunk from "./advancedLibraryChunk";
3
- import closeBundle from "./closeBundle";
4
- import composeLibrary from "./composeLibrary";
5
- import preset from "./preset";
6
- export { advancedAppChunk, advancedLibraryChunk, closeBundle, composeLibrary, preset };
7
- export { flux, fluxDashboard, fluxStatistics } from "./libraries";
package/dist/index.js DELETED
@@ -1,4 +0,0 @@
1
- var b=(e,r)=>({name:e,test:(s)=>!!r.find((a)=>s.includes(`/src/${a}`))});var P=(e,r)=>({name:e,test:(s)=>!!r.find((a)=>s.includes(`/node_modules/${a}/`))});var x=()=>({name:"@basmilius/vite-preset/close-bundle",closeBundle(){process.exit(0)}});import{existsSync as N,readFileSync as v,writeFileSync as O}from"node:fs";import{join as f,relative as S,resolve as L}from"node:path";import{searchForWorkspaceRoot as k}from"vite";var C=["tsconfig.app.json","tsconfig.json"],l=process.cwd(),i=(e)=>{let r=k(l),s=f(e.isolated?l:S(l,r),"node_modules"),a=e.sourcesPathGenerator??((t)=>L(l,`${s}/${t}/src`)),g=e.tsAliasPathGenerator??((t)=>`${s}/${t}/src/*`),c=a(e.name);return()=>({name:e.name,config:()=>({optimizeDeps:{exclude:[e.name]},resolve:{alias:{[e.name]:c,[e.alias]:c}},server:{fs:{allow:[c]}}}),configResolved(t){let n;for(let h of C){let d=f(t.root,h);if(N(d)){n=d;break}}if(!n)t.logger.error(`[${e.name}] A tsconfig.json is required for this library. Please create one.`),process.exit(1);let m=`${e.alias}/*`,y=v(n,{encoding:"utf-8"}),o=JSON.parse(y);if(o.compilerOptions.paths??={},m in o.compilerOptions.paths)return;o.compilerOptions.paths[m]=[g(e.name)],O(n,JSON.stringify(o,null,4),{encoding:"utf-8"})}})};import{resolve as A}from"node:path";import{camelCase as F,kebabCase as D}from"change-case";import{patchCssModules as G}from"vite-css-modules";import{searchForWorkspaceRoot as I}from"vite";import p from"css-class-generator";import _ from"@laynezh/vite-plugin-lib-assets";import $ from"vite-plugin-dts";var u=[],w=(e)=>{function r(s){if(s.startsWith("i__const_"))s=s.substring(9),s=s.substring(0,s.length-2);if(e.cssModules?.classNames==="camel")return F(s);if(e.cssModules?.classNames==="kebab")return D(s);if(u.includes(s))return p(u.indexOf(s));return p(u.push(s)-1)}return{name:"@basmilius/vite-preset",config:()=>({build:{assetsInlineLimit:0,cssMinify:e.isLibrary?!1:"lightningcss",minify:e.isLibrary?!1:"oxc",rolldownOptions:{output:{assetFileNames:e.fileNames==="actual"||e.isLibrary?void 0:"[hash].[ext]",chunkFileNames:e.fileNames==="actual"||e.isLibrary?void 0:"[hash].js",entryFileNames:e.fileNames==="actual"||e.isLibrary?void 0:"[hash].js",minifyInternalExports:!0}}},css:{preprocessorMaxWorkers:!0,preprocessorOptions:{scss:{api:"modern-compiler"}},modules:{generateScopedName:e.cssModules?.generateScopedName??r}},json:{stringify:!0},resolve:{alias:{"@":A(process.cwd(),"./src")},extensions:[".js",".ts",".json",".vue"]},server:{fs:{allow:[I(process.cwd())]}}})}},j=(e={})=>[G(),w(e),e.isLibrary&&_({limit:0,name:e.assetFileNames??"[contenthash:8].[ext]"}),e.isLibrary&&$({cleanVueFileName:!1,copyDtsFiles:!0,staticImport:!0,tsconfigPath:e.tsconfigPath})];var E=i({name:"@flux-ui/components",alias:"$flux"}),M=i({name:"@flux-ui/dashboard",alias:"$fluxDashboard"}),R=i({name:"@flux-ui/statistics",alias:"$fluxStatistics"});export{j as preset,R as fluxStatistics,M as fluxDashboard,E as flux,i as composeLibrary,x as closeBundle,P as advancedLibraryChunk,b as advancedAppChunk};
2
-
3
- //# debugId=B9C4549380C2DFAB64756E2164756E21
4
- //# sourceMappingURL=index.js.map
package/dist/index.js.map DELETED
@@ -1,15 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/advancedAppChunk.ts", "../src/advancedLibraryChunk.ts", "../src/closeBundle.ts", "../src/composeLibrary.ts", "../src/preset.ts", "../src/libraries.ts"],
4
- "sourcesContent": [
5
- "type AdvancedChunk = {\n readonly name: string;\n readonly test: (moduleId: string) => boolean;\n};\n\nexport default (name: string, moduleIds: string[]): AdvancedChunk => ({\n name: name,\n test: moduleId => !!moduleIds.find(module => moduleId.includes(`/src/${module}`))\n});\n",
6
- "type AdvancedChunk = {\n readonly name: string;\n readonly test: (moduleId: string) => boolean;\n};\n\nexport default (name: string, moduleIds: string[]): AdvancedChunk => ({\n name: name,\n test: moduleId => !!moduleIds.find(module => moduleId.includes(`/node_modules/${module}/`))\n});\n",
7
- "import type { Plugin } from 'vite';\n\nexport default (): Plugin => ({\n name: '@basmilius/vite-preset/close-bundle',\n\n closeBundle() {\n process.exit(0);\n }\n});\n",
8
- "import { existsSync, readFileSync, writeFileSync } from 'node:fs';\nimport { join, relative, resolve } from 'node:path';\nimport type { Plugin, UserConfig } from 'vite';\nimport { searchForWorkspaceRoot } from 'vite';\n\ntype ComposePlugin = () => Plugin;\ntype PathGenerator = (name: string) => string;\n\ntype Options = {\n readonly alias: string;\n readonly isolated?: boolean;\n readonly name: string;\n readonly sourcesPathGenerator?: PathGenerator;\n readonly tsAliasPathGenerator?: PathGenerator;\n};\n\nconst TSCONFIG_FILES = ['tsconfig.app.json', 'tsconfig.json'] as const;\nconst WORKING_DIR = process.cwd();\n\nexport default (options: Options): ComposePlugin => {\n const WORKSPACE_ROOT = searchForWorkspaceRoot(WORKING_DIR);\n const WORKSPACE_NODE_MODULES = join(options.isolated ? WORKING_DIR : relative(WORKING_DIR, WORKSPACE_ROOT), 'node_modules');\n\n const sourcesPathGenerator = options.sourcesPathGenerator ?? (name => resolve(WORKING_DIR, `${WORKSPACE_NODE_MODULES}/${name}/src`));\n const tsAliasPathGenerator = options.tsAliasPathGenerator ?? (name => `${WORKSPACE_NODE_MODULES}/${name}/src/*`);\n\n const src = sourcesPathGenerator(options.name);\n\n return (): Plugin => ({\n name: options.name,\n\n config: (): UserConfig => ({\n optimizeDeps: {\n exclude: [options.name]\n },\n resolve: {\n alias: {\n [options.name]: src,\n [options.alias]: src\n }\n },\n server: {\n fs: {\n allow: [src]\n }\n }\n }),\n\n configResolved(config): void {\n let tsconfigPath: string | undefined;\n\n for (const file of TSCONFIG_FILES) {\n const path = join(config.root, file);\n\n if (existsSync(path)) {\n tsconfigPath = path;\n break;\n }\n }\n\n if (!tsconfigPath) {\n config.logger.error(`[${options.name}] A tsconfig.json is required for this library. Please create one.`);\n process.exit(1);\n }\n\n const key = `${options.alias}/*`;\n const tsconfigData = readFileSync(tsconfigPath, {encoding: 'utf-8'});\n const tsconfig = JSON.parse(tsconfigData);\n tsconfig.compilerOptions.paths ??= {};\n\n if (key in tsconfig.compilerOptions.paths) {\n return;\n }\n\n tsconfig.compilerOptions.paths[key] = [tsAliasPathGenerator(options.name)];\n\n writeFileSync(tsconfigPath, JSON.stringify(tsconfig, null, 4), {encoding: 'utf-8'});\n }\n });\n};\n",
9
- "import { resolve } from 'node:path';\nimport { camelCase, kebabCase } from 'change-case';\nimport { patchCssModules } from 'vite-css-modules';\nimport type { Plugin } from 'vite';\nimport { searchForWorkspaceRoot } from 'vite';\nimport className from 'css-class-generator';\nimport libAssets from '@laynezh/vite-plugin-lib-assets';\nimport libDts from 'vite-plugin-dts';\n\nconst VISITED_CLASSES: string[] = [];\n\ntype Options = {\n readonly cssModules?: {\n readonly classNames?: 'mangled' | 'camel' | 'kebab';\n readonly generateScopedName?: (name: string, filename: string, css: string) => string;\n };\n readonly assetFileNames?: string;\n readonly fileNames?: 'hashes' | 'actual';\n readonly isLibrary?: boolean;\n readonly tsconfigPath?: string;\n};\n\nconst preset = (options: Options): Plugin => {\n function generateScopedName(name: string): string {\n if (name.startsWith('i__const_')) {\n name = name.substring(9);\n name = name.substring(0, name.length - 2);\n }\n\n if (options.cssModules?.classNames === 'camel') {\n return camelCase(name);\n }\n\n if (options.cssModules?.classNames === 'kebab') {\n return kebabCase(name);\n }\n\n if (VISITED_CLASSES.includes(name)) {\n return className(VISITED_CLASSES.indexOf(name));\n }\n\n return className(VISITED_CLASSES.push(name) - 1);\n }\n\n return {\n name: '@basmilius/vite-preset',\n\n config: () => ({\n build: {\n assetsInlineLimit: 0,\n cssMinify: options.isLibrary ? false : 'lightningcss',\n minify: options.isLibrary ? false : 'oxc',\n rolldownOptions: {\n output: {\n assetFileNames: options.fileNames === 'actual' || options.isLibrary ? undefined : '[hash].[ext]',\n chunkFileNames: options.fileNames === 'actual' || options.isLibrary ? undefined : '[hash].js',\n entryFileNames: options.fileNames === 'actual' || options.isLibrary ? undefined : '[hash].js',\n minifyInternalExports: true\n }\n }\n },\n css: {\n preprocessorMaxWorkers: true,\n preprocessorOptions: {\n scss: {\n api: 'modern-compiler'\n }\n },\n modules: {\n generateScopedName: options.cssModules?.generateScopedName ?? generateScopedName\n }\n },\n json: {\n stringify: true\n },\n resolve: {\n alias: {\n '@': resolve(process.cwd(), './src')\n },\n extensions: [\n '.js',\n '.ts',\n '.json',\n '.vue'\n ]\n },\n server: {\n fs: {\n allow: [\n searchForWorkspaceRoot(process.cwd())\n ]\n }\n }\n })\n };\n};\n\nexport default (options: Options = {}): Plugin[] => [\n patchCssModules() as unknown as Plugin,\n preset(options),\n\n (options.isLibrary && libAssets({\n limit: 0,\n name: options.assetFileNames ?? '[contenthash:8].[ext]'\n })) as unknown as Plugin,\n\n (options.isLibrary && libDts({\n cleanVueFileName: false,\n copyDtsFiles: true,\n staticImport: true,\n tsconfigPath: options.tsconfigPath\n })) as unknown as Plugin\n] satisfies Plugin[];\n",
10
- "import type { Plugin } from 'vite';\nimport composeLibrary from './composeLibrary';\n\ntype LibraryPlugin = () => Plugin;\n\nexport const flux: LibraryPlugin = composeLibrary({\n name: '@flux-ui/components',\n alias: '$flux'\n});\n\nexport const fluxDashboard: LibraryPlugin = composeLibrary({\n name: '@flux-ui/dashboard',\n alias: '$fluxDashboard'\n});\n\nexport const fluxStatistics: LibraryPlugin = composeLibrary({\n name: '@flux-ui/statistics',\n alias: '$fluxStatistics'\n});\n"
11
- ],
12
- "mappings": "AAKA,IAAe,GAAC,EAAc,KAAwC,CAClE,KAAM,EACN,KAAM,KAAY,CAAC,CAAC,EAAU,KAAK,KAAU,EAAS,SAAS,QAAQ,GAAQ,CAAC,CACpF,GCHA,IAAe,GAAC,EAAc,KAAwC,CAClE,KAAM,EACN,KAAM,KAAY,CAAC,CAAC,EAAU,KAAK,KAAU,EAAS,SAAS,iBAAiB,IAAS,CAAC,CAC9F,GCNA,IAAe,OAAe,CAC1B,KAAM,sCAEN,WAAW,EAAG,CACV,QAAQ,KAAK,CAAC,EAEtB,GCRA,qBAAS,kBAAY,mBAAc,gBACnC,eAAS,cAAM,aAAU,kBAEzB,iCAAS,aAaT,IAAM,EAAiB,CAAC,oBAAqB,eAAe,EACtD,EAAc,QAAQ,IAAI,EAEjB,GAAC,IAAoC,CAChD,IAAM,EAAiB,EAAuB,CAAW,EACnD,EAAyB,EAAK,EAAQ,SAAW,EAAc,EAAS,EAAa,CAAc,EAAG,cAAc,EAEpH,EAAuB,EAAQ,uBAAyB,KAAQ,EAAQ,EAAa,GAAG,KAA0B,OAAU,GAC5H,EAAuB,EAAQ,uBAAyB,KAAQ,GAAG,KAA0B,WAE7F,EAAM,EAAqB,EAAQ,IAAI,EAE7C,MAAO,KAAe,CAClB,KAAM,EAAQ,KAEd,OAAQ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"names": []
15
- }
@@ -1,6 +0,0 @@
1
- import type { Plugin } from "vite";
2
- type LibraryPlugin = () => Plugin;
3
- export declare const flux: LibraryPlugin;
4
- export declare const fluxDashboard: LibraryPlugin;
5
- export declare const fluxStatistics: LibraryPlugin;
6
- export {};
package/dist/preset.d.ts DELETED
@@ -1,13 +0,0 @@
1
- import type { Plugin } from "vite";
2
- type Options = {
3
- readonly cssModules?: {
4
- readonly classNames?: "mangled" | "camel" | "kebab";
5
- readonly generateScopedName?: (name: string, filename: string, css: string) => string;
6
- };
7
- readonly assetFileNames?: string;
8
- readonly fileNames?: "hashes" | "actual";
9
- readonly isLibrary?: boolean;
10
- readonly tsconfigPath?: string;
11
- };
12
- declare const _default: (options?: Options) => Plugin[];
13
- export default _default;