Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

get is not a function at getPubsubRoute , getLibp2pOptions #3531

Closed
raphael10-collab opened this issue Feb 5, 2021 · 10 comments
Closed

get is not a function at getPubsubRoute , getLibp2pOptions #3531

raphael10-collab opened this issue Feb 5, 2021 · 10 comments
Labels
need/triage Needs initial labeling and prioritization

Comments

@raphael10-collab
Copy link

Sorry for disturbing you again, but I get this error which seems to be related to ipfs:

TypeError: get is not a function
    at getPubsubRouter (/home/marco/webMatters/electronMatters/IPFS-Forge/.webpack/main/index.js:103294:20)
    at getLibp2pOptions (/home/marco/webMatters/electronMatters/IPFS-Forge/.webpack/main/index.js:103311:15)
    at module.exports../node_modules/ipfs-core/src/components/libp2p.js.module.exports (/home/marco/webMatters
/electronMatters/IPFS-Forge/.webpack/main/index.js:103262:25)
    at configureRepo (/home/marco/webMatters/electronMatters/IPFS-Forge/.webpack/main/index.js:107188:18)
    at async loadRepo (/home/marco/webMatters/electronMatters/IPFS-Forge/.webpack/main/index.js:107037:17)
    at async Function.start (/home/marco/webMatters/electronMatters/IPFS-Forge/.webpack/main/index.js:107018:41)
    at async Object.create (/home/marco/webMatters/electronMatters/IPFS-Forge/.webpack/main/index.js:102486:21)

This is tsconfig.json :

{
  "compilerOptions": {
    "jsx": "react",
    "allowJs": true,
    "target": "ES6",
    "module": "ESNext",
    "skipLibCheck": true,
    "esModuleInterop": true,
    "noImplicitAny": false,
    "sourceMap": true,
    "baseUrl": ".",
    "outDir": "dist",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    // https://www.typescriptlang.org/tsconfig#suppressExcessPropertyErrors
    "suppressExcessPropertyErrors": true,
    "paths": {
      "*": ["node_modules/*"],
      "@app/*": ["./src/app/*"],
      "@static/*": ["./src/static/*"],
      "@src/*": ["./src/*"]
    }
  },
  "include": ["src/**/*"]
}

This is package.json :

{
  "name": "IPFS-Forge",
  "description": "IPF-Forge",
  "version": "1.0.0",
  "main": "./.webpack/main",
  "private": true,
  "scripts": {
    "start": "electron-forge start",
    "package": "electron-forge package",
    "make": "electron-forge make",
    "publish": "electron-forge publish",
    "lint": "eslint --ext .ts ."
  },
  "repository": {
    "type": "git",
    "url": "https://github.com/raphael10-collab/IPFS-Forge"
  },
  "license": "MIT",
  "config": {
    "forge": "./tools/forge/forge.config.js"
  },
  "devDependencies": {
    "@electron-forge/cli": "^6.0.0-beta.54",
    "@electron-forge/maker-deb": "^6.0.0-beta.54",
    "@electron-forge/maker-rpm": "^6.0.0-beta.54",
    "@electron-forge/maker-squirrel": "^6.0.0-beta.54",
    "@electron-forge/maker-zip": "^6.0.0-beta.54",
    "@electron-forge/plugin-webpack": "^6.0.0-beta.54",
    "@types/react": "^17.0.1",
    "@types/react-dnd": "^3.0.2",
    "@types/react-dnd-html5-backend": "^3.0.2",
    "@types/react-dom": "^17.0.0",
    "@types/webpack-env": "^1.16.0",
    "@typescript-eslint/eslint-plugin": "^4.14.2",
    "@typescript-eslint/parser": "^4.14.2",
    "copy-webpack-plugin": "^7.0.0",
    "cross-env": "^7.0.3",
    "electron": "^11.2.2",
    "electron-rebuild": "^2.3.4",
    "eslint": "^7.19.0",
    "eslint-import-resolver-alias": "^1.1.2",
    "eslint-plugin-import": "^2.22.1",
    "eslint-plugin-react": "^7.22.0",
    "fork-ts-checker-webpack-plugin": "^6.1.0",
    "ipfs": "^0.54.1",
    "less": "^4.1.1",
    "node-loader": "^1.0.2",
    "react-hot-loader": "^4.13.0",
    "test-ipfs-example": "^2.0.3",
    "ts-loader": "^8.0.14",
    "typescript": "^4.1.3",
    "webpack": "4"
  },
  "greenkeeper": {
    "ignore": [
      "electron"
    ]
  },
  "dependencies": {
    "@hot-loader/react-dom": "^17.0.1",
    "electron-squirrel-startup": "^1.0.0",
    "ipfs-http-client": "^49.0.1",
    "ipfs-utils": "^6.0.0",
    "react": "^17.0.1",
    "react-dnd": "^11.1.3",
    "react-dnd-html5-backend": "^11.1.3"
  }
}

/tools/webpack/webpack.main.js :

module.exports = {
  /**
   * This is the main entry point for your application, it's the first file
   * that runs in the main process.
   */
  entry: ['./src/main.ts'],
  // Put your normal webpack config below here
  module: {
    rules: require('./webpack.rules'),
  },
  resolve: {
    extensions: ['.js', '.ts', '.jsx', '.tsx', '.css', '.json'],
    alias: require('./webpack.aliases'),
  },
  // https://github.com/electron/electron/issues/9920
  target: 'electron-main',
  node: {
    global: true,
    __dirname: true,
    __filename: true
  },
  externals: {
    "pouchdb": "require('pouchdb')"
  }
};

/tools/webpack/webpack.renderer.js :

* eslint-disable @typescript-eslint/no-var-requires */
const rules = require('./webpack.rules');
const plugins = require('./webpack.plugins');
const aliases = require('./webpack.aliases');

module.exports = {
  // https://github.com/electron/electron/issues/9920
  target: 'electron-renderer',
  //target: 'web',      // <-------------------------- Changing the target from electron-renderer to 'web' doesn't solve the problem
  module: {
    rules,
  },
  plugins: plugins,
  resolve: {
    extensions: ['.js', '.ts', '.jsx', '.tsx', '.css'],
    alias: {
      // React Hot Loader Patch
      'react-dom': '@hot-loader/react-dom',
      // Custom Aliases
      ...aliases,
    },
  },
};

/tools/webpack/webpack.helpers.js :

/* eslint-disable @typescript-eslint/no-var-requires */
/* eslint-disable @typescript-eslint/explicit-function-return-type */
const path = require('path');
const cwd = process.cwd();

// Creates Webpack Aliases using CWD path
const createWebpackAliases = (als) => {
  const result = {};
  for (const name in als) {
    result[name] = path.join(cwd, als[name]);
  }
  return result;
};

// Export webpack helpers
module.exports = {
  createWebpackAliases,
};

/tools/webpack/webpack.aliases.js :

// eslint-disable-next-line @typescript-eslint/no-var-requires
const { createWebpackAliases } = require('./webpack.helpers');

// Webpack aliases to resolve
const aliases = createWebpackAliases({
  '@src': 'src',
  '@app': 'src/app',
  '@static': 'src/static',
  'jsonfile': './node_modules/fs-extra/node_modules/jsonfile',
  'nanoid/random': './node_modules/nanoid',
  'nanoid/format': './node_modules/nanoid'
});

// Export aliases
module.exports = aliases;

/tools/webpack/webpack.plugins.js :

// eslint-disable-next-line @typescript-eslint/no-var-requires
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');

const webpack = require('webpack');

module.exports = [
  new ForkTsCheckerWebpackPlugin(),
  new webpack.ExternalsPlugin('commonjs', [
    'electron'
  ]),
  new webpack.ExternalsPlugin("commonjs", [
    'leveldown'
  ])
];

/tools/webpack/webpack.rules.js :

const inDev = process.env.NODE_ENV === 'development';

module.exports = [
  {
    // Add support for native node modules
    test: /\.node$/,
    use: 'node-loader',
  },
  {
    // Typescript loader
    test: /\.tsx?$/,
    exclude: /(node_modules|\.webpack)/,
    use: {
      loader: 'ts-loader',
      options: {
        transpileOnly: true,
      },
    },
  },
  {
    // CSS Loader
    test: /\.css$/,
    use: [{ loader: 'style-loader' }, { loader: 'css-loader' }],
  },
  {
    // Less loader
    test: /\.less$/,
    use: [
      { loader: 'style-loader' },
      { loader: 'css-loader' },
      { loader: 'less-loader' },
    ],
  },
  {
    // Images Loader
    test: /\.(gif|jpe?g|tiff|png|webp|bmp)$/,
    use: [
      {
        loader: 'file-loader',
        options: {
          publicPath: 'images',
          outputPath: inDev ? 'images' : './main_window/images',
        },
      },
    ],
  },
];
  • node: v14.5.0
  • O.S.: Ubuntu 18.04.4 Desktop

You can find the code here: https://github.com/raphael10-collab/IPFS-Forge
git clone -> yarn -> yarn start

@raphael10-collab raphael10-collab added the need/triage Needs initial labeling and prioritization label Feb 5, 2021
@achingbrain
Copy link
Member

This is the same issue you were having with jsonfile. Webpack is not resolving modules properly. You need to fix your webpack config. Aliasing the modules is not a solution because now your dependencies may get a version that is different to what they expect and crash at runtime.

@raphael10-collab
Copy link
Author

raphael10-collab commented Feb 5, 2021

@achingbrain
Ok. Aliasing the modules is not a solution.
What's the solution then?

@raphael10-collab
Copy link
Author

raphael10-collab commented Feb 6, 2021

@achingbrain

I removed the aliases and used instead resolve in webpack.main.js :

var path = require('path');

module.exports = {
  /**
   * This is the main entry point for your application, it's the first
 file
   * that runs in the main process.
   */
  entry: ['./src/main.ts'],
  // Put your normal webpack config below here
  module: {
    rules: require('./webpack.rules'),
  },
  resolve: {
    extensions: ['.js', '.ts', '.jsx', '.tsx', '.css', '.json'],
    modules: ['node_modules']
    //alias: require('./webpack.aliases'),
  },
  resolveLoader: {
    modules: ['node_modules'],
    mainFields: ['loader', 'main'],
  },
  target: 'electron-main',
  node: {
    global: true,
    __dirname: true,
    __filename: true
  },
};

But still get this error:

TypeError: get is not a function
    at getPubsubRouter (/home/marco/webMatters/electronMatters/IPFS-
Forge/.webpack/main/index.js:103184:20)
    at getLibp2pOptions (/home/marco/webMatters/electronMatters/IPFS-
Forge/.webpack/main/index.js:103201:15)
    at module.exports../node_modules/ipfs-core/src/components
/libp2p.js.module.exports (/home/marco/webMatters/electronMatters
/IPFS-Forge/.webpack/main/index.js:103152:25)
    at configureRepo (/home/marco/webMatters/electronMatters/IPFS-
Forge/.webpack/main/index.js:107078:18)
    at async loadRepo (/home/marco/webMatters/electronMatters/IPFS-
Forge/.webpack/main/index.js:106927:17)
    at async Function.start (/home/marco/webMatters/electronMatters
/IPFS-Forge/.webpack/main/index.js:106908:41)
    at async Object.create (/home/marco/webMatters/electronMatters
/IPFS-Forge/.webpack/main/index.js:102376:21)

@raphael10-collab
Copy link
Author

raphael10-collab commented Feb 6, 2021

@achingbrain After asking in Gitter Webpack, in Discord Electron and in StackOverflow, getting no answer and no help, I asked help also in webpack's github page where the answer, as you can see, has been:
"Open /home/marco/webMatters/electronMatters/IPFS-Forge/.webpack/main/index.js file and fix the problem"
webpack/webpack#12611 (comment)

Webpack people posted also this link:

jprichardson/node-jsonfile#140

which says : "jsonfile is not for use in the browser; only in Node or Electron."

Might be related to this problem?

I'm here again, because I do not know how to fix the problem.
Looking forward to your kind help

@achingbrain
Copy link
Member

Starting a new project with npx create-electron-app my-new-app --template=typescript-webpack and added IPFS to it. In main.ts I start an IPFS node, I'm greeted with:

Error: Module build failed (from ./node_modules/@marshallofsound/webpack-asset-relocator-loader/dist/index.js):
SyntaxError: Unexpected token (85:14)
    at Object.module.exports.pp$4.raise (/Users/alex/Documents/Workspaces/achingbrain/ipfs-electron-forge/node_modules/@marshallofsound/webpack-asset-relocator-loader/dist/index.js:20834:13)
// some lines omitted
    at Object.parseExprAtom (/Users/alex/Documents/Workspaces/achingbrain/ipfs-electron-forge/node_modules/@marshallofsound/webpack-asset-relocator-loader/dist/index.js:4551:117)
    at Object../node_modules/fs-extra/lib/mkdirs/make-dir.js (/Users/alex/Documents/Workspaces/achingbrain/ipfs-electron-forge/.webpack/main/index.js:76966:7)
    at __webpack_require__ (/Users/alex/Documents/Workspaces/achingbrain/ipfs-electron-forge/.webpack/main/index.js:21:30)
    at Object../node_modules/fs-extra/lib/mkdirs/index.js (/Users/alex/Documents/Workspaces/achingbrain/ipfs-electron-forge/.webpack/main/index.js:76943:44)
    at __webpack_require__ (/Users/alex/Documents/Workspaces/achingbrain/ipfs-electron-forge/.webpack/main/index.js:21:30)
    at Object../node_modules/fs-extra/lib/copy-sync/copy-sync.js (/Users/alex/Documents/Workspaces/achingbrain/ipfs-electron-forge/.webpack/main/index.js:75881:20)
    at __webpack_require__ (/Users/alex/Documents/Workspaces/achingbrain/ipfs-electron-forge/.webpack/main/index.js:21:30)
    at Object../node_modules/fs-extra/lib/copy-sync/index.js (/Users/alex/Documents/Workspaces/achingbrain/ipfs-electron-forge/.webpack/main/index.js:76058:13)
    at __webpack_require__ (/Users/alex/Documents/Workspaces/achingbrain/ipfs-electron-forge/.webpack/main/index.js:21:30)
    at Object../node_modules/fs-extra/lib/index.js (/Users/alex/Documents/Workspaces/achingbrain/ipfs-electron-forge/.webpack/main/index.js:76809:6)
    at __webpack_require__ (/Users/alex/Documents/Workspaces/achingbrain/ipfs-electron-forge/.webpack/main/index.js:21:30)

If I click through the stack trace, eventually in /Users/alex/Documents/Workspaces/achingbrain/ipfs-electron-forge/.webpack/main/index.js on line 76966 I find:

/***/ "./node_modules/fs-extra/lib/mkdirs/make-dir.js":
/*!******************************************************!*\
  !*** ./node_modules/fs-extra/lib/mkdirs/make-dir.js ***!
  \******************************************************/
/*! no static exports found */
/***/ (function(module, exports) {

throw new Error("Module build failed (from ./node_modules/@marshallofsound/webpack-asset-relocator-loader/dist/index.js):\nSyntaxError: Unexpected token (85:14)\n    at Object.module.exports.pp$4.raise (/Users/alex/Documents/Workspaces/achingbrain/ipfs-electron-forge/node_modules/@marshallofsound/webpack-asset-relocator-loader/dist/index.js:20834:13)\n    at Object.module.exports.pp.unexpected (/Users/alex/Documents/Workspaces/achingbrain/ipfs-electron-forge/node_modules/@marshallofsound/webpack-asset-relocator-loader/dist/index.js:18680:8)\n    at Object.module.exports.pp$1.parseTryStatement (/Users/alex/Documents/Workspaces/achingbrain/ipfs-electron-forge/node_modules/@marshallofsound/webpack-asset-relocator-loader/dist/index.js:19069:49)\n    at Object.module.exports.pp$1.parseStatement *snip*");

The error being thrown contains the stack trace that's printed out when I npm start the project.

So ./node_modules/fs-extra/lib/mkdirs/make-dir.js has a syntax error on line 85. Looking at line 85 of make-dir.js at v9.10, it's using Optional Catch Binding, which appears in ECMAScript2019. ECMAScript2019 is otherwise known as ES10

@marshallofsound/webpack-asset-relocator-loader contains an JavaScript AST parser and is a fork of @vercel/webpack-asset-relocator-loader - the fork is now very out of date. It looks like the fork should be able to support ES10 but it defaults to ES9 and doesn't seem to expose an option to change that. If I change the default in the generated source it crashes somewhere else so it's ES10 support may not be fully implemented, I don't know.

The upstream version supports ES2020 so likely would understand the Optional Catch Binding syntax.

So your options are:

  1. Stop using webpack
  2. Convince the maintainer of @marshallofsound/webpack-asset-relocator-loader to update their fork and re-apply their patch if it's still necessary

@raphael10-collab
Copy link
Author

Thank you @achingbrain Alex for this thoughrough analysis.

Despite of being outdated and being declared to be not that reliable by its author , as I read in a github thread which you showed me during our frequent "meetings" here for my problems, @marshallofsound/webpack-asset-relocator-loader is still included within electron-forge package.

I see here: electron/forge#1643 that others having this kind of issues with asset relocator.

But discovered that even after removing @marshallofsound/webpack-asset-relocator-loader I still have problems : https://github.com/webpack/webpack/issues

I was actually thinking to stop using webpack, but, since the project I'm working on is not a small project, I still need a bundler to keep eveything .

I'm going to report, linking to your good analysis, these findings in the webpack's github issue /question I opened yesterday, in the electron-forge's github page, and in discord's Electron forum, hoping that someone will come up in trying to solve the problem.

I ask you if you can keep this issue open in order to be able to understand how to solve the problem.

@achingbrain
Copy link
Member

I was actually thinking to stop using webpack, but, since the project I'm working on is not a small project, I still need a bundler to keep eveything .

You could just use webpack for the renderer, and use normal js for the main process. Run IPFS on the main process and use IPC to send data back and forth. That way you wouldn't need run any node modules through webpack and most of your problems will go away. VSCode will give you type integration for modules that publish type definitions, so you get the type-safety of TypeScript with less verbose syntax.

I ask you if you can keep this issue open in order to be able to understand how to solve the problem.

No, this issue will remain closed. This is the js-IPFS repo, for discussing issues around js-IPFS, and the problem you have has nothing to do with js-IPFS.

@raphael10-collab
Copy link
Author

raphael10-collab commented Feb 8, 2021

Commenting the main process webpack configuration in forge.config.js :

/* eslint-disable @typescript-eslint/no-var-requires */
// Forge Configuration
const path = require('path');
const rootDir = process.cwd();

module.exports = {
  // Packager Config
  packagerConfig: {
    // Create asar archive for main, renderer process files
    asar: true,
  },
  // Forge Makers
  makers: [
    {
      // Squirrel.Windows is a no-prompt, no-hassle, no-admin method of installing
      // Windows applications and is therefore the most user friendly you can get.
      name: '@electron-forge/maker-squirrel',
      config: {
        name: 'electron-react-typescript-webpack-2021',
      },
    },
    {
      // The Zip target builds basic .zip files containing your packaged application.
      // There are no platform specific dependencies for using this maker and it will run on any platform.
      name: '@electron-forge/maker-zip',
      platforms: ['darwin'],
    },
    {
       // The deb target builds .deb packages, which are the standard package format for Debian-based
      // Linux distributions such as Ubuntu.
      name: '@electron-forge/maker-deb',
      config: {},
    },
    {
      // The RPM target builds .rpm files, which is the standard package format for
      // RedHat-based Linux distributions such as Fedora.
      name: '@electron-forge/maker-rpm',
      config: {},
    },
  ],
  // Forge Plugins
  plugins: [
    [
      // The Webpack plugin allows you to use standard Webpack tooling to compile both your main process code
      // and your renderer process code, with built in support for Hot Module Reloading in the renderer
      // process and support for multiple renderers.
      '@electron-forge/plugin-webpack',
      {
        // Main process webpack configuration
        //mainConfig: path.join(rootDir, 'tools/webpack/webpack.main.js'),
        // Renderer process webpack configuration
        renderer: {
          // Configuration file path
          config: path.join(rootDir, 'tools/webpack/webpack.renderer.js'),
          // Entrypoints of the application
          entryPoints: [
            {
              // React Hot Module Replacement (HMR)
              rhmr: 'react-hot-loader/patch',
              // HTML index file template
              html: path.join(rootDir, 'src/index.html'),
              // Renderer
              js: path.join(rootDir, 'src/renderer.ts'),
              // Main Window
              name: 'main_window',
              // Preload
              preload: {
                js: path.join(rootDir, 'src/preload.ts'),
              },
            },
          ],
        },
      },
    ],
  ],
};

gives this error:

(base) marco@pc01:~/webMatters/electronMatters/Ipfs-Webpack$ yarn start
yarn run v1.22.5
$ cross-env NODE_ENV=development electron-forge start
✔ Checking your system
✔ Locating Application
✔ Preparing native dependencies
✖ Compiling Main Process Code

An unhandled error has occurred inside Forge:
Cannot read property 'entry' of undefined
TypeError: Cannot read property 'entry' of undefined
    at WebpackConfigGenerator.getMainConfig (/home/marco/webMatters/electronMatters/Ipfs-Webpack/node_modules
/@electron-forge/plugin-webpack/src/WebpackConfig.ts:127:21)
    at asyncFn (/home/marco/webMatters/electronMatters/Ipfs-Webpack/node_modules/@electron-forge/plugin-webpack
/src/WebpackPlugin.ts:234:53)
    at /home/marco/webMatters/electronMatters/Ipfs-Webpack/node_modules/@electron-forge/async-ora/src/ora-
handler.ts:35:5
    at new Promise (<anonymous>)
    at asyncOra (/home/marco/webMatters/electronMatters/Ipfs-Webpack/node_modules/@electron-forge/async-ora/src/ora-
handler.ts:34:10)
    at WebpackPlugin.compileMain (/home/marco/webMatters/electronMatters/Ipfs-Webpack/node_modules/@electron-
forge/plugin-webpack/src/WebpackPlugin.ts:233:11)
    at WebpackPlugin.startLogic (/home/marco/webMatters/electronMatters/Ipfs-Webpack/node_modules/@electron-
forge/plugin-webpack/src/WebpackPlugin.ts:348:16)
    at forgeSpawn (/home/marco/webMatters/electronMatters/Ipfs-Webpack/node_modules/@electron-forge/core/src/api
/start.ts:60:32)
    at forgeSpawnWrapper (/home/marco/webMatters/electronMatters/Ipfs-Webpack/node_modules/@electron-forge/core
/src/api/start.ts:121:21)
    at /home/marco/webMatters/electronMatters/Ipfs-Webpack/node_modules/@electron-forge/cli/src/electron-forge-
start.ts:58:19

As far as I understand from the electron-forge docs: https://www.electronforge.io/config/plugins/webpack it's not envisaged skipping mainConfig: './webpack.main.config.js' .
https://js.electronforge.io/plugin/webpack/interfaces/webpackpluginconfig#mainconfig

So should I stop using Electron-Forge all together?

@deanpress
Copy link

I currently have the exact same issue with a fresh Sapper (https://github.com/sveltejs/sapper-template-webpack) project:

Uncaught (in promise) TypeError: get is not a function
    at getPubsubRouter (libp2p.js:60)

Webpack config:

const webpack = require('webpack');
const WebpackModules = require('webpack-modules');
const path = require('path');
const config = require('sapper/config/webpack.js');
const pkg = require('./package.json');
const appConfig = require('./config.json');

const mode = process.env.NODE_ENV;
const dev = mode === 'development';

const alias = { svelte: path.resolve('node_modules', 'svelte') };
const extensions = ['.mjs', '.js', '.json', '.svelte', '.html'];
const mainFields = ['svelte', 'module', 'browser', 'main'];
const fileLoaderRule = {
	test: /\.(png|jpe?g|gif)$/i,
	use: [
		'file-loader',
	]
};

module.exports = {
	client: {
		entry: config.client.entry(),
		output: output,
		resolve: { alias, extensions, mainFields },
		module: {
			rules: [
				{
					test: /\.(svelte|html)$/,
					use: {
						loader: 'svelte-loader-hot',
						options: {
							dev,
							hydratable: true,
							emitCss: false,
							hotReload: true // pending https://github.com/sveltejs/svelte/issues/2377
						}
					}
				},
				fileLoaderRule
			]
		},
		mode,
		plugins: [
			new webpack.DefinePlugin({
				'process.browser': true,
				'process.env.NODE_ENV': JSON.stringify(mode),
				'process.env.CONFIG': JSON.stringify(appConfig),
			}),
		].filter(Boolean),
		devtool: dev && 'inline-source-map'
	},

	server: {
		entry: config.server.entry(),
		output: config.server.output(),
		target: 'node',
		resolve: { alias, extensions, mainFields },
		externals: Object.keys(pkg.dependencies).concat('encoding'),
		module: {
			rules: [
				{
					test: /\.(svelte|html)$/,
					use: {
						loader: 'svelte-loader-hot',
						options: {
							css: false,
							generate: 'ssr',
							hydratable: true,
							dev,
							emitCss: false
						}
					}
				},
				fileLoaderRule
			]
		},
		mode,
		plugins: [
			new webpack.DefinePlugin({
				'process.browser': false,
				'process.env.NODE_ENV': JSON.stringify(mode),
				'process.env.CONFIG': JSON.stringify(appConfig),
			}),
			new WebpackModules(),
		],
		performance: {
			hints: false // it doesn't matter if server.js is large
		}
	},

	serviceworker: {
		entry: config.serviceworker.entry(),
		output: config.serviceworker.output(),
		mode
	}
};

@rakeshbhatt10
Copy link

@raphael10-collab Is this issue resolved as I am facing the same issue while using webpack.or you have switched to any other alternate.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
need/triage Needs initial labeling and prioritization
Projects
None yet
Development

No branches or pull requests

4 participants