Skip to content

[V8] You may need an additional loader to handle the result of these loaders #4500

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
2 tasks done
samyan opened this issue Nov 2, 2022 · 25 comments
Closed
2 tasks done
Labels
critical Issues or bugs that are highly critical and must be solved as soon as possible.

Comments

@samyan
Copy link

samyan commented Nov 2, 2022

Describe the bug

I'm trying to run react app with your library but I get runtime error:

./node_modules/@tanstack/react-table/build/umd/index.production.js 106:18
Module parse failed: Unexpected token (106:18)
File was processed with these loaders:
 * ./node_modules/babel-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
|           i = l.accessorKey;
|     let r,
>         a = l.id ?? (i ? i.replace(".", "_") : void 0) ?? ("string" == typeof l.header ? l.header : void 0);
|     if (l.accessorFn ? r = l.accessorFn : i && (r = i.includes(".") ? e => {
|       let t = e;

Your minimal, reproducible example

localhost

Steps to reproduce

This is my npm package:

├── @tanstack/[email protected]
├── @types/[email protected]
├── @types/[email protected]
├── @types/[email protected]
├── @types/[email protected]
├── @types/[email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]

My code:

const table = useReactTable({
	data,
	columns,
	getCoreRowModel: getCoreRowModel()
});

return (
	<div className='p-2'>
		<table>
			<thead>
				{table.getHeaderGroups().map((headerGroup) => (
					<tr key={headerGroup.id}>
						{headerGroup.headers.map((header) => (
							<th key={header.id}>
								{header.isPlaceholder ? null : flexRender(header.column.columnDef.header, header.getContext())}
							</th>
						))}
					</tr>
				))}
			</thead>
			<tbody>
				{table.getRowModel().rows.map((row) => (
					<tr key={row.id}>
						{row.getVisibleCells().map((cell) => (
							<td key={cell.id}>{flexRender(cell.column.columnDef.cell, cell.getContext())}</td>
						))}
					</tr>
				))}
			</tbody>
			<tfoot>
				{table.getFooterGroups().map((footerGroup) => (
					<tr key={footerGroup.id}>
						{footerGroup.headers.map((header) => (
							<th key={header.id}>
								{header.isPlaceholder ? null : flexRender(header.column.columnDef.footer, header.getContext())}
							</th>
						))}
					</tr>
				))}
			</tfoot>
		</table>
	</div>
);

Expected behavior

Get result.

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

Windows 11 // Node v16.151

react-table version

v8.5.22

TypeScript version

v4.2.3

Additional context

No response

Terms & Code of Conduct

  • I agree to follow this project's Code of Conduct
  • I understand that if my bug cannot be reliable reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.
@samyan samyan changed the title [Error] You may need an additional loader to handle the result of these loaders [V8] You may need an additional loader to handle the result of these loaders Nov 2, 2022
@gear4s
Copy link

gear4s commented Nov 2, 2022

this issue was first introduced in 8.5.15 - we are currently using 8.5.13 to build our front-end

@samyan
Copy link
Author

samyan commented Nov 2, 2022

this issue was first introduced in 8.5.15 - we are currently using 8.5.13 to build our front-end

I will try with 8.5.13. Thanks for response.

@samyan
Copy link
Author

samyan commented Nov 2, 2022

Working with 8.5.13 for now as @gear4s suggested. Any idea when will be fixed?

@gear4s
Copy link

gear4s commented Nov 2, 2022

try to change your browser targets from this:

"browserslist": {
   "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
},

to this:

"browserslist": [
   ">0.2%",
  "not dead",
  "not op_mini all"
],

it could also be an issue with your version of React-Scripts not supporting Babel version that implements the ?? operator - try to update to [email protected] too

@samyan
Copy link
Author

samyan commented Nov 2, 2022

try to change your browser targets from this:

"browserslist": {
   "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
},

to this:

"browserslist": [
   ">0.2%",
  "not dead",
  "not op_mini all"
],

it could also be an issue with your version of React-Scripts not supporting Babel version that implements the ?? operator - try to update to [email protected] too

I've tried browserslist already but no luck. About react-scripts version, maybe. I will try later and write you. Thanks!

@nrayburn-tech
Copy link

Your issue is likely due to how Create React App processes dependency code, here is an issue from that repo with a more detailed explanation.

facebook/create-react-app#11339 (comment)

@KevinVandy KevinVandy added the critical Issues or bugs that are highly critical and must be solved as soon as possible. label Nov 16, 2022
@patrickgalbraith
Copy link
Contributor

patrickgalbraith commented Nov 17, 2022

I had this same issue when using v8 with Storybook. Fix was to extend the Storybook webpack config to process react-table.

.storybook/main.js

const nodeModulesThatNeedToBeParsedBecauseTheyExposeES6 = [
  '@tanstack[\\\\/]react-table',
];

module.exports = {
  // ...
  webpackFinal: async (config) => {
    return {
      ...config,
      module: {
        ...config.module,
        rules: config.module.rules.map((rule) => {
          if (rule.test.toString() !== String(/\.js$/)) return rule;

          const include = new RegExp(
            `[\\\\/]node_modules[\\\\/](${nodeModulesThatNeedToBeParsedBecauseTheyExposeES6.join(
              '|'
            )})`
          );

          if (Array.isArray(rule.include)) {
            rule.include.push(include);
          } else {
            rule.include = [rule.include, include].filter(Boolean);
          }

          return rule;
        }),
      },
    };
  },

@KevinVandy
Copy link
Member

@samyan @gear4s @patrickgalbraith Try out the newest TanStack Table v8.7.0 and let us know if you are still running into problems here

We think PR #4552 should have fixed this issue.

@samyan
Copy link
Author

samyan commented Nov 24, 2022

@samyan @gear4s @patrickgalbraith Try out the newest TanStack Table v8.7.0 and let us know if you are still running into problems here

We think PR #4552 should have fixed this issue.

Working perfect! Thank you.

@patrickgalbraith
Copy link
Contributor

@KevinVandy 8.7.0 works great!

However I tried v8.7.3 and the issue has returned, was there a regression recently?

@patrickgalbraith
Copy link
Contributor

Error I'm getting in 8.7.3

ERROR in ./node_modules/@tanstack/react-table/build/lib/index.esm.js 64:28
Module parse failed: Unexpected token (64:28)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
|     onStateChange: updater => {
|       setState(updater);
>       options.onStateChange?.(updater);
|     }
|   }));

@KevinVandy
Copy link
Member

Error I'm getting in 8.7.3

ERROR in ./node_modules/@tanstack/react-table/build/lib/index.esm.js 64:28
Module parse failed: Unexpected token (64:28)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
|     onStateChange: updater => {
|       setState(updater);
>       options.onStateChange?.(updater);
|     }
|   }));

There have been no code changes pretty much between 8.7.0 and 8.7.3, which is making this hard to figure out why it is happening

@marwen-cherif
Copy link

marwen-cherif commented Dec 16, 2022

Personally i've rollback to version 8.5.11 allowed me to get arround the problem.

it seems that the problem was introduced between 8.512 and 8.5.30

8.5.30 => KO
8.7.3 => KO
8.5.11 => OK

@vishal-rathod-07
Copy link

Error I'm getting in 8.7.3

ERROR in ./node_modules/@tanstack/react-table/build/lib/index.esm.js 64:28
Module parse failed: Unexpected token (64:28)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
|     onStateChange: updater => {
|       setState(updater);
>       options.onStateChange?.(updater);
|     }
|   }));

I am also getting same error.

I am using "react-scripts": "3.0.1" and "@tanstack/react-table": "8.7.2".

any solution without changing browserlist.

@valentinkorzun
Copy link

Error I'm getting in 8.7.3

ERROR in ./node_modules/@tanstack/react-table/build/lib/index.esm.js 64:28
Module parse failed: Unexpected token (64:28)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
|     onStateChange: updater => {
|       setState(updater);
>       options.onStateChange?.(updater);
|     }
|   }));

I am also getting same error.

I am using "react-scripts": "3.0.1" and "@tanstack/react-table": "8.7.2".

any solution without changing browserlist.

I also have this error. Any updates?

@ivanov-v
Copy link

Error with 8.7.2. Maybe reopen issue?

@ellisPae
Copy link

Error I'm getting in 8.7.3

ERROR in ./node_modules/@tanstack/react-table/build/lib/index.esm.js 64:28
Module parse failed: Unexpected token (64:28)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
|     onStateChange: updater => {
|       setState(updater);
>       options.onStateChange?.(updater);
|     }
|   }));

I am also getting same error.

I am using "react-scripts": "3.0.1" and "@tanstack/react-table": "8.7.2".

any solution without changing browserlist.

I'm getting the same exact issue on 8.7.4

@gear4s
Copy link

gear4s commented Dec 30, 2022

@KevinVandy I'm sure that the issues are related to the react-scripts these guys are using. what finally, really fixed the issue for us, was upgrading from [email protected] to [email protected]. what would likely have triggered this to arise is a change to the build process.

@ellisPae @valentinkorzun @vishal-rathod-07 could you try to update react-scripts first?

@WilsonCWong
Copy link

WilsonCWong commented Jan 4, 2023

Having the same issue with [email protected] and @tanstack/[email protected].

EDIT: Downgrading to 8.7.0 fixes it.

@vishal-rathod-07
Copy link

@gear4s Updating [email protected] works for me thanks 👍🏻.

@netdesignr
Copy link

netdesignr commented Jan 5, 2023

Downgrading to 8.7.0 it solved the issue. The issue will also disappear if switching to Webpack 5, but it's not an option for the project I work on.

@patrickgalbraith
Copy link
Contributor

patrickgalbraith commented Jan 8, 2023

Something has obviously changed when the package is built:

// v8.7.0
onStateChange: updater => {
  setState(updater);
  options.onStateChange == null ? void 0 : options.onStateChange(updater);
}

// v8.7.4 (official)
onStateChange: updater => {
  setState(updater);
  options.onStateChange?.(updater);
}

// v8.7.4 (local build with YARN install)
onStateChange: updater => {
  setState(updater);
  options.onStateChange == null ? void 0 : options.onStateChange(updater);
}

@KevinVandy if I do a build locally and install using npm then I get the result from v8.7.4 BUT if I install using yarn then I get the correct result. You have a yarn.lock but you don't have a package-lock.json so when you do the build locally it is correct but the CI builds are using npm install which will pull the latest dependencies. So you may want to use yarn when doing the install in your Github CI config or add a package-lock.

I'm guessing this is because of changes to @babel/preset-env. You could probably just add a include for @babel/plugin-proposal-optional-chaining.

@oneblockchain
Copy link

try to change your browser targets from this:

"browserslist": {
   "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
},

to this:

"browserslist": [
   ">0.2%",
  "not dead",
  "not op_mini all"
],

it could also be an issue with your version of React-Scripts not supporting Babel version that implements the ?? operator - try to update to [email protected] too

This works for me, thanks!

@KevinVandy
Copy link
Member

@oneblockchain this should no longer be necessary in the latest version of table though

@mnickolay
Copy link

The solution to this issue for me was multiple version for acorn were being pulled in as dependencies for other packages like webpack and ts-node. I ended up with 6.4.2, 7.4.1, and 8.8.2.

I just added the appropriate resolution in my package.json:

"resolutions": {
    "acorn": "^8.5.0"
},

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
critical Issues or bugs that are highly critical and must be solved as soon as possible.
Projects
None yet
Development

No branches or pull requests