Skip to content

Commit

Permalink
feat: add library template /libs/node-ts-esm-webpack
Browse files Browse the repository at this point in the history
  • Loading branch information
neoncitylights committed Feb 1, 2024
1 parent f9ab7a8 commit 14fbead
Show file tree
Hide file tree
Showing 7 changed files with 6,126 additions and 6 deletions.
1 change: 1 addition & 0 deletions .github/workflows/node.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ jobs:
- node-ts-esm-parcel
- node-ts-esm-rollup
- node-ts-esm-vite
- node-ts-esm-webpack
steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand Down
34 changes: 34 additions & 0 deletions libs/node-ts-esm-webpack/package.json
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"
}
}
3 changes: 3 additions & 0 deletions libs/node-ts-esm-webpack/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function greet(name: string) {
return `Hello ${name}`
}
15 changes: 15 additions & 0 deletions libs/node-ts-esm-webpack/tsconfig.json
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
}
}
46 changes: 46 additions & 0 deletions libs/node-ts-esm-webpack/webpack.config.cjs
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;
};
66 changes: 60 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 14fbead

Please sign in to comment.