Merge pull request #868 from dolanmiu/feat/webpack-5
Update webpack and testing frameworks
This commit is contained in:
1
.nycrc
1
.nycrc
@ -21,6 +21,5 @@
|
|||||||
],
|
],
|
||||||
"cache": true,
|
"cache": true,
|
||||||
"all": true,
|
"all": true,
|
||||||
"instrument": false,
|
|
||||||
"sourceMap": true
|
"sourceMap": true
|
||||||
}
|
}
|
||||||
|
@ -12,9 +12,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
function generate() {
|
function generate() {
|
||||||
const doc = new docx.Document();
|
const doc = new docx.Document({
|
||||||
|
|
||||||
const doc = new Document({
|
|
||||||
sections: [
|
sections: [
|
||||||
{
|
{
|
||||||
children: [
|
children: [
|
||||||
|
5104
package-lock.json
generated
5104
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
24
package.json
24
package.json
@ -5,22 +5,21 @@
|
|||||||
"main": "build/index.js",
|
"main": "build/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"pretest": "rimraf ./build",
|
"pretest": "rimraf ./build",
|
||||||
"test": "mocha-webpack \"src/**/*.ts\"",
|
"test": "mocha -r ts-node/register -r tsconfig-paths/register \"src/**/*.ts\"",
|
||||||
"test.coverage": "nyc npm test",
|
"test.coverage": "nyc npm test",
|
||||||
"test.watch": "npm test -- --watch",
|
"test.watch": "npm test -- --watch",
|
||||||
"prepublishOnly": "npm run build --production",
|
"prepublishOnly": "npm run build --production",
|
||||||
"lint": "tslint --project .",
|
"lint": "tslint --project .",
|
||||||
"build": "npm run webpack && npm run fix-types",
|
"build": "npm run webpack",
|
||||||
"tsc": "rimraf ./build && tsc -p .",
|
"webpack": "rimraf ./build && webpack --config ./webpack.config.ts",
|
||||||
"webpack": "rimraf ./build && webpack",
|
"demo": "npm run build && npm run ts-node --skip-project ./demo",
|
||||||
"demo": "npm run build && npm run ts-node ./demo",
|
|
||||||
"typedoc": "rimraf ./build && typedoc src/index.ts --tsconfig tsconfig.typedoc.json",
|
"typedoc": "rimraf ./build && typedoc src/index.ts --tsconfig tsconfig.typedoc.json",
|
||||||
"style": "prettier -l \"src/**/*.ts\"",
|
"style": "prettier -l \"src/**/*.ts\"",
|
||||||
"style.fix": "npm run style -- --write",
|
"style.fix": "npm run style -- --write",
|
||||||
"fix-types": "ts-node scripts/types-absolute-fixer.ts",
|
"fix-types": "ts-node scripts/types-absolute-fixer.ts",
|
||||||
"e2e": "ts-node scripts/e2e.ts",
|
"e2e": "ts-node scripts/e2e.ts",
|
||||||
"serve.docs": "cd docs && docsify serve",
|
"serve.docs": "cd docs && docsify serve",
|
||||||
"ts-node": "ts-node"
|
"ts-node": "ts-node --skip-project"
|
||||||
},
|
},
|
||||||
"pre-commit": [
|
"pre-commit": [
|
||||||
"style",
|
"style",
|
||||||
@ -68,17 +67,16 @@
|
|||||||
"@types/request-promise": "^4.1.42",
|
"@types/request-promise": "^4.1.42",
|
||||||
"@types/sinon": "^9.0.4",
|
"@types/sinon": "^9.0.4",
|
||||||
"@types/webpack": "^5.0.0",
|
"@types/webpack": "^5.0.0",
|
||||||
"awesome-typescript-loader": "^3.4.1",
|
"buffer": "^6.0.3",
|
||||||
"chai": "^3.5.0",
|
"chai": "^3.5.0",
|
||||||
"docsify-cli": "^4.3.0",
|
"docsify-cli": "^4.3.0",
|
||||||
"glob": "^7.1.2",
|
"glob": "^7.1.2",
|
||||||
"istanbul-instrumenter-loader": "^3.0.1",
|
|
||||||
"jszip": "^3.1.5",
|
"jszip": "^3.1.5",
|
||||||
"mocha": "^5.2.0",
|
"mocha": "^8.3.2",
|
||||||
"mocha-webpack": "^1.0.1",
|
|
||||||
"nyc": "^15.1.0",
|
"nyc": "^15.1.0",
|
||||||
"pre-commit": "^1.2.2",
|
"pre-commit": "^1.2.2",
|
||||||
"prettier": "^2.1.2",
|
"prettier": "^2.1.2",
|
||||||
|
"process": "^0.11.10",
|
||||||
"prompt": "^1.0.0",
|
"prompt": "^1.0.0",
|
||||||
"replace-in-file": "^3.1.0",
|
"replace-in-file": "^3.1.0",
|
||||||
"request": "^2.88.0",
|
"request": "^2.88.0",
|
||||||
@ -86,12 +84,16 @@
|
|||||||
"rimraf": "^3.0.2",
|
"rimraf": "^3.0.2",
|
||||||
"shelljs": "^0.8.4",
|
"shelljs": "^0.8.4",
|
||||||
"sinon": "^10.0.0",
|
"sinon": "^10.0.0",
|
||||||
|
"stream-browserify": "^3.0.0",
|
||||||
|
"ts-loader": "^8.1.0",
|
||||||
"ts-node": "^9.0.0",
|
"ts-node": "^9.0.0",
|
||||||
|
"tsconfig-paths": "^3.9.0",
|
||||||
"tslint": "^6.1.3",
|
"tslint": "^6.1.3",
|
||||||
"tslint-immutable": "^6.0.1",
|
"tslint-immutable": "^6.0.1",
|
||||||
"typedoc": "^0.20.29",
|
"typedoc": "^0.20.29",
|
||||||
"typescript": "4.2.3",
|
"typescript": "4.2.3",
|
||||||
"webpack": "^3.10.0"
|
"webpack": "^5.28.0",
|
||||||
|
"webpack-cli": "^4.6.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=10"
|
"node": ">=10"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { assert, expect } from "chai";
|
import { assert, expect } from "chai";
|
||||||
import * as sinon from "sinon";
|
import * as sinon from "sinon";
|
||||||
|
|
||||||
import { Formatter } from "export/formatter";
|
import { Formatter } from "@export/formatter";
|
||||||
import { Paragraph, TextRun } from "file";
|
import { Paragraph, TextRun } from "file";
|
||||||
import { CoreProperties } from "file/core-properties";
|
import { CoreProperties } from "file/core-properties";
|
||||||
import { Attributes } from "file/xml-components";
|
import { Attributes } from "file/xml-components";
|
||||||
|
@ -13,8 +13,10 @@
|
|||||||
"noUnusedParameters": true,
|
"noUnusedParameters": true,
|
||||||
"baseUrl": "./src",
|
"baseUrl": "./src",
|
||||||
"paths": {
|
"paths": {
|
||||||
"/*": ["./*"]
|
"/*": ["./*"],
|
||||||
|
"convenience-functions": ["./convenience-functions"],
|
||||||
|
"@export/*": ["./export/*"]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"exclude": ["node_modules", "tests", "**/_*", "demo", "scripts", "webpack.config.ts"]
|
"include": ["src"]
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
// tslint:disable:no-object-literal-type-assertion
|
|
||||||
import * as path from "path";
|
import * as path from "path";
|
||||||
import { Configuration } from "webpack";
|
import { Configuration, ProvidePlugin } from "webpack";
|
||||||
|
|
||||||
|
const configuration: Configuration = {
|
||||||
|
mode: "production",
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
entry: "./src/index.ts",
|
entry: "./src/index.ts",
|
||||||
|
|
||||||
output: {
|
output: {
|
||||||
@ -10,34 +11,36 @@ module.exports = {
|
|||||||
filename: "index.js",
|
filename: "index.js",
|
||||||
libraryTarget: "umd",
|
libraryTarget: "umd",
|
||||||
library: "docx",
|
library: "docx",
|
||||||
|
globalObject: "this",
|
||||||
},
|
},
|
||||||
|
|
||||||
resolve: {
|
resolve: {
|
||||||
extensions: [".tsx", ".ts", ".js"],
|
extensions: [".ts", ".js"],
|
||||||
modules: [path.resolve("./src"), "node_modules"],
|
modules: [path.resolve("./src"), "node_modules"],
|
||||||
|
fallback: {
|
||||||
|
buffer: require.resolve("buffer"),
|
||||||
|
stream: require.resolve("stream-browserify"),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
module: {
|
module: {
|
||||||
rules: [
|
rules: [
|
||||||
{
|
{
|
||||||
test: /\.ts$/,
|
test: /\.ts$/,
|
||||||
loaders: ["awesome-typescript-loader"],
|
loader: "ts-loader",
|
||||||
|
options: {
|
||||||
|
configFile: "tsconfig.json",
|
||||||
},
|
},
|
||||||
// For coverage testing
|
|
||||||
...(process.env.NODE_ENV !== "production"
|
|
||||||
? [
|
|
||||||
{
|
|
||||||
test: /\.(ts)/,
|
|
||||||
include: path.resolve("src"),
|
|
||||||
loader: "istanbul-instrumenter-loader",
|
|
||||||
enforce: "post",
|
|
||||||
exclude: [/node_modules/],
|
|
||||||
},
|
},
|
||||||
]
|
|
||||||
: []),
|
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
||||||
// Because docx is now targetting web
|
plugins: [
|
||||||
// target: 'node',
|
// fix "process is not defined" error
|
||||||
} as Configuration;
|
new ProvidePlugin({
|
||||||
|
process: "process/browser",
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = configuration;
|
||||||
|
Reference in New Issue
Block a user