rollup-plugin-keywords 0.0.23

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 cueaz
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # rollup-plugin-keywords
2
+
3
+ Refer to the [`vite-plugin-keywords`'s `README`](https://github.com/cueaz/vite-plugin-keywords#readme) for more information.
package/dist/cli.js ADDED
@@ -0,0 +1,17 @@
1
+ // src/cli.ts
2
+ import {
3
+ collectKeywordsAndGenerateTypes,
4
+ createPrefixedLogger
5
+ } from "minifiable-keywords";
6
+
7
+ // src/shared.ts
8
+ var PLUGIN_NAME = "rollup-plugin-keywords";
9
+
10
+ // src/cli.ts
11
+ var main = async () => {
12
+ const root = process.cwd();
13
+ const logger = createPrefixedLogger(console, PLUGIN_NAME);
14
+ await collectKeywordsAndGenerateTypes(root, logger);
15
+ };
16
+ await main();
17
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/cli.ts","../src/shared.ts"],"sourcesContent":["import {\n collectKeywordsAndGenerateTypes,\n createPrefixedLogger,\n} from 'minifiable-keywords';\nimport { PLUGIN_NAME } from './shared';\n\nconst main = async () => {\n const root = process.cwd();\n const logger = createPrefixedLogger(console, PLUGIN_NAME);\n await collectKeywordsAndGenerateTypes(root, logger);\n};\n\nawait main();\n","export const PLUGIN_NAME = 'rollup-plugin-keywords';\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EACA;AAAA,OACK;;;ACHA,IAAM,cAAc;;;ADM3B,IAAM,OAAO,YAAY;AACvB,QAAM,OAAO,QAAQ,IAAI;AACzB,QAAM,SAAS,qBAAqB,SAAS,WAAW;AACxD,QAAM,gCAAgC,MAAM,MAAM;AACpD;AAEA,MAAM,KAAK;","names":[]}
package/dist/index.cjs ADDED
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ default: () => index_default,
24
+ keywordsPlugin: () => keywordsPlugin
25
+ });
26
+ module.exports = __toCommonJS(index_exports);
27
+ var import_minifiable_keywords = require("minifiable-keywords");
28
+
29
+ // src/shared.ts
30
+ var PLUGIN_NAME = "rollup-plugin-keywords";
31
+
32
+ // src/index.ts
33
+ var keywordsPlugin = () => {
34
+ let collectedKeywords;
35
+ let logger;
36
+ const root = process.cwd();
37
+ const isDev = process.env.NODE_ENV === "development";
38
+ return {
39
+ name: PLUGIN_NAME,
40
+ async buildStart() {
41
+ const pluginThis = this;
42
+ logger = (0, import_minifiable_keywords.createPrefixedLogger)(
43
+ {
44
+ info: pluginThis.info,
45
+ warn: pluginThis.warn,
46
+ error: pluginThis.error
47
+ },
48
+ PLUGIN_NAME,
49
+ false
50
+ );
51
+ collectedKeywords = await (0, import_minifiable_keywords.collectKeywordsAndGenerateTypes)(root, logger);
52
+ },
53
+ resolveId(source, importer) {
54
+ if (!importer) {
55
+ return;
56
+ }
57
+ const [validSource] = (0, import_minifiable_keywords.splitQuery)(source);
58
+ if (validSource === import_minifiable_keywords.VIRTUAL_MODULE_ID) {
59
+ return import_minifiable_keywords.RESOLVED_VIRTUAL_MODULE_ID;
60
+ }
61
+ },
62
+ load(id) {
63
+ const [validId] = (0, import_minifiable_keywords.splitQuery)(id);
64
+ if (validId === import_minifiable_keywords.RESOLVED_VIRTUAL_MODULE_ID) {
65
+ return (0, import_minifiable_keywords.generateModuleCode)(collectedKeywords, isDev);
66
+ }
67
+ }
68
+ };
69
+ };
70
+ var index_default = keywordsPlugin;
71
+ // Annotate the CommonJS export names for ESM import in node:
72
+ 0 && (module.exports = {
73
+ keywordsPlugin
74
+ });
75
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/shared.ts"],"sourcesContent":["import {\n collectKeywordsAndGenerateTypes,\n createPrefixedLogger,\n generateModuleCode,\n RESOLVED_VIRTUAL_MODULE_ID,\n splitQuery,\n VIRTUAL_MODULE_ID,\n type PrefixedLogger,\n} from 'minifiable-keywords';\nimport type { Plugin } from 'rollup';\nimport { PLUGIN_NAME } from './shared';\n\nexport const keywordsPlugin = (): Plugin => {\n let collectedKeywords: Set<string>;\n let logger: PrefixedLogger;\n const root = process.cwd();\n const isDev = process.env.NODE_ENV === 'development';\n\n return {\n name: PLUGIN_NAME,\n\n async buildStart() {\n const pluginThis = this;\n logger = createPrefixedLogger(\n {\n info: pluginThis.info,\n warn: pluginThis.warn,\n error: pluginThis.error,\n },\n PLUGIN_NAME,\n false,\n );\n collectedKeywords = await collectKeywordsAndGenerateTypes(root, logger);\n },\n\n resolveId(source, importer) {\n if (!importer) {\n return;\n }\n const [validSource] = splitQuery(source);\n if (validSource === VIRTUAL_MODULE_ID) {\n return RESOLVED_VIRTUAL_MODULE_ID;\n }\n },\n\n load(id) {\n const [validId] = splitQuery(id);\n if (validId === RESOLVED_VIRTUAL_MODULE_ID) {\n return generateModuleCode(collectedKeywords, isDev);\n }\n },\n };\n};\n\nexport default keywordsPlugin;\n","export const PLUGIN_NAME = 'rollup-plugin-keywords';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iCAQO;;;ACRA,IAAM,cAAc;;;ADYpB,IAAM,iBAAiB,MAAc;AAC1C,MAAI;AACJ,MAAI;AACJ,QAAM,OAAO,QAAQ,IAAI;AACzB,QAAM,QAAQ,QAAQ,IAAI,aAAa;AAEvC,SAAO;AAAA,IACL,MAAM;AAAA,IAEN,MAAM,aAAa;AACjB,YAAM,aAAa;AACnB,mBAAS;AAAA,QACP;AAAA,UACE,MAAM,WAAW;AAAA,UACjB,MAAM,WAAW;AAAA,UACjB,OAAO,WAAW;AAAA,QACpB;AAAA,QACA;AAAA,QACA;AAAA,MACF;AACA,0BAAoB,UAAM,4DAAgC,MAAM,MAAM;AAAA,IACxE;AAAA,IAEA,UAAU,QAAQ,UAAU;AAC1B,UAAI,CAAC,UAAU;AACb;AAAA,MACF;AACA,YAAM,CAAC,WAAW,QAAI,uCAAW,MAAM;AACvC,UAAI,gBAAgB,8CAAmB;AACrC,eAAO;AAAA,MACT;AAAA,IACF;AAAA,IAEA,KAAK,IAAI;AACP,YAAM,CAAC,OAAO,QAAI,uCAAW,EAAE;AAC/B,UAAI,YAAY,uDAA4B;AAC1C,mBAAO,+CAAmB,mBAAmB,KAAK;AAAA,MACpD;AAAA,IACF;AAAA,EACF;AACF;AAEA,IAAO,gBAAQ;","names":[]}
@@ -0,0 +1,5 @@
1
+ import { Plugin } from 'rollup';
2
+
3
+ declare const keywordsPlugin: () => Plugin;
4
+
5
+ export { keywordsPlugin as default, keywordsPlugin };
@@ -0,0 +1,5 @@
1
+ import { Plugin } from 'rollup';
2
+
3
+ declare const keywordsPlugin: () => Plugin;
4
+
5
+ export { keywordsPlugin as default, keywordsPlugin };
package/dist/index.js ADDED
@@ -0,0 +1,57 @@
1
+ // src/index.ts
2
+ import {
3
+ collectKeywordsAndGenerateTypes,
4
+ createPrefixedLogger,
5
+ generateModuleCode,
6
+ RESOLVED_VIRTUAL_MODULE_ID,
7
+ splitQuery,
8
+ VIRTUAL_MODULE_ID
9
+ } from "minifiable-keywords";
10
+
11
+ // src/shared.ts
12
+ var PLUGIN_NAME = "rollup-plugin-keywords";
13
+
14
+ // src/index.ts
15
+ var keywordsPlugin = () => {
16
+ let collectedKeywords;
17
+ let logger;
18
+ const root = process.cwd();
19
+ const isDev = process.env.NODE_ENV === "development";
20
+ return {
21
+ name: PLUGIN_NAME,
22
+ async buildStart() {
23
+ const pluginThis = this;
24
+ logger = createPrefixedLogger(
25
+ {
26
+ info: pluginThis.info,
27
+ warn: pluginThis.warn,
28
+ error: pluginThis.error
29
+ },
30
+ PLUGIN_NAME,
31
+ false
32
+ );
33
+ collectedKeywords = await collectKeywordsAndGenerateTypes(root, logger);
34
+ },
35
+ resolveId(source, importer) {
36
+ if (!importer) {
37
+ return;
38
+ }
39
+ const [validSource] = splitQuery(source);
40
+ if (validSource === VIRTUAL_MODULE_ID) {
41
+ return RESOLVED_VIRTUAL_MODULE_ID;
42
+ }
43
+ },
44
+ load(id) {
45
+ const [validId] = splitQuery(id);
46
+ if (validId === RESOLVED_VIRTUAL_MODULE_ID) {
47
+ return generateModuleCode(collectedKeywords, isDev);
48
+ }
49
+ }
50
+ };
51
+ };
52
+ var index_default = keywordsPlugin;
53
+ export {
54
+ index_default as default,
55
+ keywordsPlugin
56
+ };
57
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/shared.ts"],"sourcesContent":["import {\n collectKeywordsAndGenerateTypes,\n createPrefixedLogger,\n generateModuleCode,\n RESOLVED_VIRTUAL_MODULE_ID,\n splitQuery,\n VIRTUAL_MODULE_ID,\n type PrefixedLogger,\n} from 'minifiable-keywords';\nimport type { Plugin } from 'rollup';\nimport { PLUGIN_NAME } from './shared';\n\nexport const keywordsPlugin = (): Plugin => {\n let collectedKeywords: Set<string>;\n let logger: PrefixedLogger;\n const root = process.cwd();\n const isDev = process.env.NODE_ENV === 'development';\n\n return {\n name: PLUGIN_NAME,\n\n async buildStart() {\n const pluginThis = this;\n logger = createPrefixedLogger(\n {\n info: pluginThis.info,\n warn: pluginThis.warn,\n error: pluginThis.error,\n },\n PLUGIN_NAME,\n false,\n );\n collectedKeywords = await collectKeywordsAndGenerateTypes(root, logger);\n },\n\n resolveId(source, importer) {\n if (!importer) {\n return;\n }\n const [validSource] = splitQuery(source);\n if (validSource === VIRTUAL_MODULE_ID) {\n return RESOLVED_VIRTUAL_MODULE_ID;\n }\n },\n\n load(id) {\n const [validId] = splitQuery(id);\n if (validId === RESOLVED_VIRTUAL_MODULE_ID) {\n return generateModuleCode(collectedKeywords, isDev);\n }\n },\n };\n};\n\nexport default keywordsPlugin;\n","export const PLUGIN_NAME = 'rollup-plugin-keywords';\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;;;ACRA,IAAM,cAAc;;;ADYpB,IAAM,iBAAiB,MAAc;AAC1C,MAAI;AACJ,MAAI;AACJ,QAAM,OAAO,QAAQ,IAAI;AACzB,QAAM,QAAQ,QAAQ,IAAI,aAAa;AAEvC,SAAO;AAAA,IACL,MAAM;AAAA,IAEN,MAAM,aAAa;AACjB,YAAM,aAAa;AACnB,eAAS;AAAA,QACP;AAAA,UACE,MAAM,WAAW;AAAA,UACjB,MAAM,WAAW;AAAA,UACjB,OAAO,WAAW;AAAA,QACpB;AAAA,QACA;AAAA,QACA;AAAA,MACF;AACA,0BAAoB,MAAM,gCAAgC,MAAM,MAAM;AAAA,IACxE;AAAA,IAEA,UAAU,QAAQ,UAAU;AAC1B,UAAI,CAAC,UAAU;AACb;AAAA,MACF;AACA,YAAM,CAAC,WAAW,IAAI,WAAW,MAAM;AACvC,UAAI,gBAAgB,mBAAmB;AACrC,eAAO;AAAA,MACT;AAAA,IACF;AAAA,IAEA,KAAK,IAAI;AACP,YAAM,CAAC,OAAO,IAAI,WAAW,EAAE;AAC/B,UAAI,YAAY,4BAA4B;AAC1C,eAAO,mBAAmB,mBAAmB,KAAK;AAAA,MACpD;AAAA,IACF;AAAA,EACF;AACF;AAEA,IAAO,gBAAQ;","names":[]}
package/package.json ADDED
@@ -0,0 +1,55 @@
1
+ {
2
+ "name": "rollup-plugin-keywords",
3
+ "version": "0.0.23",
4
+ "description": "A Rollup plugin that provides minifiable Symbols (keywords) to use in place of string literals for aggressive minification.",
5
+ "keywords": [
6
+ "rollup",
7
+ "rollup-plugin",
8
+ "minification"
9
+ ],
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/cueaz/vite-plugin-keywords.git"
13
+ },
14
+ "license": "MIT",
15
+ "author": "cueaz",
16
+ "type": "module",
17
+ "exports": {
18
+ ".": {
19
+ "import": {
20
+ "types": "./dist/index.d.ts",
21
+ "default": "./dist/index.js"
22
+ },
23
+ "require": {
24
+ "types": "./dist/index.d.cts",
25
+ "default": "./dist/index.cjs"
26
+ }
27
+ },
28
+ "./package.json": "./package.json"
29
+ },
30
+ "main": "./dist/index.js",
31
+ "types": "./dist/index.d.ts",
32
+ "bin": {
33
+ "keywords": "dist/cli.js"
34
+ },
35
+ "files": [
36
+ "dist"
37
+ ],
38
+ "dependencies": {
39
+ "minifiable-keywords": "0.0.23"
40
+ },
41
+ "devDependencies": {
42
+ "@types/node": "^24.1.0",
43
+ "rimraf": "^6.0.1",
44
+ "tsup": "^8.5.0",
45
+ "vitest": "^3.2.4"
46
+ },
47
+ "peerDependencies": {
48
+ "rollup": "^3.0.0 || ^4.0.0"
49
+ },
50
+ "scripts": {
51
+ "build": "tsup",
52
+ "clean": "rimraf dist",
53
+ "test": "vitest"
54
+ }
55
+ }