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

Provide esm version #173

Open
tobiasdiez opened this issue Mar 4, 2023 · 4 comments
Open

Provide esm version #173

tobiasdiez opened this issue Mar 4, 2023 · 4 comments

Comments

@tobiasdiez
Copy link

With more and more build tools (vite, nuxt, etc) going towards an esm-first build, it would be nice if a proper esm interface could be provided, i.e. transpile and distribute esm version, including correct export declaration in package.json.

@michaelhays
Copy link

michaelhays commented Mar 20, 2023

Found a few PRs that seem to address this: #43, #160, #171

For those of you using TypeScript and "type": "module", I'm using this as a workaround:

/imports/slugify.ts

/**
 * Hack to make 'slugify' import work with "type": "module".
 */
import slugify from 'slugify'

export default slugify as unknown as typeof slugify.default

/src/someFile.ts

import slugify from '~/imports/slugify.js'

const slug = slugify('Some Name')

@tyteen4a03
Copy link

+1 on this!

@kmturley
Copy link

Another alternative is to disable TypeScript checking for that line:

// @ts-ignore
slugify('some string')

Although this is not ideal

@glorat
Copy link

glorat commented Aug 13, 2024

I've dealt with this in my typescript project by in-sourcing slugify and converting the code to typescript. See https://gist.github.com/glorat/5070ebd2fa275e2012a51300329a7a55

In-sourcing is de-facto a hard fork but the codebase is mature so wouldn't be an issue for most cases

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

5 participants