I am importing two modules from the same package.
import { RowSelection } from "gridjs/plugins/selection";
import { Grid } from "gridjs";
I can access RowSelection in VSCode (e.g. by go to definition) just fine. Intellisense is working fine too. Therefore the module definition seems okay.
My issue is that webpack is successful for Grid but fails for RowSelection with the following error message:
Module not found: Error: Can't resolve 'gridjs/plugins/selection' in 'C:\workspace\src'
The error message is correct as well. The module definitely does not exist in the mentioned path. It is in '../node_modules/gridjs/plugins/selection'.
I don't understand, why it is not searching in the node modules directory the same way as it is doing for Grid though.
Why is RowSelection resolved differently than Grid and what can I do to fix this issue?
This is my webpack configuration:
const webpackMerge = require("webpack-merge");
const baseDashboardConfig =
require("@splunk/webpack-configs/dashboard.config").default;
const baseConfig = require("@splunk/webpack-configs").default;
module.exports = webpackMerge(baseConfig, {
entry: "./src/details_dialog.js",
output: {
path: __dirname,
filename: "details_dialog.js",
},
module: {
rules: [
{
test: /\.css$/,
//exclude: [/node_modules/],
use: [
{
loader: "style-loader",
},
{
loader: "css-loader",
},
],
},
],
},
});
CodePudding user response:
The only thing that comes to mind is that you've not included .tsx files with your .ts files in your base webpack config? The clue is that the source file for rowSelection is rowSelection.tsx (error) and gridjs is gridjs.ts (no error). That might explain the error message since rowSeletion.tsx is not getting transpiled by webpack, and therefore cannot be found in the src folder.
CodePudding user response:
Apparently this is not in issue with my configuration but has been reported as an issue with gridjs (https://github.com/grid-js/gridjs/issues/969)