Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(packaging): configure rollup for jitar #261

Merged
merged 22 commits into from
Apr 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
ba1a786
Builds the client library
basmasking Apr 15, 2023
28360d1
Merge branch 'main' into 249-configure-rollup-for-jitar
basmasking Apr 17, 2023
be27ce7
Merge branch 'main' into 249-configure-rollup-for-jitar
basmasking Apr 17, 2023
60c4c10
Resolved merge conflicts
basmasking Apr 17, 2023
e6d402a
Second iteration of the config
basmasking Apr 17, 2023
4503a40
Added lib to the ignore list
basmasking Apr 17, 2023
6e768cc
Merge branch 'main' into 249-configure-rollup-for-jitar
basmasking Apr 19, 2023
f79b16b
Resolved conflict
basmasking Apr 19, 2023
16dc63e
Merge branch 'main' into 249-configure-rollup-for-jitar
basmasking Apr 19, 2023
ce9925f
Working setup
basmasking Apr 19, 2023
161ade7
Something that works too
basmasking Apr 19, 2023
1614a15
Fixed issue with minification
basmasking Apr 21, 2023
4a2f71e
Moved errors to separate package
basmasking Apr 21, 2023
5619482
No default export in jitar errors
basmasking Apr 24, 2023
c2f5215
Updated config to replace @jitar/errors with ./errors.js
basmasking Apr 24, 2023
c79136c
Moved the errors back in the runtime package
basmasking Apr 24, 2023
a42a75a
Get the errors from the runtime package
basmasking Apr 24, 2023
1684313
Restored instanceof check
basmasking Apr 24, 2023
66ca36e
First satisfying config
basmasking Apr 24, 2023
a3e0818
Redirect all external jitar dependencies to internal jitar
basmasking Apr 24, 2023
b00a373
Merge branch 'main' into 249-configure-rollup-for-jitar
basmasking Apr 24, 2023
5598333
Processed feedback
basmasking Apr 24, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6,293 changes: 3,710 additions & 2,583 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
"test": "npm run test --workspace=packages/reflection --workspace=packages/serialization --workspace=packages/runtime --workspace=packages/caching --workspace=packages/server-nodejs --workspace=packages/jitar --workspace=packages/create-jitar --workspace=packages/plugin-vite --if-present"
},
"devDependencies": {
"@rollup/plugin-node-resolve": "^15.0.2",
"@rollup/plugin-replace": "^5.0.2",
"@rollup/plugin-terser": "^0.4.1",
"@rollup/plugin-typescript": "^11.1.0",
"@types/express": "^4.17.17",
"@types/express-http-proxy": "^1.6.3",
"@types/fs-extra": "^11.0.1",
Expand All @@ -46,6 +50,8 @@
"eslint": "^8.38.0",
"eslint-plugin-jitar": "0.0.1",
"lerna": "^6.6.1",
"rollup": "^3.20.2",
"rollup-plugin-dts": "^5.3.0",
"vite": "^4.2.1",
"vitest": "^0.30.0"
}
Expand Down
8 changes: 2 additions & 6 deletions packages/jitar/.npmignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
coverage
src
test
node_modules
.eslintignore
.eslintrc
vite.config.ts
dist/types
tsconfig.json
rollup.config.js
*.tgz
97 changes: 0 additions & 97 deletions packages/jitar/CHANGELOG.md

This file was deleted.

23 changes: 17 additions & 6 deletions packages/jitar/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,31 @@
"author": "Masking Technology <[email protected]> (https://jitar.dev)",
"license": "MIT",
"type": "module",
"types": "dist/lib.d.ts",
"types": "./dist/lib.d.ts",
"sideEffects": true,
"exports": {
".": "./dist/lib.js"
".": "./dist/lib.js",
"./server": "./dist/server.js",
"./client": "./dist/client.js"
},
"scripts": {
"lint": "eslint . --ext .ts",
"build": "tsc -p tsconfig.json",
"clean": "rm -rf dist build",
"validate": "tsc -p tsconfig.json --noEmit",
"build": "npm run clean && rollup -c",
"clean": "rm -rf dist",
"release": "npm run clean && npm run build && npm publish"
},
"dependencies": {
"@jitar/runtime": "^0.4.0",
"@jitar/server-nodejs": "^0.4.0"
"@jitar/server-nodejs": "^0.4.0",
"express": "^4.18.2",
"express-http-proxy": "^1.6.3",
"fs-extra": "^11.1.1",
"glob-promise": "6.0.2",
"mime-types": "^2.1.35",
"tslog": "^4.8.2",
"yargs": "^17.7.1",
"zod": "^3.21.4"
},
"engines": {
"node": ">=18.7"
Expand All @@ -41,4 +52,4 @@
"full stack",
"web applications"
]
}
}
56 changes: 56 additions & 0 deletions packages/jitar/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@

import terser from '@rollup/plugin-terser';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import typescript from '@rollup/plugin-typescript';
import replace from '@rollup/plugin-replace';
import dts from 'rollup-plugin-dts';

import { SERVER_EXTERNALS, REPLACE_VALUES } from './rollup.definitions.js';

export default [
{
external: SERVER_EXTERNALS,
input: {
server: 'src/server.ts',
client: 'src/client.ts'
},
output: {
dir: 'dist',
exports: 'named',
format: 'module',
plugins: [terser({
module: true,
mangle: false
})]
},
plugins: [
typescript(),
replace({
preventAssignment: true,
values: REPLACE_VALUES
}),
nodeResolve()
]
},
{
external: [
'./client.js',
'./server.js'
],
input: 'src/lib.ts',
output: {
file: 'dist/lib.js',
format: 'module'
},
plugins: [
typescript()
]
},
{
input: './dist/types/lib.d.ts',
output: [{ file: 'dist/lib.d.ts', format: 'module' }],
plugins: [dts({
respectExternal: true
})],
}
]
15 changes: 15 additions & 0 deletions packages/jitar/rollup.definitions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

export const SERVER_EXTERNALS = [
'express',
'express-http-proxy',
'fs-extra',
'glob-promise',
'mime-types',
'tslog',
'yargs',
'zod'
];

export const REPLACE_VALUES = {
'RUNTIME_ERROR_LOCATION': '/jitar/client.js'
};
43 changes: 40 additions & 3 deletions packages/jitar/src/client.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,41 @@

export { startClient, getClient } from '@jitar/runtime';

export * from './shared.js';
export
{
HealthCheck,
Middleware,
NextHandler,
Segment,
Procedure,
Implementation,
Version,
NamedParameter,
ArrayParameter,
ObjectParameter,
BadRequest,
Forbidden,
NotFound,
NotImplemented,
PaymentRequired,
ServerError,
Teapot,
Unauthorized,
ClientNotFound,
FileNotFound,
ImplementationNotFound,
InvalidClientId,
InvalidParameterValue,
InvalidSegmentFile,
InvalidVersionNumber,
MissingParameterValue,
ModuleNotAccessible,
ModuleNotLoaded,
NoNodeAvailable,
ProcedureNotAccessible,
ProcedureNotFound,
RepositoryNotAvailable,
RuntimeNotAvailable,
SegmentNotFound,
UnknownParameter,
startClient,
getClient
} from '@jitar/runtime';
2 changes: 0 additions & 2 deletions packages/jitar/src/server.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@

export { startServer, CorsMiddleware } from '@jitar/server-nodejs';

export * from './shared.js';
13 changes: 0 additions & 13 deletions packages/jitar/src/shared.ts

This file was deleted.

9 changes: 4 additions & 5 deletions packages/jitar/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
{
"compilerOptions": {
"target": "es2022",
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"module": "es2022",
"target": "ESNext",
"module": "ESNext",
"declaration": true,
"declarationDir": "./dist/types",
"rootDir": "./src/",
"moduleResolution": "node",
"declaration": true,
"outDir": "./dist",
"removeComments": true,
"esModuleInterop": true,
Expand Down
26 changes: 18 additions & 8 deletions packages/reflection/src/models/ReflectionScope.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@ import ReflectionExport from './ReflectionExport.js';
import ReflectionGenerator from './ReflectionGenerator.js';
import ReflectionDeclaration from './ReflectionDeclaration.js';

// Required to work after minification.
const IMPORT_NAME = ReflectionImport.name;
const EXPORT_NAME = ReflectionExport.name;
const DECLARATION_NAME = ReflectionDeclaration.name;
const FUNCTION_NAME = ReflectionFunction.name;
const GETTER_NAME = ReflectionGetter.name;
const SETTER_NAME = ReflectionSetter.name;
const GENERATOR_NAME = ReflectionGenerator.name;
const CLASS_NAME = ReflectionClass.name;

export default class ReflectionScope
{
#members: ReflectionMember[];
Expand All @@ -23,21 +33,21 @@ export default class ReflectionScope

get members(): ReflectionMember[] { return this.#members; }

get imports(): ReflectionImport[] { return this.#members.filter(member => member.constructor.name === 'ReflectionImport') as ReflectionImport[]; }
get imports(): ReflectionImport[] { return this.#members.filter(member => member.constructor.name === IMPORT_NAME) as ReflectionImport[]; }

get exports(): ReflectionExport[] { return this.#members.filter(member => member.constructor.name === 'ReflectionExport') as ReflectionExport[]; }
get exports(): ReflectionExport[] { return this.#members.filter(member => member.constructor.name === EXPORT_NAME) as ReflectionExport[]; }

get declarations(): ReflectionDeclaration[] { return this.#members.filter(member => member.constructor.name === 'ReflectionDeclaration') as ReflectionDeclaration[]; }
get declarations(): ReflectionDeclaration[] { return this.#members.filter(member => member.constructor.name === DECLARATION_NAME) as ReflectionDeclaration[]; }

get functions(): ReflectionFunction[] { return this.#members.filter(member => member.constructor.name === 'ReflectionFunction') as ReflectionFunction[]; }
get functions(): ReflectionFunction[] { return this.#members.filter(member => member.constructor.name === FUNCTION_NAME) as ReflectionFunction[]; }

get getters(): ReflectionGetter[] { return this.#members.filter(member => member.constructor.name === 'ReflectionGetter') as ReflectionGetter[]; }
get getters(): ReflectionGetter[] { return this.#members.filter(member => member.constructor.name === GETTER_NAME) as ReflectionGetter[]; }

get setters(): ReflectionSetter[] { return this.#members.filter(member => member.constructor.name === 'ReflectionSetter') as ReflectionSetter[]; }
get setters(): ReflectionSetter[] { return this.#members.filter(member => member.constructor.name === SETTER_NAME) as ReflectionSetter[]; }

get generators(): ReflectionGenerator[] { return this.#members.filter(member => member.constructor.name === 'ReflectionGenerator') as ReflectionGenerator[]; }
get generators(): ReflectionGenerator[] { return this.#members.filter(member => member.constructor.name === GENERATOR_NAME) as ReflectionGenerator[]; }

get classes(): ReflectionClass[] { return this.#members.filter(member => member.constructor.name === 'ReflectionClass') as ReflectionClass[]; }
get classes(): ReflectionClass[] { return this.#members.filter(member => member.constructor.name === CLASS_NAME) as ReflectionClass[]; }

getMember(name: string): ReflectionMember | undefined
{
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime/src/errors/ClientNotFound.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ export default class ClientNotFound extends BadRequest
get clientId() { return this.#clientId; }
}

(ClientNotFound as Loadable).source = '/jitar-runtime/errors/ClientNotFound.js';
(ClientNotFound as Loadable).source = 'RUNTIME_ERROR_LOCATION';
2 changes: 1 addition & 1 deletion packages/runtime/src/errors/FileNotFound.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ export default class FileNotFound extends NotFound
get filename() { return this.#filename; }
}

(FileNotFound as Loadable).source = '/jitar-runtime/errors/FileNotFound.js';
(FileNotFound as Loadable).source = 'RUNTIME_ERROR_LOCATION';
2 changes: 1 addition & 1 deletion packages/runtime/src/errors/ImplementationNotFound.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ export default class ImplementationNotFound extends NotFound
get version() { return this.#version; }
}

(ImplementationNotFound as Loadable).source = '/jitar-runtime/errors/ImplementationNotFound.js';
(ImplementationNotFound as Loadable).source = 'RUNTIME_ERROR_LOCATION';
2 changes: 1 addition & 1 deletion packages/runtime/src/errors/InvalidClientId.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ export default class InvalidClientId extends BadRequest
get clientId() { return this.#clientId; }
}

(InvalidClientId as Loadable).source = '/jitar-runtime/errors/InvalidClientId.js';
(InvalidClientId as Loadable).source = 'RUNTIME_ERROR_LOCATION';
Loading