Build option to be bundled as a standalone target
We want to distribute this as a https://nodejs.org/api/single-executable-applications.html#generating-single-executable-preparation-blobs single executable can you provide this or instructions how? I tried using pkg and configuring rollup to bundle the third party dependencies but I get stuck on an xhr one.
I think this would really enhance the deployment scenarios of this export server for many. Currently we do our charting in java.
Same issue here, I made a minmal failing example... It only contains highcharts-export-server which I try to bundle with rollup. On execution I get:
$ node.exe main.cjs
node:internal/modules/cjs/loader:1215
throw err;
^
Error: Cannot find module './xhr-sync-worker.js'
Require stack:
- C:\temp\highcharts-export-server-bundling\dist\main.cjs
at Module._resolveFilename (node:internal/modules/cjs/loader:1212:15)
at Function.resolve (node:internal/modules/helpers:193:19)
at requireXMLHttpRequestImpl (C:\temp\highcharts-export-server-bundling\dist\main.cjs:507517:51)
at C:\temp\highcharts-export-server-bundling\dist\main.cjs:509170:16
at requireXMLHttpRequest (C:\temp\highcharts-export-server-bundling\dist\main.cjs:509171:4)
at requireInterfaces (C:\temp\highcharts-export-server-bundling\dist\main.cjs:514272:20)
at requireWindow (C:\temp\highcharts-export-server-bundling\dist\main.cjs:514857:32)
at requireApi (C:\temp\highcharts-export-server-bundling\dist\main.cjs:516054:27)
at Object.<anonymous> (C:\temp\highcharts-export-server-bundling\dist\main.cjs:516379:18)
at Module._compile (node:internal/modules/cjs/loader:1529:14) {
code: 'MODULE_NOT_FOUND',
requireStack: [ 'C:\\temp\\highcharts-export-server-bundling\\dist\\main.cjs' ]
}
Node.js v20.19.0
// package.json
{
"type": "commonjs",
"main": "dist/index.cjs",
"scripts": {
"clean": "rimraf coverage dist tmp",
"build:release": "npm run clean && rollup -c"
},
"dependencies": {
"highcharts-export-server": "^5.0.0"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^29.0.0",
"@rollup/plugin-json": "^6.1.0",
"@rollup/plugin-node-resolve": "^16.0.3",
"@rollup/plugin-typescript": "^12.3.0",
"rimraf": "~6.1",
"rollup": "^4.52.5",
"typescript": "^5.9.3"
}
}
// rollup.config.js
import commonjs from '@rollup/plugin-commonjs';
import {nodeResolve} from '@rollup/plugin-node-resolve';
import json from '@rollup/plugin-json';
export default {
input: ['src/main.ts'],
output: {
dir: 'dist',
format: 'cjs',
entryFileNames: '[name].cjs',
},
plugins: [
nodeResolve({
preferBuiltins: true,
}),
commonjs({
requireNodeBuiltins: true,
}),
json()
],
};
// main.ts
import exporter from 'highcharts-export-server';
(async () => {
await exporter.init();
await exporter.shutdown();
})();
Run npm run build:release to bundle.
cd dist; node.exe main.cjs to run.