react-notion-x icon indicating copy to clipboard operation
react-notion-x copied to clipboard

Webpack build can't resolve p-queue or mem

Open nathanwaters opened this issue 2 years ago • 3 comments

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

nathanwaters avatar Aug 05 '22 08:08 nathanwaters

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 avatar Aug 06 '22 06:08 nathanwaters

@nathanwaters have you published this somewhere in NPM?

rxmie24 avatar Aug 09 '22 00:08 rxmie24

@ramatronics nah I'll leave that to the maintainer. Probably a much better way to do this but here's what I did...

  1. Copy the code in node_modules/notion-utils/build/index.js
  2. Paste somewhere like src/overrides/notionUtils.js
  3. Change import K from 'p-queue' to import K from 'p-queue/dist'
  4. Change import ee from 'mem' to import ee from 'mem/dist'
  5. In your webpack config add something like this...
  resolve: {
    alias: {
      'notion-utils': path.resolve(
        __dirname,
        'src/overrides/notionUtils'
      ),
    },
  },

nathanwaters avatar Aug 09 '22 01:08 nathanwaters

Same problem here using Webpack 5.73.0. Any solution for now?

alfonsograziano avatar Dec 08 '22 08:12 alfonsograziano