Skip to content

Commit

Permalink
build: Use Rollup and swc for build and minify
Browse files Browse the repository at this point in the history
  • Loading branch information
Unnoen committed Apr 3, 2023
1 parent 0b80187 commit 4aa3b78
Show file tree
Hide file tree
Showing 7 changed files with 414 additions and 42 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ It supports nested classes, arrays, null/undefined values, has type safety and t

Designed to be lightweight with no dependencies. Your bundler will thank you.

Offers both CommonJS and ES Module builds, so you can use it with Node.js, Webpack, Rollup, Parcel, Vite etc.

- [Installation](#installation)
- [Usage](#usage)
- [Simple Types](#simple-types)
Expand Down
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// noinspection JSUnusedGlobalSymbols // We ignore this because this is a config file read by jest.
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
export default {
preset: 'ts-jest',
testEnvironment: 'node',
};
33 changes: 15 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"packageManager": "yarn@3.5.0",
"name": "@unnoen/untypedjson",
"description": "A simple JSON deserializer and serializer for Node.js and the browser using TypeScript decorators.",
"version": "1.0.1",
"version": "1.0.2",
"type": "module",
"license": "MIT",
"author": "Unnoen",
"keywords": [
Expand All @@ -23,41 +24,37 @@
"bugs": {
"url": "https://github.com/Unnoen/UntypedJSON/issues"
},
"main": "./lib/cjs/index.js",
"main": "./lib/cjs/index.cjs",
"module": "./lib/esm/index.js",
"types": "./lib/cjs/index.d.ts",
"files": [
"lib"
],
"types": "./lib/esm/index.d.ts",
"exports": {
".": {
"import": {
"types": "./lib/esm/index.d.ts",
"default": "./lib/esm/index.js"
},
"require": {
"types": "./lib/cjs/index.d.ts",
"default": "./lib/cjs/index.js"
}
"import": "./lib/esm/index.js",
"require": "./lib/cjs/index.cjs"
}
},
"files": [
"lib"
],
"scripts": {
"build": "yarn build:esm && yarn build:cjs",
"build:esm": "tsc -p tsconfig.json",
"build:cjs": "tsc -p tsconfig.cjs.json",
"build": "rollup -c",
"test": "jest",
"lint": "eslint src --ext .ts",
"lint:fix": "eslint src --ext .ts --fix",
"prepublishOnly": "yarn build"
},
"devDependencies": {
"@swc/core": "^1.3.44",
"@swc/helpers": "^0.4.14",
"@types/jest": "^29.5.0",
"@types/node": "^18.15.11",
"eslint": "^8.37.0",
"eslint-config-canonical": "^41.0.1",
"eslint-import-resolver-typescript": "^3.5.4",
"jest": "^29.5.0",
"ts-jest": "^29.0.5",
"rollup": "^3.20.2",
"rollup-plugin-ts": "^3.2.0",
"ts-jest": "^29.1.0",
"typescript": "^5.0.3"
}
}
44 changes: 44 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// rollup.config.js
import ts from 'rollup-plugin-ts';

const config = [
{
input: 'src/index.ts',
output: {
file: 'lib/esm/index.js',
format: 'es',
sourcemap: false,
},
plugins: [ts(
{
swcConfig: {
minify: true,
},
transpiler: {
otherSyntax: 'swc',
typescriptSyntax: 'typescript',
},
},
)],
},
{
input: 'src/index.ts',
output: {
file: 'lib/cjs/index.cjs',
format: 'cjs',
sourcemap: false,
},
plugins: [ts(
{
swcConfig: {
minify: true,
},
transpiler: {
otherSyntax: 'swc',
typescriptSyntax: 'typescript',
},
},
)],
},
];
export default config;
7 changes: 0 additions & 7 deletions tsconfig.cjs.json

This file was deleted.

7 changes: 3 additions & 4 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@
"strict": false,
"skipLibCheck": true,
"declaration": true,
"declarationMap": true,
"sourceMap": true,
"outDir": "./lib/esm",
"lib": ["ES2021", "DOM"]
"outDir": "lib",
"removeComments": false,
"lib": ["ES2021", "DOM"],
},
"include": ["src/**/*.ts"],
"exclude": ["node_modules", "lib", ".yarn"]
Expand Down
Loading

0 comments on commit 4aa3b78

Please sign in to comment.