react-notion-x
react-notion-x copied to clipboard
Webpack build can't resolve p-queue or mem
Description
Webpack 4 builds throw can't resolve p-queue and mem in node_modules/notion-utils/build
Example repo (fork and run): https://replit.com/@nathanwaters3/Reactjs-Babel-Webpack-Boilerplate#src/App.js
In that Repl it only throws p-queue error but in local build it also throws mem "can't resolve" error.
Notion Test Page ID
In code
Fixed it with an override for now. The problem is p-queue and mem are not exported properly...
import PQueue from 'p-queue'
should be import PQueue from 'p-queue/dist'
import mem from 'mem'
should be import mem from 'mem/dist'
https://github.com/NotionX/react-notion-x/blob/master/packages/notion-utils/src/get-all-pages-in-space.ts https://github.com/NotionX/react-notion-x/blob/master/packages/notion-compat/src/notion-compat-api.ts https://github.com/NotionX/react-notion-x/blob/master/packages/notion-utils/src/normalize-url.ts
@nathanwaters have you published this somewhere in NPM?
@ramatronics nah I'll leave that to the maintainer. Probably a much better way to do this but here's what I did...
- Copy the code in
node_modules/notion-utils/build/index.js
- Paste somewhere like
src/overrides/notionUtils.js
- Change
import K from 'p-queue'
toimport K from 'p-queue/dist'
- Change
import ee from 'mem'
toimport ee from 'mem/dist'
- In your webpack config add something like this...
resolve: {
alias: {
'notion-utils': path.resolve(
__dirname,
'src/overrides/notionUtils'
),
},
},
Same problem here using Webpack 5.73.0. Any solution for now?