fix: use webpack for package

This commit is contained in:
春希 2020-03-31 03:14:44 +08:00
parent 4a3b60e601
commit b350a882d6
3 changed files with 47 additions and 6 deletions

View File

@ -7,7 +7,8 @@
"lib"
],
"scripts": {
"build": "rimraf lib && tsc",
"compile": "rimraf lib && tsc",
"build": "rimraf lib && webpack",
"demo": "ts-node -r tsconfig-paths/register ./src/demo/main.ts",
"test": "ava"
},
@ -19,8 +20,12 @@
"devDependencies": {
"ava": "^1.0.1",
"rimraf": "^3.0.2",
"ts-loader": "^6.2.2",
"ts-node": "^7.0.1",
"tsconfig-paths": "^3.9.0"
"tsconfig-paths": "^3.9.0",
"tsconfig-paths-webpack-plugin": "^3.2.0",
"webpack": "^4.42.1",
"webpack-cli": "^3.3.11"
},
"ava": {
"compileEnhancements": false,

View File

@ -1,15 +1,22 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"module": "es2015",
"noImplicitAny": true,
"sourceMap": true,
"moduleResolution": "node",
"isolatedModules": true,
"target": "es5",
"strictNullChecks": true,
"inlineSources": false,
"lib": ["es2015"],
"downlevelIteration": true,
"paths": {
"@/*": ["./src/*"]
},
"outDir": "./lib",
"lib": [
"es6"
],
"types": ["node"],
"baseUrl": ".", /* Base directory to resolve non-absolute module names. */
"baseUrl": "." /* Base directory to resolve non-absolute module names. */
},
"include": [
"src/**/*"

View File

@ -0,0 +1,29 @@
const path = require('path');
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
module.exports = {
// entry: './src/index.ts',
target: 'node',
entry: {
index: './src/index.ts',
// demo: './src/demo/main.ts',
},
module: {
rules: [
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/,
},
],
},
resolve: {
extensions: [ '.tsx', '.ts', '.js' ],
plugins: [new TsconfigPathsPlugin({/* options: see below */})],
},
output: {
// filename: 'bundle.js',
filename: '[name].js',
path: path.resolve(__dirname, 'lib'),
},
};