vite-plugin-strip-comments 0.0.6 → 0.0.7
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/README.md +9 -6
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +23 -14
- package/dist/index.mjs.map +1 -1
- package/package.json +12 -8
- package/tsconfig.json +35 -36
- package/vite.config.ts +14 -14
package/README.md
CHANGED
|
@@ -4,12 +4,14 @@
|
|
|
4
4
|
[](https://github.com/thednp/vite-plugin-strip-comments/actions/workflows/ci.yml)
|
|
5
5
|
[](https://www.npmjs.com/package/vite-plugin-strip-comments)
|
|
6
6
|
[](http://npm-stat.com/charts.html?package=vite-plugin-strip-comments)
|
|
7
|
-
[](https://www.typescriptlang.org/)
|
|
8
|
+
[](https://vitest.dev/)
|
|
9
|
+
[](https://github.com/vitejs)
|
|
10
10
|
|
|
11
11
|
A very simple Vite plugin for stripping comments in your production code. Some comments just don't get removed no matter what minify options you set, especially `/* istanbul ignore */` flags. Keep in mind this is experimental, please **use with caution**.
|
|
12
12
|
|
|
13
|
+
> NOTE - this plugin should be compatible with rollup, rolldown, tsup and tsdown as well.
|
|
14
|
+
|
|
13
15
|
## Install
|
|
14
16
|
|
|
15
17
|
```bash
|
|
@@ -45,10 +47,11 @@ export default defineConfig({
|
|
|
45
47
|
|
|
46
48
|
**Options**
|
|
47
49
|
|
|
48
|
-
* type
|
|
50
|
+
* `type`: "none" | "keep-jsdoc" | "keep-legal" (default) - changes the behavior of the transform function
|
|
49
51
|
* **none** removes all comments
|
|
50
|
-
* **keep-legal** remove all commments except those which contain `@legal` or `@license`, a very good practice to allow open source to shine yes?
|
|
51
|
-
*
|
|
52
|
+
* **keep-legal** remove all commments except those which contain `@copyright`, `@legal` or `@license`, a very good practice to allow open source to shine yes?
|
|
53
|
+
* **keep-jsdoc** remove all commments except legal (described above) and JSDoc
|
|
54
|
+
* `enforce`: "pre" (default) | "post" - determines where in the compilation pipeline the plugin should work;
|
|
52
55
|
|
|
53
56
|
## Contributions
|
|
54
57
|
* Found a problem, [report](https://github.com/thednp/vite-plugin-strip-comments/issues) the problem. Thank you!
|
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";const a={type:"keep-legal",enforce:"pre"},
|
|
1
|
+
"use strict";const a={type:"keep-legal",enforce:"pre"},f=(n={})=>{const l={type:["none","keep-legal","keep-jsdoc"].some(e=>e===n.type)?n.type:a.type,enforce:["pre","post"].some(e=>e===n.enforce)?n.enforce:a.enforce};return{name:"vite-plugin-strip-comments",enforce:l.enforce,apply:"build",transform(e,r){if(!r||r.includes("node_modules")||!/\.([jt]sx?)$/.test(r))return{code:e,map:null};let t=e,s;const c=Array.from(e.matchAll(/\/\*[\s\S]*?\*\/|\/\*\*.*?\*\/|(?<!https?:)\/\/.*(?=\n)?/gm));for(let o=0;o<c.length;o+=1){[s]=c[o];const i=s.startsWith("/**"),p=["@legal","@license","@copyright"].some(m=>s.includes(m));switch(l.type){case"keep-jsdoc":!i&&!p&&(t=t.replace(s,""));break;case"keep-legal":p||(t=t.replace(s,""));break;default:t=t.replace(s,"")}}return{code:t,map:null}}}};module.exports=f;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../src/index.ts"],"sourcesContent":["import { type Plugin } from \"vite\";\n\nexport type StripCommentsPlugin = Plugin<StripCommentsConfig> & {\n name: string;\n enforce: \"pre\" | \"post\" | undefined;\n apply: \"build\";\n transform: (\n code: string,\n id?: string,\n ) => {\n code: string;\n map: string | null;\n };\n};\n\nexport type StripCommentsConfig = {\n type: \"none\" | \"keep-legal\";\n enforce: \"pre\" | \"post\" | undefined;\n};\n\nconst StripCommentsDefaultConfig: StripCommentsConfig = {\n type: \"keep-legal\",\n enforce: \"pre\",\n};\n\nconst stripComments = (cfg: Partial<StripCommentsConfig> = {}) => {\n const config: Partial<StripCommentsConfig> = {\n type
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../src/index.ts"],"sourcesContent":["import { type Plugin } from \"vite\";\n\nexport type StripCommentsPlugin = Plugin<StripCommentsConfig> & {\n name: string;\n enforce: \"pre\" | \"post\" | undefined;\n apply: \"build\";\n transform: (\n code: string,\n id?: string,\n ) => {\n code: string;\n map: string | null;\n };\n};\n\nexport type StripCommentsConfig = {\n type: \"none\" | \"keep-legal\" | \"keep-jsdoc\";\n enforce: \"pre\" | \"post\" | undefined;\n};\n\nconst StripCommentsDefaultConfig: StripCommentsConfig = {\n type: \"keep-legal\",\n enforce: \"pre\",\n};\n\nconst stripComments = (cfg: Partial<StripCommentsConfig> = {}) => {\n const config: Partial<StripCommentsConfig> = {\n type: [\"none\", \"keep-legal\", \"keep-jsdoc\"].some((x) => x === cfg.type)\n ? cfg.type\n : StripCommentsDefaultConfig.type,\n enforce: [\"pre\", \"post\"].some((x) => x === cfg.enforce)\n ? cfg.enforce\n : StripCommentsDefaultConfig.enforce,\n };\n\n return {\n name: \"vite-plugin-strip-comments\",\n enforce: config.enforce,\n apply: \"build\",\n transform(code: string, id?: string): { code: string; map: null } {\n /* istanbul ignore if @preserve */\n if (!id || id.includes(\"node_modules\") || !/\\.([jt]sx?)$/.test(id)) {\n return { code, map: null };\n }\n let result = code;\n let match: string;\n\n const matchesArray = Array.from(\n code.matchAll(\n /\\/\\*[\\s\\S]*?\\*\\/|\\/\\*\\*.*?\\*\\/|(?<!https?:)\\/\\/.*(?=\\n)?/gm,\n ),\n );\n\n for (let i = 0; i < matchesArray.length; i += 1) {\n // first match\n [match] = matchesArray[i];\n const isJSDoc = match.startsWith(\"/**\");\n const isLegal = [\"@legal\", \"@license\", \"@copyright\"].some((x) =>\n match.includes(x)\n );\n // console.log({ isJSDoc, isLegal, match });\n\n switch (config.type) {\n case \"keep-jsdoc\":\n if (!isJSDoc && !isLegal) {\n result = result.replace(match, \"\");\n }\n break;\n case \"keep-legal\":\n if (!isLegal) {\n result = result.replace(match, \"\");\n }\n break;\n case \"none\":\n default:\n result = result.replace(match, \"\");\n }\n }\n\n return { code: result, map: null };\n },\n } satisfies StripCommentsPlugin;\n};\n\nexport default stripComments;\n"],"names":["StripCommentsDefaultConfig","stripComments","cfg","config","x","code","id","result","match","matchesArray","i","isJSDoc","isLegal"],"mappings":"aAoBA,MAAMA,EAAkD,CACtD,KAAM,aACN,QAAS,KACX,EAEMC,EAAgB,CAACC,EAAoC,KAAO,CAChE,MAAMC,EAAuC,CAC3C,KAAM,CAAC,OAAQ,aAAc,YAAY,EAAE,KAAMC,GAAMA,IAAMF,EAAI,IAAI,EACjEA,EAAI,KACJF,EAA2B,KAC/B,QAAS,CAAC,MAAO,MAAM,EAAE,KAAMI,GAAMA,IAAMF,EAAI,OAAO,EAClDA,EAAI,QACJF,EAA2B,OAAA,EAGjC,MAAO,CACL,KAAM,6BACN,QAASG,EAAO,QAChB,MAAO,QACP,UAAUE,EAAcC,EAA0C,CAEhE,GAAI,CAACA,GAAMA,EAAG,SAAS,cAAc,GAAK,CAAC,eAAe,KAAKA,CAAE,EAC/D,MAAO,CAAE,KAAAD,EAAM,IAAK,IAAA,EAEtB,IAAIE,EAASF,EACTG,EAEJ,MAAMC,EAAe,MAAM,KACzBJ,EAAK,SACH,4DAAA,CACF,EAGF,QAASK,EAAI,EAAGA,EAAID,EAAa,OAAQC,GAAK,EAAG,CAE/C,CAACF,CAAK,EAAIC,EAAaC,CAAC,EACxB,MAAMC,EAAUH,EAAM,WAAW,KAAK,EAChCI,EAAU,CAAC,SAAU,WAAY,YAAY,EAAE,KAAMR,GACzDI,EAAM,SAASJ,CAAC,CAAA,EAIlB,OAAQD,EAAO,KAAA,CACb,IAAK,aACC,CAACQ,GAAW,CAACC,IACfL,EAASA,EAAO,QAAQC,EAAO,EAAE,GAEnC,MACF,IAAK,aACEI,IACHL,EAASA,EAAO,QAAQC,EAAO,EAAE,GAEnC,MAEF,QACED,EAASA,EAAO,QAAQC,EAAO,EAAE,CAAA,CAEvC,CAEA,MAAO,CAAE,KAAMD,EAAQ,IAAK,IAAA,CAC9B,CAAA,CAEJ"}
|
package/dist/index.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ declare const stripComments: (cfg?: Partial<StripCommentsConfig>) => {
|
|
|
10
10
|
export default stripComments;
|
|
11
11
|
|
|
12
12
|
declare type StripCommentsConfig = {
|
|
13
|
-
type: "none" | "keep-legal";
|
|
13
|
+
type: "none" | "keep-legal" | "keep-jsdoc";
|
|
14
14
|
enforce: "pre" | "post" | undefined;
|
|
15
15
|
};
|
|
16
16
|
|
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
const
|
|
1
|
+
const p = {
|
|
2
2
|
type: "keep-legal",
|
|
3
3
|
enforce: "pre"
|
|
4
|
-
},
|
|
4
|
+
}, f = (n = {}) => {
|
|
5
5
|
const o = {
|
|
6
|
-
type: ["none", "keep-legal"].some((e) => e === n.type) ? n.type :
|
|
7
|
-
enforce: ["pre", "post"].some((e) => e === n.enforce) ? n.enforce :
|
|
6
|
+
type: ["none", "keep-legal", "keep-jsdoc"].some((e) => e === n.type) ? n.type : p.type,
|
|
7
|
+
enforce: ["pre", "post"].some((e) => e === n.enforce) ? n.enforce : p.enforce
|
|
8
8
|
};
|
|
9
9
|
return {
|
|
10
10
|
name: "vite-plugin-strip-comments",
|
|
@@ -13,24 +13,33 @@ const a = {
|
|
|
13
13
|
transform(e, r) {
|
|
14
14
|
if (!r || r.includes("node_modules") || !/\.([jt]sx?)$/.test(r))
|
|
15
15
|
return { code: e, map: null };
|
|
16
|
-
let t = e,
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
let t = e, s;
|
|
17
|
+
const a = Array.from(
|
|
18
|
+
e.matchAll(
|
|
19
|
+
/\/\*[\s\S]*?\*\/|\/\*\*.*?\*\/|(?<!https?:)\/\/.*(?=\n)?/gm
|
|
20
|
+
)
|
|
21
|
+
);
|
|
22
|
+
for (let l = 0; l < a.length; l += 1) {
|
|
23
|
+
[s] = a[l];
|
|
24
|
+
const m = s.startsWith("/**"), c = ["@legal", "@license", "@copyright"].some(
|
|
25
|
+
(i) => s.includes(i)
|
|
26
|
+
);
|
|
27
|
+
switch (o.type) {
|
|
28
|
+
case "keep-jsdoc":
|
|
29
|
+
!m && !c && (t = t.replace(s, ""));
|
|
30
|
+
break;
|
|
22
31
|
case "keep-legal":
|
|
23
|
-
|
|
32
|
+
c || (t = t.replace(s, ""));
|
|
24
33
|
break;
|
|
25
|
-
case "none":
|
|
26
34
|
default:
|
|
27
|
-
t = t.replace(
|
|
35
|
+
t = t.replace(s, "");
|
|
28
36
|
}
|
|
37
|
+
}
|
|
29
38
|
return { code: t, map: null };
|
|
30
39
|
}
|
|
31
40
|
};
|
|
32
41
|
};
|
|
33
42
|
export {
|
|
34
|
-
|
|
43
|
+
f as default
|
|
35
44
|
};
|
|
36
45
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../src/index.ts"],"sourcesContent":["import { type Plugin } from \"vite\";\n\nexport type StripCommentsPlugin = Plugin<StripCommentsConfig> & {\n name: string;\n enforce: \"pre\" | \"post\" | undefined;\n apply: \"build\";\n transform: (\n code: string,\n id?: string,\n ) => {\n code: string;\n map: string | null;\n };\n};\n\nexport type StripCommentsConfig = {\n type: \"none\" | \"keep-legal\";\n enforce: \"pre\" | \"post\" | undefined;\n};\n\nconst StripCommentsDefaultConfig: StripCommentsConfig = {\n type: \"keep-legal\",\n enforce: \"pre\",\n};\n\nconst stripComments = (cfg: Partial<StripCommentsConfig> = {}) => {\n const config: Partial<StripCommentsConfig> = {\n type
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../src/index.ts"],"sourcesContent":["import { type Plugin } from \"vite\";\n\nexport type StripCommentsPlugin = Plugin<StripCommentsConfig> & {\n name: string;\n enforce: \"pre\" | \"post\" | undefined;\n apply: \"build\";\n transform: (\n code: string,\n id?: string,\n ) => {\n code: string;\n map: string | null;\n };\n};\n\nexport type StripCommentsConfig = {\n type: \"none\" | \"keep-legal\" | \"keep-jsdoc\";\n enforce: \"pre\" | \"post\" | undefined;\n};\n\nconst StripCommentsDefaultConfig: StripCommentsConfig = {\n type: \"keep-legal\",\n enforce: \"pre\",\n};\n\nconst stripComments = (cfg: Partial<StripCommentsConfig> = {}) => {\n const config: Partial<StripCommentsConfig> = {\n type: [\"none\", \"keep-legal\", \"keep-jsdoc\"].some((x) => x === cfg.type)\n ? cfg.type\n : StripCommentsDefaultConfig.type,\n enforce: [\"pre\", \"post\"].some((x) => x === cfg.enforce)\n ? cfg.enforce\n : StripCommentsDefaultConfig.enforce,\n };\n\n return {\n name: \"vite-plugin-strip-comments\",\n enforce: config.enforce,\n apply: \"build\",\n transform(code: string, id?: string): { code: string; map: null } {\n /* istanbul ignore if @preserve */\n if (!id || id.includes(\"node_modules\") || !/\\.([jt]sx?)$/.test(id)) {\n return { code, map: null };\n }\n let result = code;\n let match: string;\n\n const matchesArray = Array.from(\n code.matchAll(\n /\\/\\*[\\s\\S]*?\\*\\/|\\/\\*\\*.*?\\*\\/|(?<!https?:)\\/\\/.*(?=\\n)?/gm,\n ),\n );\n\n for (let i = 0; i < matchesArray.length; i += 1) {\n // first match\n [match] = matchesArray[i];\n const isJSDoc = match.startsWith(\"/**\");\n const isLegal = [\"@legal\", \"@license\", \"@copyright\"].some((x) =>\n match.includes(x)\n );\n // console.log({ isJSDoc, isLegal, match });\n\n switch (config.type) {\n case \"keep-jsdoc\":\n if (!isJSDoc && !isLegal) {\n result = result.replace(match, \"\");\n }\n break;\n case \"keep-legal\":\n if (!isLegal) {\n result = result.replace(match, \"\");\n }\n break;\n case \"none\":\n default:\n result = result.replace(match, \"\");\n }\n }\n\n return { code: result, map: null };\n },\n } satisfies StripCommentsPlugin;\n};\n\nexport default stripComments;\n"],"names":["StripCommentsDefaultConfig","stripComments","cfg","config","x","code","id","result","match","matchesArray","i","isJSDoc","isLegal"],"mappings":"AAoBA,MAAMA,IAAkD;AAAA,EACtD,MAAM;AAAA,EACN,SAAS;AACX,GAEMC,IAAgB,CAACC,IAAoC,OAAO;AAChE,QAAMC,IAAuC;AAAA,IAC3C,MAAM,CAAC,QAAQ,cAAc,YAAY,EAAE,KAAK,CAACC,MAAMA,MAAMF,EAAI,IAAI,IACjEA,EAAI,OACJF,EAA2B;AAAA,IAC/B,SAAS,CAAC,OAAO,MAAM,EAAE,KAAK,CAACI,MAAMA,MAAMF,EAAI,OAAO,IAClDA,EAAI,UACJF,EAA2B;AAAA,EAAA;AAGjC,SAAO;AAAA,IACL,MAAM;AAAA,IACN,SAASG,EAAO;AAAA,IAChB,OAAO;AAAA,IACP,UAAUE,GAAcC,GAA0C;AAEhE,UAAI,CAACA,KAAMA,EAAG,SAAS,cAAc,KAAK,CAAC,eAAe,KAAKA,CAAE;AAC/D,eAAO,EAAE,MAAAD,GAAM,KAAK,KAAA;AAEtB,UAAIE,IAASF,GACTG;AAEJ,YAAMC,IAAe,MAAM;AAAA,QACzBJ,EAAK;AAAA,UACH;AAAA,QAAA;AAAA,MACF;AAGF,eAASK,IAAI,GAAGA,IAAID,EAAa,QAAQC,KAAK,GAAG;AAE/C,SAACF,CAAK,IAAIC,EAAaC,CAAC;AACxB,cAAMC,IAAUH,EAAM,WAAW,KAAK,GAChCI,IAAU,CAAC,UAAU,YAAY,YAAY,EAAE;AAAA,UAAK,CAACR,MACzDI,EAAM,SAASJ,CAAC;AAAA,QAAA;AAIlB,gBAAQD,EAAO,MAAA;AAAA,UACb,KAAK;AACH,YAAI,CAACQ,KAAW,CAACC,MACfL,IAASA,EAAO,QAAQC,GAAO,EAAE;AAEnC;AAAA,UACF,KAAK;AACH,YAAKI,MACHL,IAASA,EAAO,QAAQC,GAAO,EAAE;AAEnC;AAAA,UAEF;AACE,YAAAD,IAASA,EAAO,QAAQC,GAAO,EAAE;AAAA,QAAA;AAAA,MAEvC;AAEA,aAAO,EAAE,MAAMD,GAAQ,KAAK,KAAA;AAAA,IAC9B;AAAA,EAAA;AAEJ;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-strip-comments",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
|
+
"author": "thednp",
|
|
5
|
+
"license": "MIT",
|
|
4
6
|
"description": "🗃️ Vite plugin for stripping comments in production builds",
|
|
5
7
|
"main": "dist/index.mjs",
|
|
6
8
|
"module": "./dist/index.mjs",
|
|
@@ -18,22 +20,24 @@
|
|
|
18
20
|
},
|
|
19
21
|
"keywords": [
|
|
20
22
|
"vite",
|
|
23
|
+
"rollup",
|
|
24
|
+
"rolldown",
|
|
25
|
+
"tsup",
|
|
26
|
+
"tsdown",
|
|
21
27
|
"strip",
|
|
22
28
|
"comments"
|
|
23
29
|
],
|
|
24
|
-
"author": "thednp",
|
|
25
|
-
"license": "MIT",
|
|
26
30
|
"bugs": {
|
|
27
31
|
"url": "https://github.com/thednp/vite-plugin-strip-comments/issues"
|
|
28
32
|
},
|
|
29
33
|
"homepage": "https://github.com/thednp/vite-plugin-strip-comments#readme",
|
|
30
34
|
"devDependencies": {
|
|
31
|
-
"@types/node": "^
|
|
32
|
-
"@vitest/coverage-istanbul": "^
|
|
33
|
-
"typescript": "^5.
|
|
34
|
-
"vite": "^
|
|
35
|
+
"@types/node": "^25.0.10",
|
|
36
|
+
"@vitest/coverage-istanbul": "^4.0.18",
|
|
37
|
+
"typescript": "^5.9.3",
|
|
38
|
+
"vite": "^7.3.1",
|
|
35
39
|
"vite-plugin-dts": "^4.5.4",
|
|
36
|
-
"vitest": "^
|
|
40
|
+
"vitest": "^4.0.18"
|
|
37
41
|
},
|
|
38
42
|
"engines": {
|
|
39
43
|
"node": ">=20",
|
package/tsconfig.json
CHANGED
|
@@ -1,36 +1,35 @@
|
|
|
1
|
-
{
|
|
2
|
-
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"lib": ["DOM", "ESNext", "DOM.Iterable"],
|
|
5
|
-
// "types": ["vite", "vite/client"],
|
|
6
|
-
"rootDir": "./",
|
|
7
|
-
"baseUrl": "./",
|
|
8
|
-
"module": "ESNext",
|
|
9
|
-
"target": "ESNext",
|
|
10
|
-
"moduleResolution": "Bundler",
|
|
11
|
-
"allowJs": true,
|
|
12
|
-
"forceConsistentCasingInFileNames": true,
|
|
13
|
-
"resolvePackageJsonImports": true,
|
|
14
|
-
"useDefineForClassFields": true,
|
|
15
|
-
"strict": true,
|
|
16
|
-
"sourceMap": true,
|
|
17
|
-
"resolveJsonModule": true,
|
|
18
|
-
"esModuleInterop": true,
|
|
19
|
-
"isolatedModules": true,
|
|
20
|
-
"noUnusedLocals": true,
|
|
21
|
-
"noUnusedParameters": true,
|
|
22
|
-
"noImplicitReturns": true,
|
|
23
|
-
"removeComments": false,
|
|
24
|
-
"allowSyntheticDefaultImports": true,
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
"
|
|
35
|
-
|
|
36
|
-
}
|
|
1
|
+
{
|
|
2
|
+
// https://janessagarrow.com/blog/typescript-and-esbuild/
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"lib": ["DOM", "ESNext", "DOM.Iterable"],
|
|
5
|
+
// "types": ["vite", "vite/client"],
|
|
6
|
+
"rootDir": "./",
|
|
7
|
+
"baseUrl": "./",
|
|
8
|
+
"module": "ESNext",
|
|
9
|
+
"target": "ESNext",
|
|
10
|
+
"moduleResolution": "Bundler",
|
|
11
|
+
"allowJs": true,
|
|
12
|
+
"forceConsistentCasingInFileNames": true,
|
|
13
|
+
"resolvePackageJsonImports": true,
|
|
14
|
+
"useDefineForClassFields": true,
|
|
15
|
+
"strict": true,
|
|
16
|
+
"sourceMap": true,
|
|
17
|
+
"resolveJsonModule": true,
|
|
18
|
+
"esModuleInterop": true,
|
|
19
|
+
"isolatedModules": true,
|
|
20
|
+
"noUnusedLocals": true,
|
|
21
|
+
"noUnusedParameters": true,
|
|
22
|
+
"noImplicitReturns": true,
|
|
23
|
+
"removeComments": false,
|
|
24
|
+
"allowSyntheticDefaultImports": true,
|
|
25
|
+
"allowImportingTsExtensions": true,
|
|
26
|
+
"noEmit": true,
|
|
27
|
+
"checkJs": true,
|
|
28
|
+
"skipLibCheck": true, // allows dts-bundle-generator to import from package.json
|
|
29
|
+
"paths": {
|
|
30
|
+
"~/*": ["./src/*"],
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
"include": ["src/*"],
|
|
34
|
+
"exclude": ["node_modules", "experiments", "coverage", "dist"],
|
|
35
|
+
}
|
package/vite.config.ts
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
import { resolve } from
|
|
2
|
-
import { defineConfig } from
|
|
1
|
+
import { resolve } from "node:path";
|
|
2
|
+
import { defineConfig } from "vite";
|
|
3
3
|
import dts from "vite-plugin-dts";
|
|
4
|
-
import strip from
|
|
4
|
+
import strip from "./src/index";
|
|
5
5
|
|
|
6
|
-
const NAME =
|
|
6
|
+
const NAME = "VitePluginStripComments";
|
|
7
7
|
|
|
8
8
|
const fileName = {
|
|
9
9
|
es: `index.mjs`,
|
|
10
10
|
cjs: `index.cjs`,
|
|
11
|
-
};
|
|
11
|
+
} as const;
|
|
12
12
|
|
|
13
13
|
export default defineConfig({
|
|
14
|
-
base:
|
|
14
|
+
base: "./",
|
|
15
15
|
esbuild: {
|
|
16
|
-
legalComments:
|
|
16
|
+
legalComments: "none",
|
|
17
17
|
},
|
|
18
18
|
plugins: [
|
|
19
19
|
dts({
|
|
20
|
-
outDir:
|
|
20
|
+
outDir: "dist",
|
|
21
21
|
copyDtsFiles: true,
|
|
22
22
|
rollupTypes: true,
|
|
23
23
|
}),
|
|
24
24
|
strip(),
|
|
25
25
|
],
|
|
26
26
|
build: {
|
|
27
|
-
minify:
|
|
27
|
+
minify: "esbuild",
|
|
28
28
|
emptyOutDir: true,
|
|
29
|
-
outDir:
|
|
30
|
-
target:
|
|
29
|
+
outDir: "dist",
|
|
30
|
+
target: "ESNext",
|
|
31
31
|
lib: {
|
|
32
|
-
entry: resolve(__dirname,
|
|
32
|
+
entry: resolve(__dirname, "src/index.ts"),
|
|
33
33
|
name: NAME,
|
|
34
|
-
formats: [
|
|
35
|
-
fileName: (format) => fileName[format],
|
|
34
|
+
formats: ["es", "cjs"],
|
|
35
|
+
fileName: (format) => fileName[format as "es" | "cjs"],
|
|
36
36
|
},
|
|
37
37
|
sourcemap: true,
|
|
38
38
|
},
|