You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
WARNING in No instantiations of threads.js workers found.
Please check that:
1. You have configured Babel / TypeScript to not transpile ES modules
2. You import `Worker` from `threads` where you use it
my webpack
constlodash=require("lodash");constCopyPlugin=require("copy-webpack-plugin");constHtmlWebpackPlugin=require("html-webpack-plugin");constThreadsPlugin=require("threads-plugin");constpath=require("path");constwebpack=require("webpack");functionsrcPaths(src){returnpath.join(__dirname,src);}constisEnvProduction=process.env.NODE_ENV==="production";constisEnvDevelopment=process.env.NODE_ENV==="development";// #region Common settingsconstcommonConfig={devtool: isEnvDevelopment ? "source-map" : false,mode: isEnvProduction ? "production" : "development",output: {path: srcPaths("dist")},devServer: {port: 8080,contentBase: srcPaths("dist"),writeToDisk: true,hot: true,open: true,},node: {__dirname: false,__filename: false},resolve: {alias: {_: srcPaths("src"),_main: srcPaths("src/main"),_models: srcPaths("src/models"),_public: srcPaths("public"),_renderer: srcPaths("src/renderer"),_utils: srcPaths("src/utils"),},extensions: [".js",".json",".ts",".tsx"],},module: {rules: [{test: /\.js$/,include: srcPaths("src"),use: ["thread-loader",// your expensive loader (e.g babel-loader)],},{test: /\.(ts|tsx|js)$/,exclude: /node_modules/,loader: "ts-loader",},{test: /\.(scss|css)$/,use: ["style-loader","css-loader","sass-loader"],},{test: /\.(jpg|png|svg|ico|icns)$/,loader: "file-loader",options: {name: "[path][name].[ext]",},},],},plugins: [newThreadsPlugin({target: "electron-node-worker",globalObject: "self",plugins: [// A string here will copy the named plugin from your configuration:"HtmlWebpackPlugin",],}),],};// #endregionconstmainConfig=lodash.cloneDeep(commonConfig);mainConfig.entry="./src/main/main.ts";mainConfig.target="electron-main";mainConfig.output.filename="main.bundle.js";mainConfig.plugins=[
...mainConfig.plugins,newCopyPlugin({patterns: [{from: "package.json",to: "package.json",transform: (content,_path)=>{// eslint-disable-line no-unused-varsconstjsonContent=JSON.parse(content);deletejsonContent.devDependencies;deletejsonContent.scripts;deletejsonContent.build;jsonContent.main="./main.bundle.js";jsonContent.scripts={start: "electron ./main.bundle.js"};jsonContent.postinstall="electron-builder install-app-deps";returnJSON.stringify(jsonContent,undefined,2);},},],}),newwebpack.HotModuleReplacementPlugin(),];constrendererConfig=lodash.cloneDeep(commonConfig);rendererConfig.entry=["react-hot-loader/patch","./src/renderer/renderer.tsx",];rendererConfig.target="electron-renderer";rendererConfig.output.filename="renderer.bundle.js";rendererConfig.plugins=[
...rendererConfig.plugins,newwebpack.HotModuleReplacementPlugin(),newHtmlWebpackPlugin({template: path.resolve(__dirname,"./public/index.html"),}),];module.exports=[mainConfig,rendererConfig];
Based on your sample code you are instantiating new Worker(…) without having imported the threads.js Worker import { Worker } from "threads". The webpack plugin will only handle worker instantiations of threads.js' Workers.
getting the warning
my webpack
How im calling threads
and my worker
The issue is it it seems like it's not searching or compiling and searching correctly since this is the error
Cannot find module '/dist/workers/worker-scripts.ts'
The text was updated successfully, but these errors were encountered: