Open tobiasdiez opened 1 year ago
Found a few PRs that seem to address this: https://github.com/simov/slugify/pull/43, https://github.com/simov/slugify/pull/160, https://github.com/simov/slugify/pull/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')
+1 on this!
Another alternative is to disable TypeScript checking for that line:
// @ts-ignore
slugify('some string')
Although this is not ideal
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
.