Skip to content

Commit 2c8766f

Browse files
committed
Minor Webpack changes
1 parent 0dc9759 commit 2c8766f

File tree

5 files changed

+9
-6
lines changed

5 files changed

+9
-6
lines changed

FAQ.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
# Frequently asked questions
33

4-
## How do I import Heapify in a Node.js ES6 module?
4+
## How do I import Heapify on a Node.js native ES6 module?
55

66
One could innocently try this:
77

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"types": "dist/heapify.d.ts",
1313
"scripts": {
1414
"test": "jest --coverage",
15-
"integration": "cd test/integration && ts-node --project scripts/run.tsconfig.json scripts/run.ts",
15+
"integration": "npm run build:prod --silent && cd test/integration && ts-node --project scripts/run.tsconfig.json scripts/run.ts",
1616
"count": "cloc src/heapify.ts",
1717
"bench": "node benchmark/index.mjs",
1818
"linter": "eslint . --ext js,mjs,ts",
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

22
import * as assert from "assert";
3-
import {MinQueue} from "heapify";
3+
import {MinQueue} from "heapify/dist/heapify.mjs";
44
import {testFunction} from "common";
55
assert.ok(testFunction(new MinQueue()));

tsconfig.json

+2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
{
22
"files": ["src/heapify.ts"],
33
"compilerOptions": {
4+
"resolveJsonModule": true,
45
"module": "CommonJS",
56
"target": "es2015",
67
"moduleResolution": "node",
78
"declaration": true,
89
"sourceMap": true,
910
"declarationDir": "./dist/",
11+
"outDir": "./dist/",
1012
"esModuleInterop": true,
1113
"allowSyntheticDefaultImports": true,
1214
"forceConsistentCasingInFileNames": true,

webpack.config.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11

22
import * as path from "path";
33
import ForkTsCheckerWebpackPlugin from "fork-ts-checker-webpack-plugin";
4+
import pkg from "./package.json";
45

56
let shouldCheckTypeScript = true;
67

@@ -64,7 +65,7 @@ function makeConfig(mode: string, filename: string, module: boolean) {
6465
return config;
6566
}
6667

67-
export default (mode: string) => [
68-
makeConfig(mode, "heapify.js", false),
69-
makeConfig(mode, "heapify.mjs", true),
68+
export default (_env: unknown, argv: {mode: string}) => [
69+
makeConfig(argv.mode, path.basename(pkg.main), false),
70+
makeConfig(argv.mode, path.basename(pkg.module), true),
7071
];

0 commit comments

Comments
 (0)