1

So, I recently tried to use the TS neo4j-driver (neo4j-driver), which of course works as supposed inside a TS app.

However, when I try to use neo4j-driver in combination with Stencil, I get a compiler error from the stencil compiler (Node Polyfills Required). So, I changed my stencil.config.ts to

import { Config } from '@stencil/core';
import nodePolyfills from 'rollup-plugin-node-polyfills';
import { sass } from '@stencil/sass';

export const config: Config = {
  namespace: 'graph-viz',
  outputTargets: [
    {
      type: 'dist',
      esmLoaderPath: '../loader',
    },
    {
      type: 'dist-custom-elements',
    },
    {
      type: 'docs-readme',
    },
    {
      type: 'www',
      serviceWorker: null, // disable service workers
    },
  ],
  plugins: [
    sass({
      injectGlobalPaths: ['src/scss/objects.scss'],
    }),
  ],
  rollupPlugins: { after: [nodePolyfills()] }
};

Now the thing is, to get neo4j-driver to work in this context, I still need to manually patch /node_modules/neo4j-driver-bolt-connection/lib/channel/channel-buf.js and utf8.js and replace every occurrence of var buffer_1 = __importDefault(require("buffer")); to var buffer_1 = __importDefault(require("buffer/")); (notice the trailing slash).

Why is this even required, I just don't get it. All I know is it breaks updates of the required modules, and requires manual patching, which are both huge red flags / showstoppers for me.

lightxx
  • 1,037
  • 2
  • 11
  • 29

0 Answers0