Code Monkey home page Code Monkey logo

Comments (11)

bpierre avatar bpierre commented on May 22, 2024 1

@dan437 @Mrtenz Done!

https://github.com/bpierre/blo/releases/tag/v1.2.0
https://unpkg.com/browse/[email protected]/package.json
https://unpkg.com/browse/[email protected]/dist/

Thanks and please me know if it works 🤗

from blo.

dan437 avatar dan437 commented on May 22, 2024 1

Thank you for a quick fix!

from blo.

bpierre avatar bpierre commented on May 22, 2024

Is it with Next.js? Could you please add a way to reproduce the issue? Thanks!

from blo.

abhijeetbhagat avatar abhijeetbhagat commented on May 22, 2024

@bpierre yes, we use next.js. it's a closed source application so can't reveal more details. but this is our env:
node version: 16.20.0
macos

install blo: npm i -S blo
use:

 import { bloSvg } from 'blo';`
...
 <img alt={address} src={bloSvg(address)} />

after the page loads, we get that error. lmk if you still need more details (i am a new react dev btw so dont understand much as of now :))

EDIT: thank you for creating this cool library!

from blo.

bpierre avatar bpierre commented on May 22, 2024

@abhijeetbhagat I created a new Next.js project with npx create-next-app and leaving everything by default:

Here is the demo page, everything seems to work for me: https://github.com/bpierre/blo-issue-3/blob/main/src/app/page.tsx

I added you as a collaborator on this repo, could you please try to reproduce your issue there? Thanks!

from blo.

bpierre avatar bpierre commented on May 22, 2024

Closing this issue for now, please reopen if you can reproduce on the linked repo :)

from blo.

Mrtenz avatar Mrtenz commented on May 22, 2024

@bpierre blo specifies type: 'module' in package.json, meaning that any .js files are treated as ES module. Since the main file is index.cjs.js (ends with .js), it's treated as ES module as well. It's not possible to require the library because of this in CommonJS environments.

The easiest solution is to name the main file index.cjs, which is always treated as CommonJS regardless of the type in package.json.

from blo.

bpierre avatar bpierre commented on May 22, 2024

@Mrtenz it used to be the case, but it was causing compatibility issues in certain cases (ESLint). This commit changed it: 9ce9aa2

Could you please post a reproduction of your issue somewhere so I can have a look? Thanks 🙏

from blo.

dan437 avatar dan437 commented on May 22, 2024

Hi, you can see it's reproduced here on the yarn test:coverage:mocha step: https://app.circleci.com/pipelines/github/MetaMask/metamask-extension/75930/workflows/2d755ea6-af10-47d9-884d-f5b5c17f2fba/jobs/2611616

After removing "type": "module", from blo's package.json it works, but not sure if that's the right solution.

Other thing that has worked was to downgrade blo from 1.1.1 to 1.1.0.

from blo.

bpierre avatar bpierre commented on May 22, 2024

Found the issue about ESLint and using the .cjs extension, it was also with MetaMask/metamask-extension:

  1. MetaMask/metamask-extension#21010 (comment)
  2. MetaMask/metamask-extension#21010 (review)

@Mrtenz @dan437 Could you confirm having .cjs works with your ESLint config now? There is no extensions line in the current .eslintrc.js but it might not be needed anymore?

from blo.

dan437 avatar dan437 commented on May 22, 2024

After downgrading to 1.1.0 I can see that blo's package.json uses:

"main": "./dist/index.cjs",
  "types": "./dist/index.d.ts",
  "exports": {
    ".": {
      "types": "./dist/index.d.ts",
      "require": "./dist/index.cjs",
      "default": "./dist/index.js"
    }
  },

Mocha tests pass and when I run yarn lint in the MetaMask extension, it passes as well.

from blo.

Related Issues (2)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.