jakearchibald / idb

IndexedDB, but with promises
https://www.npmjs.com/package/idb
ISC License
6.29k stars 353 forks source link

webpack3 not run, How to configure? #195

Closed sujiewen closed 4 years ago

sujiewen commented 4 years ago

Module parse failed: Unexpected token (78:4) You may need an appropriate loader to handle this file type. | } | replaceTraps((oldTraps) => ({ | ...oldTraps, | get: (target, prop, receiver) => getMethod(target, prop) || oldTraps.get(target, prop, receiver), | has: (target, prop) => !!getMethod(target, prop) || oldTraps.has(target, prop),

ram2104 commented 3 years ago

Hey, How did you fix this issue? Even I'm using Webpack3 and facing the same issue

jjtfsalgado commented 3 years ago

Me too, how did you guys managed to fix this?

cmngo commented 3 years ago

same problem ,how to fix it ?

e-simpson commented 2 years ago

Same issue

jakearchibald commented 2 years ago

If folks are still encountering this, please open a new issue with a reduced reproduction of the issue. Saying "not work" is not enough. Give me a few reproducible steps to recreate the issue you're seeing.

e-simpson commented 2 years ago

I followed this React AWS Amplify Auth tutorial. After running npm install aws-amplify @aws-amplify/ui-react and attempting to compile I received the error:

node_modules/idb/build/esm/index.js

Module parse failed: Unexpected token (78:4) You may need an appropriate loader to handle this file type. replaceTraps((oldTraps) => ({ ...oldTraps, get: (target, prop, receiver) => getMethod(target, prop) || oldTraps.get(target, prop, receiver), has: (target, prop) => !!getMethod(target, prop) || oldTraps.has(target, prop), }));

The usual npm/yarn troubleshooting didn't work. I was able to fix this by completely restarting with a new react app. I'm not sure if this is related, however, the only difference between the working and non-working app was that the non-working setup's file path contained a folder name that used non-alpha characters. Not sure how this could affect localized node_modules but that was the only thing I changed and found that it worked.

jakearchibald commented 2 years ago

It sounds like the JS parser is out of date. Webpack 3 is pretty old now.

You might be able to use babel as a loader so it transcodes the modern JS to something old webpack understands.