-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add library template
/libs/node-ts-esm-webpack
- Loading branch information
1 parent
f9ab7a8
commit 14fbead
Showing
7 changed files
with
6,126 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
"private": true, | ||
"version": "1.0.0", | ||
"name": "node-ts-esm-webpack", | ||
"description": "Node, TypeScript (ESM), Webpack", | ||
"keywords": [ | ||
"node", | ||
"typescript", | ||
"esm", | ||
"webpack" | ||
], | ||
"type": "module", | ||
"types": "./dist/index.d.ts", | ||
"exports": { | ||
".": { | ||
"types": "./dist/index.d.ts", | ||
"require": "./dist/index.js" | ||
} | ||
}, | ||
"files": [ | ||
"dist" | ||
], | ||
"scripts": { | ||
"build": "webpack --mode=production", | ||
"prepublint": "npm run build", | ||
"publint": "publint ." | ||
}, | ||
"devDependencies": { | ||
"ts-loader": "^9.5.1", | ||
"typescript": "^5.3.3", | ||
"webpack": "^5.90.0", | ||
"webpack-cli": "^5.1.4" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export function greet(name: string) { | ||
return `Hello ${name}` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"include": [ | ||
"src" | ||
], | ||
"compilerOptions": { | ||
"baseUrl": "src", | ||
"outDir": "dist", | ||
"sourceMap": true, | ||
"esModuleInterop": true, | ||
"module": "ES2022", | ||
"moduleResolution": "Bundler", | ||
"declaration": true, | ||
"emitDeclarationOnly": false | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
const path = require('path'); | ||
const isProduction = process.env.NODE_ENV == 'production'; | ||
|
||
const config = { | ||
experiments: { | ||
outputModule: true, | ||
}, | ||
devtool: 'inline-source-map', | ||
entry: './src/index.ts', | ||
output: { | ||
path: path.resolve(__dirname, 'dist'), | ||
filename: 'index.js', | ||
clean: true, | ||
library: { | ||
type: 'module' | ||
} | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.([cm]?ts|tsx)$/, | ||
loader: 'ts-loader', | ||
exclude: ['/node_modules/'], | ||
}, | ||
], | ||
}, | ||
resolve: { | ||
extensions: ['.tsx', '.ts', '.jsx', '.js'], | ||
extensionAlias: { | ||
".js": [".js", ".ts"], | ||
".cjs": [".cjs", ".cts"], | ||
".mjs": [".mjs", ".mts"] | ||
} | ||
}, | ||
}; | ||
|
||
module.exports = () => { | ||
if (isProduction) { | ||
config.mode = 'production'; | ||
|
||
|
||
} else { | ||
config.mode = 'development'; | ||
} | ||
return config; | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.