@gjsify/esbuild-plugin-deepkit 0.0.3 → 0.1.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 +37 -39
- package/esbuild.mjs +5 -30
- package/package.json +16 -11
- package/tsconfig.json +17 -11
- package/dist/cjs/index.cjs +0 -1
package/README.md
CHANGED
|
@@ -1,56 +1,54 @@
|
|
|
1
1
|
# @gjsify/esbuild-plugin-deepkit
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
esbuild plugin for Deepkit type compiler integration.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Part of the [gjsify](https://github.com/gjsify/gjsify) project — Node.js and Web APIs for GJS (GNOME JavaScript).
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @gjsify/esbuild-plugin-deepkit
|
|
11
|
+
# or
|
|
12
|
+
yarn add @gjsify/esbuild-plugin-deepkit
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
import { build } from 'esbuild';
|
|
19
|
+
import { deepkitPlugin } from '@gjsify/esbuild-plugin-deepkit';
|
|
20
|
+
|
|
21
|
+
await build({
|
|
22
|
+
entryPoints: ['src/index.ts'],
|
|
23
|
+
bundle: true,
|
|
24
|
+
outfile: 'dist/index.js',
|
|
25
|
+
format: 'esm',
|
|
26
|
+
platform: 'node',
|
|
27
|
+
plugins: [deepkitPlugin()],
|
|
28
|
+
});
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Example
|
|
6
32
|
|
|
7
33
|
src/index.ts:
|
|
8
|
-
```
|
|
34
|
+
```typescript
|
|
9
35
|
import { deserialize } from '@deepkit/type';
|
|
10
36
|
|
|
11
|
-
interface Config {
|
|
12
|
-
color: string;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
37
|
interface User {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
lastName?: string;
|
|
20
|
-
config: Config;
|
|
21
|
-
username: string;
|
|
38
|
+
id: number;
|
|
39
|
+
createdAt: Date;
|
|
40
|
+
username: string;
|
|
22
41
|
}
|
|
23
42
|
|
|
24
|
-
//deserialize JSON object to real instances
|
|
25
43
|
const user = deserialize<User>({
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
config: {color: '#221122'},
|
|
44
|
+
id: 0,
|
|
45
|
+
username: 'peter',
|
|
46
|
+
createdAt: '2021-06-26T12:34:41.061Z',
|
|
30
47
|
});
|
|
31
48
|
|
|
32
|
-
|
|
33
49
|
console.log(user.createdAt instanceof Date); // true
|
|
34
50
|
```
|
|
35
51
|
|
|
36
|
-
|
|
37
|
-
```js
|
|
38
|
-
import { build } from 'esbuild';
|
|
39
|
-
import { deepkitPlugin } from '@gjsify/esbuild-plugin-deepkit';
|
|
52
|
+
## License
|
|
40
53
|
|
|
41
|
-
|
|
42
|
-
entryPoints: ['src/index.ts'],
|
|
43
|
-
bundle: true,
|
|
44
|
-
minify: true,
|
|
45
|
-
outfile: 'dist/index.js',
|
|
46
|
-
format: 'esm',
|
|
47
|
-
platform: "node",
|
|
48
|
-
external: ['@deepkit/type'],
|
|
49
|
-
plugins: [deepkitPlugin()],
|
|
50
|
-
});
|
|
51
|
-
```
|
|
52
|
-
Start:
|
|
53
|
-
```bash
|
|
54
|
-
node dist/index.js
|
|
55
|
-
-> true
|
|
56
|
-
```
|
|
54
|
+
MIT
|
package/esbuild.mjs
CHANGED
|
@@ -1,46 +1,21 @@
|
|
|
1
1
|
import { build } from 'esbuild';
|
|
2
|
-
import { readFile } from 'fs/promises';
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
await readFile(
|
|
6
|
-
new URL('./package.json', import.meta.url)
|
|
7
|
-
)
|
|
8
|
-
);
|
|
9
|
-
|
|
10
|
-
const baseConfig = {
|
|
3
|
+
await build({
|
|
11
4
|
entryPoints: ['src/index.ts'],
|
|
12
5
|
bundle: true,
|
|
13
6
|
minify: true,
|
|
7
|
+
format: 'esm',
|
|
8
|
+
outfile: 'dist/esm/index.mjs',
|
|
14
9
|
external: [
|
|
15
10
|
'fs',
|
|
16
11
|
'fs/promises',
|
|
17
12
|
'util',
|
|
18
13
|
'path',
|
|
19
14
|
'process',
|
|
20
|
-
'util',
|
|
21
15
|
'typescript',
|
|
22
16
|
'@deepkit/type-compiler',
|
|
23
17
|
'esbuild',
|
|
24
|
-
// '@gjsify/resolve-npm', can't be required in cjs builds
|
|
25
18
|
'@gjsify/esbuild-plugin-transform-ext',
|
|
26
|
-
'@gjsify/esbuild-plugin-deno-loader',
|
|
27
19
|
'@gjsify/esbuild-plugin-gjsify',
|
|
28
|
-
]
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
if(pkg.main) {
|
|
32
|
-
build({
|
|
33
|
-
...baseConfig,
|
|
34
|
-
outfile: pkg.main,
|
|
35
|
-
format: 'cjs',
|
|
36
|
-
platform: "node",
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if(pkg.main) {
|
|
41
|
-
build({
|
|
42
|
-
...baseConfig,
|
|
43
|
-
outfile: pkg.module,
|
|
44
|
-
format: 'esm',
|
|
45
|
-
});
|
|
46
|
-
}
|
|
20
|
+
],
|
|
21
|
+
});
|
package/package.json
CHANGED
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gjsify/esbuild-plugin-deepkit",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "Deepkit type compiler plugin for esbuild",
|
|
5
|
-
"type": "
|
|
6
|
-
"main": "dist/
|
|
7
|
-
"module": "dist/esm/index.mjs",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/esm/index.mjs",
|
|
8
7
|
"types": "dist/types/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/types/index.d.ts",
|
|
11
|
+
"default": "./dist/esm/index.mjs"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
9
14
|
"scripts": {
|
|
10
|
-
"clear": "rm -rf dist tsconfig.tsbuildinfo",
|
|
11
|
-
"
|
|
12
|
-
"build": "yarn
|
|
15
|
+
"clear": "rm -rf dist tsconfig.tsbuildinfo || exit 0",
|
|
16
|
+
"check": "tsc --noEmit",
|
|
17
|
+
"build": "yarn build:js && yarn build:types",
|
|
13
18
|
"build:js": "node esbuild.mjs",
|
|
14
19
|
"build:types": "yarn tsc --emitDeclarationOnly"
|
|
15
20
|
},
|
|
@@ -27,11 +32,11 @@
|
|
|
27
32
|
"fs"
|
|
28
33
|
],
|
|
29
34
|
"dependencies": {
|
|
30
|
-
"@deepkit/type-compiler": "^1.0.
|
|
35
|
+
"@deepkit/type-compiler": "^1.0.19",
|
|
36
|
+
"typescript": "^6.0.2"
|
|
31
37
|
},
|
|
32
38
|
"devDependencies": {
|
|
33
|
-
"@types/node": "^
|
|
34
|
-
"esbuild": "^0.
|
|
35
|
-
"typescript": "^5.1.3"
|
|
39
|
+
"@types/node": "^25.5.0",
|
|
40
|
+
"esbuild": "^0.27.4"
|
|
36
41
|
}
|
|
37
42
|
}
|
package/tsconfig.json
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"rootDir": "src",
|
|
4
|
+
"outDir": "dist",
|
|
5
|
+
"declarationDir": "dist/types",
|
|
6
|
+
"declaration": true,
|
|
7
|
+
"target": "ESNext",
|
|
8
|
+
"module": "ESNext",
|
|
9
|
+
"types": [
|
|
10
|
+
"node"
|
|
11
|
+
],
|
|
12
|
+
"moduleResolution": "bundler",
|
|
13
|
+
"strict": false
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"src/index.ts"
|
|
17
|
+
]
|
|
18
|
+
}
|
package/dist/cjs/index.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var g=Object.create;var i=Object.defineProperty;var D=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var L=Object.getPrototypeOf,y=Object.prototype.hasOwnProperty;var h=(t,e)=>{for(var n in e)i(t,n,{get:e[n],enumerable:!0})},a=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of O(e))!y.call(t,o)&&o!==n&&i(t,o,{get:()=>e[o],enumerable:!(r=D(e,o))||r.enumerable});return t};var k=(t,e,n)=>(n=t!=null?g(L(t)):{},a(e||!t||!t.__esModule?i(n,"default",{value:t,enumerable:!0}):n,t)),P=t=>a(i({},"__esModule",{value:!0}),t);var T={};h(T,{deepkitPlugin:()=>m,default:()=>A,transformExtern:()=>R});module.exports=P(T);var l=require("fs/promises"),c=k(require("@deepkit/type-compiler")),s=require("util");var p=t=>new TextDecoder().decode(t);var f=new c.DeepkitLoader,d=(...t)=>{console.log("printDiagnostics",(0,s.inspect)(t,!1,10,!0))},u={filter:/\.(m|c)?tsx?$/,namespace:"file"},R=(t,e,n)=>{if(!t.reflection||!n.contents||!u.filter.test(e.path)||e.pluginData?.isReflected)return n;let r=e.namespace+":"+e.path;try{let o=typeof n.contents=="string"?n.contents:p(n.contents);n.contents=f.transform(o,r),n.pluginData=n.pluginData||{},n.pluginData.isReflected=!0}catch(o){d({file:r,error:o})}return n},x=async t=>{let e;try{if(e=await(0,l.readFile)(t.path,"utf8"),t.pluginData?.isReflected)return{contents:e,loader:"ts",pluginData:{isReflected:!0}};e=f.transform(e,t.path)}catch(n){return d({file:t.path,error:n}),null}return{contents:e,loader:"ts",pluginData:{isReflected:!0}}},m=(t={})=>({name:"deepkit",setup(e){t.reflection=t.reflection===void 0?!0:t.reflection,t.reflection&&e.onLoad(u,x)}}),A=m;0&&(module.exports={deepkitPlugin,transformExtern});
|