Skip to content
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

Remove the need for require ('util') in browser environment #718

Open
majkelch opened this issue Oct 11, 2021 · 4 comments
Open

Remove the need for require ('util') in browser environment #718

majkelch opened this issue Oct 11, 2021 · 4 comments

Comments

@majkelch
Copy link

I would like to use Sanctuary with Vue 3.x (Composition API), Vite (2.6.x) and Yarn 3.x. Vite runs without problem, but when navigating to any page, I am running into error from Either/index.js:

var custom = util.inspect.custom; TypeError: Cannot read properties of undefined (reading 'custom')

My usage of Sanctuary looks like this api.utils.js:

import * as S from 'sanctuary'
export const processData = ({ data }) => S.pipe ([ S.head, S.props(['value', 'result']) ]) (data.rows)

From our discussion on glitter, recommended solution would be:
The long-term fix is to update Sanctuary to use Symbol.for ('nodejs.util.inspect.custom'), obviating the need for require ('util'), circumventing this issue.

@davidchambers
Copy link
Member

This issue is related to sanctuary-js/sanctuary-def#300.

@dotnetCarpenter
Copy link

@majkelch A work-around until there is a new Sanctuary release is to point to the latest commit on github.com in package.json.

In the beginning of January I got it working with the following commits:

  "dependencies": {
    "fluture": "^14.0.0",
    "fluture-sanctuary-types": "^7.1.0",
    "sanctuary": "sanctuary-js/sanctuary#fd5a923db69bba0c8f265a3aef3c413be0e00933",
    "sanctuary-def": "dotnetCarpenter/sanctuary-def#f1ad60190245247b5a6df8518686fe345bb6c7ee",
    "sanctuary-either": "sanctuary-js/sanctuary-either#dc183e2952b62d60d8921b44b0ea2090787e0a12",
    "sanctuary-maybe": "sanctuary-js/sanctuary-maybe#b84c101889c12bb9631151f0cdf06c5502e5f31c",
    "sanctuary-pair": "sanctuary-js/sanctuary-pair#93f915932d49f64542088bbfdd25ec63b31c8141",
    "sanctuary-show": "sanctuary-js/sanctuary-show#aab1fa59a2abdd8b4a82c64c2ba58471bbbe2123",
    "sanctuary-type-classes": "sanctuary-js/sanctuary-type-classes#1d97129d9e66509a2867ec680faa374afc0cbad1"
  },

@ken-okabe
Copy link

Since this library doesn't seriously support modern browser environment or modern import syntax that works on Node.js nowadays, I copy and paste the source code to use as my own ESM.

@davidchambers
Copy link
Member

We're (slowly) working towards converting the many Sanctuary projects to ES modules, @stken2050. :)

Would you like to help us with the migration?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants