Closed FurryR closed 1 month ago
eslint --fix .
npm install --save-dev nanoid@FurryR/nanoid
- We also have url-alphabet
- Please run
eslint --fix .
- I really worry that it could break something else. Can you test that this method doesn’t break Vite and webpack (you can add version from your branch by
npm install --save-dev nanoid@FurryR/nanoid
url-alphabet
a private file. I will add default export for it later..d.ts
) need to be updated. Anyway, I will take a look.Tested with pnpm start
. This PR does not break Vite.
const { nanoid } = require('nanoid')
But Nano ID 4.x and 5.x don’t support require()
. If you are using CJS you need 3.x version. We have a special branch for it.
@ai any way you can guys ship this? I was trying using nanoId with typescript the problem is that when I transpile and push the code to google app engine, it says that the require() is not supported. Maybe you have a workaround instead of needing this PR?
@ferreiro as I told I need some investigation that it will not break in many possible cases where Nano ID is used.
If you need it, please help to the community.
const { nanoid } = require('nanoid')
But Nano ID 4.x and 5.x don’t support
require()
. If you are using CJS you need 3.x version. We have a special branch for it.
Hmm. weird. If you access https://cdn.jsdelivr.net/npm/nanoid@3.3.7/non-secure/+esm you will see.
Anyway, I will close this PR and wait for a better workaround. Thank you all guys.
Proposed Changes
Ensure compatibility with some CDNs & bundlers on some CJS libraries.
jsDelivr translates
const { nanoid } = require('nanoid')
directly intoimport e from 'nanoid/+esm'; const { nanoid } = e
, which is problematic and causes some libraries fail to load.Here is an example using
postcss
:Additional Information
It is suggested to squash merge this PR.