Skip to content
This repository was archived by the owner on Jun 24, 2025. It is now read-only.

Commit 3dbf8fb

Browse files
committed
build: Fix running webpack on ESM
1 parent 6f6ce38 commit 3dbf8fb

File tree

4 files changed

+7
-5
lines changed

4 files changed

+7
-5
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"build-backend-docs": "rimraf ./docs/backend_api && ./node_modules/.bin/jsdoc -c jsdoc-conf.json -d ./docs/backend_api src/becca/entities/*.js src/services/backend_script_api.js src/services/sql.js",
3535
"build-frontend-docs": "rimraf ./docs/frontend_api && ./node_modules/.bin/jsdoc -c jsdoc-conf.json -d ./docs/frontend_api src/public/app/entities/*.js src/public/app/services/frontend_script_api.js src/public/app/widgets/basic_widget.js src/public/app/widgets/note_context_aware_widget.js src/public/app/widgets/right_panel_widget.js",
3636
"build-docs": "npm run build-backend-docs && npm run build-frontend-docs",
37-
"webpack": "webpack -c webpack.config.ts",
37+
"webpack": "cross-env NODE_OPTIONS=--loader=ts-node/esm webpack -c webpack.config.ts",
3838
"test-jasmine": "cross-env TRILIUM_DATA_DIR=./data-test tsx ./node_modules/.bin/jasmine",
3939
"test-es6": "tsx -r esm spec-es6/attribute_parser.spec.ts",
4040
"test": "npm run test-jasmine && npm run test-es6",

src/services/asset_path.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
import packageJson from "../../package.json";
1+
import packageJson from "../../package.json" assert { type: "json" };
22

33
export default `assets/v${packageJson.version}`;

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"compilerOptions": {
33
"moduleResolution": "Bundler",
4-
"module": "ES2022",
4+
"module": "ESNext",
55
"target": "ES2020",
66
"declaration": false,
77
"sourceMap": true,

webpack.config.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
import { fileURLToPath } from "url";
12
import path from "path";
23
import assetPath from "./src/services/asset_path.js";
34

4-
module.exports = {
5+
const rootDir = path.dirname(fileURLToPath(import.meta.url));
6+
export default {
57
mode: 'production',
68
entry: {
79
setup: './src/public/app/setup.js',
@@ -10,7 +12,7 @@ module.exports = {
1012
},
1113
output: {
1214
publicPath: `${assetPath}/app-dist/`,
13-
path: path.resolve(__dirname, 'src/public/app-dist'),
15+
path: path.resolve(rootDir, 'src/public/app-dist'),
1416
filename: '[name].js',
1517
},
1618
devtool: 'source-map',

0 commit comments

Comments
 (0)