-
Hi there. This is my first contribution to this repository, I hope it's in the correct place. I am trying to integrate a NodeJS C++ Extension. The extension is a dedicated npm package, it provides an index.js and index.d.ts file and this index.js file requires a native C++ extension. The repository structure is as follows (I am skipping irrelevant files):
So the generated dist/index.js file contains Now I cloned the Theia-Blueprint repository and executed the
So it seems to find the file, but it's not loaded correctly. The package is used in the hello-backend-service.ts as follows: import { injectable } from '@theia/core/shared/inversify';
import { HelloBackendService } from '../common/protocol';
import { addon } from 'myaddon-package-name';
@injectable()
export class HelloBackendServiceImpl implements HelloBackendService {
sayHelloTo(name: string): Promise<string> {
return new Promise<string>(resolve => {
addon.add(5, 4, (_: unknown, data: unknown) => {
resolve(`${name} ${data}`);
});
});
}
} I've installed it via if (nodeConfig.config.optimization) {
// Some TerserPlugins
}
nodeConfig.nativePlugin.nativeBinding('myaddon', 'myaddon-package-name/build/Release/myaddon.node'); And there is also a "node-loader" in place somehow and I verified the existence of myaddon.node. Unfortunately, there is no positive outcome, yet. Do you have any ideas? Thanks in advance! Resources: |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Hey @ngfelixl, Thanks for the logs/context on this! Looking at this part:
It looks like you're attempting to load your native node package in the browser bundle. This is also indicated by the webpack error (we only generate a loader for You need to bind the backend contribution in a dedicated theia/packages/core/package.json Line 145 in 1a7486e |
Beta Was this translation helpful? Give feedback.
Hey @ngfelixl,
Thanks for the logs/context on this! Looking at this part:
It looks like you're attempting to load your native node package in the browser bundle. This is also indicated by the webpack error (we only generate a loader for
.node
files for the backend).You need to bind the backend contribution in a dedicated
backend-module.ts
file that is entered as abackend
module in yourpackage.json
. See for example:theia/packages/core/package.json
Line 145 in 1a7486e