vite-plugin-lucide-preprocess 1.3.1 → 1.4.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.
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +28 -24
- package/dist/plugin.js.map +1 -1
- package/package.json +4 -3
package/dist/plugin.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.js"],"names":[],"mappings":"AAKA,6DAA6D;AAE7D;;;;;;GAMG;AACH,8CAJsB,MAAM,GAChB,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC,CAiB/B;AAED;;;;;GAKG;AACH,4CAHqB,MAAM,GACf,MAAM,CAgBjB;AAED;;;;;GAKG;AACH,+CAJqB,MAAM,WACR,OAAO,GACd,MAAM,CAYjB;AAkBD;;;;GAIG;AACH,iCAHmB,OAAO,GACd,OAAO,MAAM,EAAE,MAAM,CAgDhC;AAnED,oCACyF;qBAlE3E;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE"}
|
package/dist/plugin.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import renamedReplacementsModules from "./renamedReplacements.js";
|
|
2
|
+
import MagicString from "magic-string";
|
|
2
3
|
const ignoredPaths = ["/node_modules/", "/.svelte-kit/"];
|
|
3
4
|
/** @typedef {{ name: string; importName: string }} Module */
|
|
4
5
|
/**
|
|
@@ -86,31 +87,34 @@ export function plugin(options = defaultOptions) {
|
|
|
86
87
|
transform: (code, path) => {
|
|
87
88
|
if (ignoredPaths.some(p => path.includes(p)))
|
|
88
89
|
return;
|
|
90
|
+
const s = new MagicString(code);
|
|
91
|
+
s.replace(importsMatcher,
|
|
92
|
+
/**
|
|
93
|
+
* @param _ The whole matched string
|
|
94
|
+
* @param initialSpacing {string} The spacing before the matched import statement
|
|
95
|
+
* @param modulesStr {string} The imported icons as a raw string
|
|
96
|
+
* @param quote {string} The quote used in the import statement (either ' or ")
|
|
97
|
+
* @param importStyle {string} The method the icons are imported with
|
|
98
|
+
* @param framework {string} The framework the icons are imported for
|
|
99
|
+
* @param lineEnding {string} The end of the line of the matched import statement (often a semicolon)
|
|
100
|
+
* @return The optimized import statement(s)
|
|
101
|
+
*/
|
|
102
|
+
(_, initialSpacing, modulesStr, quote, importStyle, framework, lineEnding) => {
|
|
103
|
+
const [modules, types] = rawModulesToLists(modulesStr);
|
|
104
|
+
const moduleImports = modules
|
|
105
|
+
.map(m => `${initialSpacing}import ${m.name} from ${quote}${importStyle}${framework}${frameworkImportPath(framework, mergedOptions)}${iconCompToDashed(m.importName)}${quote}${lineEnding.trimEnd()}`)
|
|
106
|
+
.join(initialSpacing.includes("\n") ? "" : "\n");
|
|
107
|
+
const typesImport = `${initialSpacing}import type { ${types.join(", ")} } from ${quote}${importStyle}${framework}${quote}${lineEnding.trimEnd()}`;
|
|
108
|
+
return [
|
|
109
|
+
types.length ? typesImport : undefined,
|
|
110
|
+
modules.length ? moduleImports : undefined
|
|
111
|
+
]
|
|
112
|
+
.filter(Boolean)
|
|
113
|
+
.join(initialSpacing.includes("\n") ? "" : "\n");
|
|
114
|
+
});
|
|
89
115
|
return {
|
|
90
|
-
code:
|
|
91
|
-
|
|
92
|
-
* @param _ The whole matched string
|
|
93
|
-
* @param initialSpacing {string} The spacing before the matched import statement
|
|
94
|
-
* @param modulesStr {string} The imported icons as a raw string
|
|
95
|
-
* @param quote {string} The quote used in the import statement (either ' or ")
|
|
96
|
-
* @param importStyle {string} The method the icons are imported with
|
|
97
|
-
* @param framework {string} The framework the icons are imported for
|
|
98
|
-
* @param lineEnding {string} The end of the line of the matched import statement (often a semicolon)
|
|
99
|
-
* @return The optimized import statement(s)
|
|
100
|
-
*/
|
|
101
|
-
(_, initialSpacing, modulesStr, quote, importStyle, framework, lineEnding) => {
|
|
102
|
-
const [modules, types] = rawModulesToLists(modulesStr);
|
|
103
|
-
const moduleImports = modules
|
|
104
|
-
.map(m => `${initialSpacing}import ${m.name} from ${quote}${importStyle}${framework}${frameworkImportPath(framework, mergedOptions)}${iconCompToDashed(m.importName)}${quote}${lineEnding.trimEnd()}`)
|
|
105
|
-
.join(initialSpacing.includes("\n") ? "" : "\n");
|
|
106
|
-
const typesImport = `${initialSpacing}import type { ${types.join(", ")} } from ${quote}${importStyle}${framework}${quote}${lineEnding.trimEnd()}`;
|
|
107
|
-
return [
|
|
108
|
-
types.length ? typesImport : undefined,
|
|
109
|
-
modules.length ? moduleImports : undefined
|
|
110
|
-
]
|
|
111
|
-
.filter(Boolean)
|
|
112
|
-
.join(initialSpacing.includes("\n") ? "" : "\n");
|
|
113
|
-
})
|
|
116
|
+
code: s.toString(),
|
|
117
|
+
map: s.generateMap({ hires: "boundary", source: path })
|
|
114
118
|
};
|
|
115
119
|
}
|
|
116
120
|
};
|
package/dist/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.js"],"names":[],"mappings":"AAAA,OAAO,0BAA0B,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.js"],"names":[],"mappings":"AAAA,OAAO,0BAA0B,MAAM,0BAA0B,CAAC;AAClE,OAAO,WAAW,MAAM,cAAc,CAAC;AAEvC,MAAM,YAAY,GAAG,CAAC,gBAAgB,EAAE,eAAe,CAAC,CAAC;AAEzD,6DAA6D;AAE7D;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAAC,UAAU;IAC3C,MAAM,GAAG,GAAG,UAAU;SACpB,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;SAClB,MAAM,CAAC,CA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-plugin-lucide-preprocess",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"author": {
|
|
5
5
|
"url": "https://github.com/WarningImHack3r",
|
|
6
6
|
"name": "WarningImHack3r"
|
|
@@ -31,11 +31,12 @@
|
|
|
31
31
|
"vite": ">=5"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"lucide-svelte": "^0.
|
|
34
|
+
"lucide-svelte": "^0.525.0",
|
|
35
|
+
"magic-string": "^0.30.0",
|
|
35
36
|
"prettier": "^3.0.0",
|
|
36
37
|
"publint": "^0.3.0",
|
|
37
38
|
"typescript": "^5.0.0",
|
|
38
|
-
"vite": "^
|
|
39
|
+
"vite": "^7.0.0",
|
|
39
40
|
"vitest": "^3.0.0"
|
|
40
41
|
},
|
|
41
42
|
"main": "./dist/index.js",
|