packaging working, need to fix json import assertion

This commit is contained in:
Felix Kaspar 2024-01-12 18:39:57 +01:00
parent 9c1588d150
commit c07e247a2a
5 changed files with 1629 additions and 1364 deletions

2892
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -2,7 +2,6 @@
"name": "@stirling-pdf/server-node",
"version": "0.0.0",
"description": "",
"//": "end pkgroll config",
"type": "module",
"exports": "./dist/index.js",
"imports": {
@ -11,13 +10,15 @@
"optionalDependencies": {
"canvas": "^2.11.2"
},
"files": [
"/shared-operations/src/wasm/pdfcpu/pdfcpu.wasm"
],
"scripts": {
"build": "pkgroll",
"dev": "npx tsx watch src/index.ts",
"build": "npm run prebuild && pkgroll && npm run postbuild",
"start": "node ./dist/index.js",
"dev": "npx tsx watch src/index.ts"
"prebuild": "rimraf ./dist",
"postbuild": "npm run copy-locales && npm run copy-pdfcpu",
"copy-locales": "copyfiles -u 3 ../shared-operations/src/locales/**/*.json dist",
"copy-pdfcpu": "copyfiles -u 5 ../shared-operations/src/wasm/pdfcpu/pdfcpu.wasm dist"
},
"keywords": [],
"author": "",
@ -38,8 +39,11 @@
"tsconfig-paths": "^4.2.0"
},
"devDependencies": {
"copyfiles": "^2.4.1",
"pkgroll": "^2.0.1",
"rimraf": "^5.0.5",
"ts-node-dev": "^2.0.0",
"typescript": "^5.2.2"
}
}

View File

@ -1,4 +1,4 @@
import "@stirling-pdf/shared-operations/src/locales/i18next.config";
import "@stirling-pdf/shared-operations/src/i18next.config";
import express from "express";
const app = express();

View File

@ -2,10 +2,10 @@ import i18next from "i18next";
import resourcesToBackend from "i18next-resources-to-backend";
i18next
.use(resourcesToBackend((language, namespace) => import(`./${namespace}/${language}.json`)))
.use(resourcesToBackend((language, namespace) => import(`./locales/${namespace}/${language}.json`)))
.init({
// debug: true,
ns: ["common"], // Preload this namespace, no need to add the others
ns: ["common"], // Preload this namespace, no need to add the others, they will load once their module is loaded
defaultNS: "common",
fallbackLng: "en",
interpolation: {

View File

@ -1,7 +1,8 @@
import { WasmFs } from '@wasmer/wasmfs';
import path from "path";
import { fileURLToPath } from 'url';
let nodeWasmLocation = "../shared-operations/src/wasm/pdfcpu/"; // TODO: Replace with __dirname
let nodeWasmLocation = path.dirname(fileURLToPath(import.meta.url));
let fs;
const wasmfs = new WasmFs();