Skip to content

Conversation

@neonerd
Copy link
Contributor

@neonerd neonerd commented Nov 24, 2017

This fixes the problem with Webpack + TS-Loader not working correctly after slugify added TS definitions.

Fixes #16

@simov simov merged commit 07c3c9d into simov:master Nov 24, 2017
@simov
Copy link
Owner

simov commented Nov 24, 2017

Thank you! 👍

@sylvaindumont
Copy link
Contributor

Thanks for the fix, I chose commonjs export instead of es6 export because it was used in others browser/node modules exporting a single function (ex: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/haversine/index.d.ts).
es6 export worked better for me but I followed what seemed to be a convention to avoid breaking builds, but it did the opposite.
Your es6 export works well when compiling with commonjs modules and es6 modules, thank you again.

@karlhorky
Copy link

karlhorky commented Jan 29, 2023

This change breaks the new "module": "node16" setting in tsconfig.json. I'll create a reproduction and PR reverting this change. I think @sylvaindumont's original approach was actually correct, because slugify is indeed a CommonJS module.

Hopefully bundler module resolution with webpack + ts-loader (and other bundlers) have since adapted and now also can also deal with the CommonJS-style export, because it seems to be the right way to do this.

karlhorky added a commit to karlhorky/slugify that referenced this pull request Jan 29, 2023
The change in simov#19 to switch to an ESM-style export seemed like the right solution at the time.

However, module systems have evolved since then and the `export default` fails when "module": "node16" is configured in tsconfig.json

Since `slugify` is a CommonJS module, it seems like using a CommonJS-style export is indeed the right choice for this package.
@karlhorky
Copy link

Reproduction of problem + PR to revert to CommonJS export: #171

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

Successfully merging this pull request may close these issues.

1.2.4 breaks webpack compilation

4 participants