properties-file 3.7.0 → 4.0.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/README.md +5 -34
- package/dist/cjs/bundler/bun.d.ts +10 -0
- package/dist/cjs/bundler/bun.js +1 -0
- package/dist/cjs/bundler/esbuild.d.ts +11 -0
- package/dist/cjs/bundler/esbuild.js +1 -0
- package/dist/cjs/bundler/rollup.d.ts +11 -0
- package/dist/cjs/bundler/rollup.js +1 -0
- package/dist/cjs/bundler/webpack.d.ts +12 -0
- package/dist/esm/bundler/bun.d.ts +10 -0
- package/dist/esm/bundler/bun.js +1 -0
- package/dist/esm/bundler/esbuild.d.ts +11 -0
- package/dist/esm/bundler/esbuild.js +1 -0
- package/dist/esm/bundler/rollup.d.ts +11 -0
- package/dist/esm/bundler/rollup.js +1 -0
- package/dist/esm/bundler/webpack.d.ts +12 -0
- package/package.json +57 -18
- package/dist/cjs/loader/webpack.d.ts +0 -12
- package/dist/esm/loader/webpack.d.ts +0 -12
- /package/dist/cjs/{loader → bundler}/webpack.js +0 -0
- /package/dist/esm/{loader → bundler}/webpack.js +0 -0
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
[](https://bundlejs.com/?q=properties-file@latest&treeshake=[*])
|
|
7
7
|

|
|
8
8
|
|
|
9
|
-
`.properties` file parser, editor, formatter and
|
|
9
|
+
`.properties` file parser, editor, formatter and bundler integrations.
|
|
10
10
|
|
|
11
11
|
## Installation 💻
|
|
12
12
|
|
|
@@ -27,7 +27,7 @@ npm install properties-file
|
|
|
27
27
|
- A `Properties` class provides insights into parsing data.
|
|
28
28
|
- A `PropertiesEditor` class enables the addition, edition, and removal of entries.
|
|
29
29
|
- `escapeKey` and `escapeValue` allow the conversion of any content to a `.properties` compatible format.
|
|
30
|
-
-
|
|
30
|
+
- Bundler integrations for Webpack, Rollup/Vite, esbuild, and Bun to import `.properties` files directly. See [BUNDLER.md](./BUNDLER.md).
|
|
31
31
|
- [Tiny](https://bundlejs.com/?q=properties-file%40latest&treeshake=%5B*%5D) with 0 dependencies.
|
|
32
32
|
- 100% test coverage based on the output from a Java implementation.
|
|
33
33
|
- Active maintenance (many popular `.properties` packages have been inactive for years).
|
|
@@ -189,40 +189,11 @@ console.log(properties.format())
|
|
|
189
189
|
|
|
190
190
|
For convenience, we also added an `upsert` method that allows updating a key if it exists or adding it at the end, when it doesn't. Make sure to check in your IDE for all available methods and options in our TSDoc.
|
|
191
191
|
|
|
192
|
-
###
|
|
192
|
+
### Bundler Integrations
|
|
193
193
|
|
|
194
|
-
If you would like to import `.properties` directly using `import`, this package
|
|
194
|
+
If you would like to import `.properties` directly using `import`, this package provides integrations for all major bundlers: **Webpack/Rspack**, **Rollup/Vite/Rolldown**, **esbuild**, and **Bun**.
|
|
195
195
|
|
|
196
|
-
|
|
197
|
-
// webpack.config.js
|
|
198
|
-
module.exports = {
|
|
199
|
-
module: {
|
|
200
|
-
rules: [
|
|
201
|
-
{
|
|
202
|
-
test: /\.properties$/i,
|
|
203
|
-
use: [
|
|
204
|
-
{
|
|
205
|
-
loader: 'properties-file/webpack-loader',
|
|
206
|
-
},
|
|
207
|
-
],
|
|
208
|
-
},
|
|
209
|
-
],
|
|
210
|
-
},
|
|
211
|
-
}
|
|
212
|
-
```
|
|
213
|
-
|
|
214
|
-
As soon as you configure Webpack, the `.properties` type should be available in your IDE when using `import`. If you ever need to add it manually, you can add a `*.properties` type declaration file at the root of your application, like this:
|
|
215
|
-
|
|
216
|
-
```ts
|
|
217
|
-
declare module '*.properties' {
|
|
218
|
-
/** A key/value object representing the content of a `.properties` file. */
|
|
219
|
-
const properties: {
|
|
220
|
-
/** The value of a `.properties` file key. */
|
|
221
|
-
[key: string]: string
|
|
222
|
-
}
|
|
223
|
-
export { properties }
|
|
224
|
-
}
|
|
225
|
-
```
|
|
196
|
+
See [BUNDLER.md](./BUNDLER.md) for setup instructions and examples.
|
|
226
197
|
|
|
227
198
|
By adding these configurations you should now be able to import directly `.properties` files just like this:
|
|
228
199
|
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { BunPlugin } from 'bun';
|
|
2
|
+
/**
|
|
3
|
+
* Bun plugin for `.properties` files. Works with both `Bun.plugin` (runtime) and `Bun.build`
|
|
4
|
+
* (build-time).
|
|
5
|
+
*/
|
|
6
|
+
declare const bunPlugin: BunPlugin;
|
|
7
|
+
export default bunPlugin;
|
|
8
|
+
|
|
9
|
+
// Enables type recognition for direct `.properties` file imports.
|
|
10
|
+
import '../properties-file.d.ts'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var node_fs_1=require("node:fs"),__1=require(".."),bunPlugin={name:"properties-file",setup:function(e){e.onLoad({filter:/\.properties$/},function(e){var r=e.path;return{exports:{properties:(0,__1.getProperties)((0,node_fs_1.readFileSync)(r,"utf8"))},loader:"object"}})}};exports.default=bunPlugin;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Plugin } from 'esbuild';
|
|
2
|
+
/**
|
|
3
|
+
* esbuild plugin for `.properties` files.
|
|
4
|
+
*
|
|
5
|
+
* @returns An esbuild plugin that transforms `.properties` imports into JavaScript modules.
|
|
6
|
+
*/
|
|
7
|
+
declare const esbuildPlugin: () => Plugin;
|
|
8
|
+
export default esbuildPlugin;
|
|
9
|
+
|
|
10
|
+
// Enables type recognition for direct `.properties` file imports.
|
|
11
|
+
import '../properties-file.d.ts'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var node_fs_1=require("node:fs"),__1=require(".."),esbuildPlugin=function(){return{name:"properties-file",setup:function(e){e.onLoad({filter:/\.properties$/},function(e){var r=e.path;return{contents:"export const properties = ".concat(JSON.stringify((0,__1.getProperties)((0,node_fs_1.readFileSync)(r,"utf8"))),";"),loader:"js"}})}}};exports.default=esbuildPlugin;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Plugin } from 'rollup';
|
|
2
|
+
/**
|
|
3
|
+
* Rollup plugin for `.properties` files. Also compatible with Vite and Rolldown.
|
|
4
|
+
*
|
|
5
|
+
* @returns A Rollup plugin that transforms `.properties` imports into JavaScript modules.
|
|
6
|
+
*/
|
|
7
|
+
declare const rollupPlugin: () => Plugin;
|
|
8
|
+
export default rollupPlugin;
|
|
9
|
+
|
|
10
|
+
// Enables type recognition for direct `.properties` file imports.
|
|
11
|
+
import '../properties-file.d.ts'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var __1=require(".."),PROPERTIES_EXTENSION=".properties",rollupPlugin=function(){return{name:"properties-file",transform:function(e,r){return-1===r.indexOf(PROPERTIES_EXTENSION,r.length-PROPERTIES_EXTENSION.length)?null:{code:"export const properties = ".concat(JSON.stringify((0,__1.getProperties)(e)),";"),map:null}}}};exports.default=rollupPlugin;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Webpack file loader for `.properties` files. Also compatible with Rspack.
|
|
3
|
+
*
|
|
4
|
+
* @param content - The content of a `.properties` file.
|
|
5
|
+
*
|
|
6
|
+
* @returns A CommonJS module string exporting the parsed key-value pairs.
|
|
7
|
+
*/
|
|
8
|
+
declare const webpackLoader: (content: string) => string;
|
|
9
|
+
export default webpackLoader;
|
|
10
|
+
|
|
11
|
+
// Enables type recognition for direct `.properties` file imports.
|
|
12
|
+
import '../properties-file.d.ts'
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { BunPlugin } from 'bun';
|
|
2
|
+
/**
|
|
3
|
+
* Bun plugin for `.properties` files. Works with both `Bun.plugin` (runtime) and `Bun.build`
|
|
4
|
+
* (build-time).
|
|
5
|
+
*/
|
|
6
|
+
declare const bunPlugin: BunPlugin;
|
|
7
|
+
export default bunPlugin;
|
|
8
|
+
|
|
9
|
+
// Enables type recognition for direct `.properties` file imports.
|
|
10
|
+
import '../properties-file.d.ts'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{readFileSync}from"node:fs";import{getProperties}from"../index.js";var bunPlugin={name:"properties-file",setup:function(e){e.onLoad({filter:/\.properties$/},function(e){var r=e.path;return{exports:{properties:getProperties(readFileSync(r,"utf8"))},loader:"object"}})}};export default bunPlugin;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Plugin } from 'esbuild';
|
|
2
|
+
/**
|
|
3
|
+
* esbuild plugin for `.properties` files.
|
|
4
|
+
*
|
|
5
|
+
* @returns An esbuild plugin that transforms `.properties` imports into JavaScript modules.
|
|
6
|
+
*/
|
|
7
|
+
declare const esbuildPlugin: () => Plugin;
|
|
8
|
+
export default esbuildPlugin;
|
|
9
|
+
|
|
10
|
+
// Enables type recognition for direct `.properties` file imports.
|
|
11
|
+
import '../properties-file.d.ts'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{readFileSync}from"node:fs";import{getProperties}from"../index.js";var esbuildPlugin=function(){return{name:"properties-file",setup:function(e){e.onLoad({filter:/\.properties$/},function(e){var r=e.path;return{contents:"export const properties = ".concat(JSON.stringify(getProperties(readFileSync(r,"utf8"))),";"),loader:"js"}})}}};export default esbuildPlugin;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Plugin } from 'rollup';
|
|
2
|
+
/**
|
|
3
|
+
* Rollup plugin for `.properties` files. Also compatible with Vite and Rolldown.
|
|
4
|
+
*
|
|
5
|
+
* @returns A Rollup plugin that transforms `.properties` imports into JavaScript modules.
|
|
6
|
+
*/
|
|
7
|
+
declare const rollupPlugin: () => Plugin;
|
|
8
|
+
export default rollupPlugin;
|
|
9
|
+
|
|
10
|
+
// Enables type recognition for direct `.properties` file imports.
|
|
11
|
+
import '../properties-file.d.ts'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{getProperties}from"../index.js";var PROPERTIES_EXTENSION=".properties",rollupPlugin=function(){return{name:"properties-file",transform:function(e,r){return-1===r.indexOf(PROPERTIES_EXTENSION,r.length-PROPERTIES_EXTENSION.length)?null:{code:"export const properties = ".concat(JSON.stringify(getProperties(e)),";"),map:null}}}};export default rollupPlugin;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Webpack file loader for `.properties` files. Also compatible with Rspack.
|
|
3
|
+
*
|
|
4
|
+
* @param content - The content of a `.properties` file.
|
|
5
|
+
*
|
|
6
|
+
* @returns A CommonJS module string exporting the parsed key-value pairs.
|
|
7
|
+
*/
|
|
8
|
+
declare const webpackLoader: (content: string) => string;
|
|
9
|
+
export default webpackLoader;
|
|
10
|
+
|
|
11
|
+
// Enables type recognition for direct `.properties` file imports.
|
|
12
|
+
import '../properties-file.d.ts'
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "properties-file",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": ".properties file parser, editor, formatter and
|
|
3
|
+
"version": "4.0.0",
|
|
4
|
+
"description": ".properties file parser, editor, formatter and bundler integrations.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
".properties",
|
|
7
7
|
"properties",
|
|
@@ -13,8 +13,11 @@
|
|
|
13
13
|
"Java",
|
|
14
14
|
"intl",
|
|
15
15
|
"i18n",
|
|
16
|
-
"properties Webpack loader",
|
|
17
16
|
"Webpack loader",
|
|
17
|
+
"Rollup plugin",
|
|
18
|
+
"Vite plugin",
|
|
19
|
+
"esbuild plugin",
|
|
20
|
+
"Bun plugin",
|
|
18
21
|
"internationalization"
|
|
19
22
|
],
|
|
20
23
|
"repository": {
|
|
@@ -36,6 +39,46 @@
|
|
|
36
39
|
"default": "./dist/cjs/index.js"
|
|
37
40
|
}
|
|
38
41
|
},
|
|
42
|
+
"./bundler/bun": {
|
|
43
|
+
"import": {
|
|
44
|
+
"types": "./dist/esm/bundler/bun.d.ts",
|
|
45
|
+
"default": "./dist/esm/bundler/bun.js"
|
|
46
|
+
},
|
|
47
|
+
"require": {
|
|
48
|
+
"types": "./dist/cjs/bundler/bun.d.ts",
|
|
49
|
+
"default": "./dist/cjs/bundler/bun.js"
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
"./bundler/esbuild": {
|
|
53
|
+
"import": {
|
|
54
|
+
"types": "./dist/esm/bundler/esbuild.d.ts",
|
|
55
|
+
"default": "./dist/esm/bundler/esbuild.js"
|
|
56
|
+
},
|
|
57
|
+
"require": {
|
|
58
|
+
"types": "./dist/cjs/bundler/esbuild.d.ts",
|
|
59
|
+
"default": "./dist/cjs/bundler/esbuild.js"
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
"./bundler/rollup": {
|
|
63
|
+
"import": {
|
|
64
|
+
"types": "./dist/esm/bundler/rollup.d.ts",
|
|
65
|
+
"default": "./dist/esm/bundler/rollup.js"
|
|
66
|
+
},
|
|
67
|
+
"require": {
|
|
68
|
+
"types": "./dist/cjs/bundler/rollup.d.ts",
|
|
69
|
+
"default": "./dist/cjs/bundler/rollup.js"
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
"./bundler/webpack": {
|
|
73
|
+
"import": {
|
|
74
|
+
"types": "./dist/esm/bundler/webpack.d.ts",
|
|
75
|
+
"default": "./dist/esm/bundler/webpack.js"
|
|
76
|
+
},
|
|
77
|
+
"require": {
|
|
78
|
+
"types": "./dist/cjs/bundler/webpack.d.ts",
|
|
79
|
+
"default": "./dist/cjs/bundler/webpack.js"
|
|
80
|
+
}
|
|
81
|
+
},
|
|
39
82
|
"./editor": {
|
|
40
83
|
"import": {
|
|
41
84
|
"types": "./dist/esm/editor/index.d.ts",
|
|
@@ -65,16 +108,6 @@
|
|
|
65
108
|
"types": "./dist/cjs/unescape/index.d.ts",
|
|
66
109
|
"default": "./dist/cjs/unescape/index.js"
|
|
67
110
|
}
|
|
68
|
-
},
|
|
69
|
-
"./webpack-loader": {
|
|
70
|
-
"import": {
|
|
71
|
-
"types": "./dist/esm/loader/webpack.d.ts",
|
|
72
|
-
"default": "./dist/esm/loader/webpack.js"
|
|
73
|
-
},
|
|
74
|
-
"require": {
|
|
75
|
-
"types": "./dist/cjs/loader/webpack.d.ts",
|
|
76
|
-
"default": "./dist/cjs/loader/webpack.js"
|
|
77
|
-
}
|
|
78
111
|
}
|
|
79
112
|
},
|
|
80
113
|
"main": "dist/cjs/index.js",
|
|
@@ -85,6 +118,8 @@
|
|
|
85
118
|
],
|
|
86
119
|
"scripts": {
|
|
87
120
|
"add-file-type-declaration": "node ./dist/esm/add-import-type.js && find ./dist -name 'add-import-type.*' -type f -delete",
|
|
121
|
+
"benchmark": "npx tsx benchmarks/run.ts",
|
|
122
|
+
"benchmark-compare": "npx tsx benchmarks/compare.ts",
|
|
88
123
|
"build": "npm run check-nvm-node-version && npm run prettier-write && npm run eslint-fix && rm -Rf ./dist && tsc -p tsconfig.cjs.json && tsc -p tsconfig.esm.json && echo '{ \"type\": \"commonjs\" }' > dist/cjs/package.json && tsc -p src/build-scripts/tsconfig.json && node dist/build-scripts/build.js && npm run test",
|
|
89
124
|
"check-nvm-node-version": "check-node-version --node $(node -p \"'>='+require('fs').readFileSync('.nvmrc','utf-8').trim()\")",
|
|
90
125
|
"depcheck": "depcheck",
|
|
@@ -98,15 +133,17 @@
|
|
|
98
133
|
},
|
|
99
134
|
"devDependencies": {
|
|
100
135
|
"@release-it/conventional-changelog": "10.0.6",
|
|
136
|
+
"@types/bun": "1.3.11",
|
|
101
137
|
"@types/jest": "30.0.0",
|
|
102
138
|
"@types/node": "25.5.0",
|
|
103
139
|
"check-node-version": "4.2.1",
|
|
104
140
|
"depcheck": "1.4.7",
|
|
105
141
|
"dotenv-cli": "11.0.0",
|
|
106
|
-
"
|
|
142
|
+
"esbuild": "0.27.4",
|
|
143
|
+
"eslint": "10.1.0",
|
|
107
144
|
"eslint-config-prettier": "10.1.8",
|
|
108
145
|
"eslint-import-resolver-typescript": "4.4.4",
|
|
109
|
-
"eslint-plugin-es-x": "9.
|
|
146
|
+
"eslint-plugin-es-x": "9.6.0",
|
|
110
147
|
"eslint-plugin-import-x": "4.16.2",
|
|
111
148
|
"eslint-plugin-jest": "29.15.0",
|
|
112
149
|
"eslint-plugin-package-json": "0.91.0",
|
|
@@ -118,14 +155,16 @@
|
|
|
118
155
|
"jest": "30.3.0",
|
|
119
156
|
"jiti": "2.6.1",
|
|
120
157
|
"jsonc-eslint-parser": "3.1.0",
|
|
121
|
-
"npm-check-updates": "19.6.
|
|
158
|
+
"npm-check-updates": "19.6.5",
|
|
122
159
|
"prettier": "3.8.1",
|
|
123
160
|
"prettier-plugin-organize-imports": "4.3.0",
|
|
124
161
|
"release-it": "19.2.4",
|
|
125
|
-
"
|
|
162
|
+
"rollup": "4.60.0",
|
|
163
|
+
"terser": "5.46.1",
|
|
164
|
+
"tinybench": "6.0.0",
|
|
126
165
|
"ts-jest": "29.4.6",
|
|
127
166
|
"typescript": "5.9.3",
|
|
128
|
-
"typescript-eslint": "8.57.
|
|
167
|
+
"typescript-eslint": "8.57.1"
|
|
129
168
|
},
|
|
130
169
|
"engines": {
|
|
131
170
|
"node": "*"
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Webpack file loader for `.properties` files.
|
|
3
|
-
*
|
|
4
|
-
* @param content - the content of a `.properties` file.
|
|
5
|
-
*
|
|
6
|
-
* @returns A Webpack file loader string containing the content of a `.properties` file.
|
|
7
|
-
*/
|
|
8
|
-
declare const webpackLoader: (content: string) => string;
|
|
9
|
-
export default webpackLoader;
|
|
10
|
-
|
|
11
|
-
// Enables type recognition for direct `.properties` file imports.
|
|
12
|
-
import '../properties-file.d.ts'
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Webpack file loader for `.properties` files.
|
|
3
|
-
*
|
|
4
|
-
* @param content - the content of a `.properties` file.
|
|
5
|
-
*
|
|
6
|
-
* @returns A Webpack file loader string containing the content of a `.properties` file.
|
|
7
|
-
*/
|
|
8
|
-
declare const webpackLoader: (content: string) => string;
|
|
9
|
-
export default webpackLoader;
|
|
10
|
-
|
|
11
|
-
// Enables type recognition for direct `.properties` file imports.
|
|
12
|
-
import '../properties-file.d.ts'
|
|
File without changes
|
|
File without changes
|