Skip to content

Commit

Permalink
perf: enhance project structure and introduce normalization
Browse files Browse the repository at this point in the history
This commit significantly restructures the project to improve its maintainability and compatibility across different systems. Changes include:

- Added `.editorconfig` settings for `Makefile` to ensure consistent indentation using tabs, promoting a unified coding style across different IDEs/environments.
- Updated `.gitignore` and introduced `.npmignore` to refine what files are excluded from version control and what files are ignored when publishing the package. This ensures that only relevant files are packaged, reducing the package size and enhancing security.
- Adjusted `package.json` to simplify the project's structure by removing outdated configurations and introducing `types`, `typesVersions`, and updated `exports` to better support TypeScript type definitions and module resolution. This aims to provide clearer entry points for different module systems (ESM, CommonJS), making the library more accessible to various consumers.
- Introduced specific `tsconfig` files (`tsconfig.bundler.json`, `tsconfig.cjs.json`, `tsconfig.esm.json`, and `tsconfig.types.json`) to cater to different build targets (AMD, CommonJS, ES Modules, and type declarations). This modularized approach allows for more tailored compilation settings, improving build performance and compatibility.
- Updated the build and prepack scripts to incorporate these changes, ensuring that the library is properly built before it is packed and published.

These changes collectively aim to make the library more robust, flexible, and easier to use across diverse environments. By adopting common conventions and optimizing for current JavaScript toolchains, the project sets a strong foundation for future development and collaboration.
  • Loading branch information
JonDotsoy committed Mar 21, 2024
1 parent 2a18c81 commit 77fbdad
Show file tree
Hide file tree
Showing 9 changed files with 103 additions and 10 deletions.
5 changes: 4 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@ indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = false
insert_final_newline = false
insert_final_newline = false

[Makefile]
indent_style = tab
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
!.editorconfig
!.npmignore
lib/
!Makefile

# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore

Expand Down
6 changes: 6 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
src/
Makefile
tsconfig.*
*.lockb
.*
*.tgz
Binary file modified bun.lockb
Binary file not shown.
41 changes: 34 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,61 @@
"name": "streamable-tools",
"description": "`streamable-tools` is a JS/TS library for easy stream manipulation in web apps, offering utilities like `MultiplyStream` for data propagation, `SplitStream` for data splitting, and tools for stream creation and control.",
"version": "0.1.5",
"module": "index.ts",
"type": "module",
"license": "MIT",
"types": "./index.d.ts",
"typesVersions": {
"*": {
"*": [
"./lib/types/*"
]
}
},
"exports": {
".": {
"types": "./lib/types/index.d.ts",
"import": "./lib/esm/index.js",
"default": "./lib/cjs/index.js"
},
"./multiply-stream": {
"default": "./dist/esm/multiply-stream.js"
"types": "./lib/types/multiply-stream.d.ts",
"import": "./lib/esm/multiply-stream.js",
"default": "./lib/cjs/multiply-stream.js"
},
"./readable-stream-with-controller": {
"default": "./dist/esm/readable-stream-with-controller.js"
"types": "./lib/types/readable-stream-with-controller.d.ts",
"import": "./lib/esm/readable-stream-with-controller.js",
"default": "./lib/cjs/readable-stream-with-controller.js"
},
"./split-stream": {
"default": "./dist/esm/split-stream.js"
"types": "./lib/types/split-stream.d.ts",
"import": "./lib/esm/split-stream.js",
"default": "./lib/cjs/split-stream.js"
},
"./iterable-to-readable-stream": {
"default": "./dist/esm/iterable-to-readable-stream.js"
"types": "./lib/types/iterable-to-readable-stream.d.ts",
"import": "./lib/esm/iterable-to-readable-stream.js",
"default": "./lib/cjs/iterable-to-readable-stream.js"
}
},
"repository": {
"type": "git",
"url": "https://github.com/JonDotsoy/streamable-tools.git"
},
"files": [
"./src/",
"./lib/cjs/",
"./lib/types/",
"./lib/esm/"
],
"scripts": {
"build@esm": "tsc --project tsconfig.esm.json --outdir ./dist/esm",
"prepack": "make build",
"build": "make build",
"fmt": "prettier -w ."
},
"devDependencies": {
"@types/bun": "latest",
"prettier": "^3.2.5",
"semver": "^7.6.0",
"typescript": "^5.4.2"
},
"peerDependencies": {
Expand Down
13 changes: 13 additions & 0 deletions tsconfig.bundler.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"noEmit": false,
"declaration": true,
"allowImportingTsExtensions": false,
"moduleResolution": "Bundler",
"target": "ES2015",
"module": "amd",
"verbatimModuleSyntax": false
},
"exclude": ["./dist/", "**/*.spec.ts"]
}
15 changes: 15 additions & 0 deletions tsconfig.cjs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"noEmit": false,
"declaration": true,
"allowImportingTsExtensions": false,
"moduleResolution": "Node",
"target": "ES2016",
"module": "CommonJS",
"verbatimModuleSyntax": false,
"sourceRoot": "./src/",
"inlineSourceMap": true
},
"exclude": ["./dist/", "./lib/", "**/*.spec.ts", "**/tests/**"]
}
12 changes: 10 additions & 2 deletions tsconfig.esm.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,15 @@
"compilerOptions": {
"noEmit": false,
"declaration": true,
"allowImportingTsExtensions": false
"allowImportingTsExtensions": false,
"sourceRoot": "./src/",
"inlineSourceMap": true
},
"exclude": ["**/*.spec.ts"]
"exclude": [
"./dist/",
"./lib/",
"**/*.spec.ts",
"**/tests/**",
"**/__templates__/**"
]
}
18 changes: 18 additions & 0 deletions tsconfig.types.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"noEmit": false,
"declaration": true,
"allowImportingTsExtensions": false,
"sourceRoot": "./src/",
"inlineSourceMap": true,
"emitDeclarationOnly": true
},
"exclude": [
"./dist/",
"./lib/",
"**/*.spec.ts",
"**/tests/**",
"**/__templates__/**"
]
}

0 comments on commit 77fbdad

Please sign in to comment.