Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix esm vs. cjs typings #1197

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

Closed

Conversation

romainmenke
Copy link
Member

@romainmenke romainmenke commented Dec 4, 2023

fixes : #1031


I am not sure that I like this yet.
It adds a lot of complexity.

General approach :

  • bundle and treeshake the type definitions
  • do a string find/replace to convert the esm typings to cjs.

Bundling and treeshaking the types is critical to make this work.
All types for a given plugin need to be in a known place and shape to do the string find/replace.

This obviously is very brittle and depends on a bunch more 3rd party software.

@romainmenke
Copy link
Member Author

nope, this remains unsolvable.
No matter which way you start you always end up with single bit that is broken.

If you follow this route to it's end you find that there is just no way to express default exports in the correct way in both commonjs and esmodules and do this automated, not with manually crafted types.

I don't think we can have correct types as long as we dual ship esm and cjs.

@romainmenke romainmenke closed this Dec 4, 2023
@romainmenke romainmenke deleted the fix-ts-typings--considerate-burrowing-frog-e44706597a branch December 4, 2023 22:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli common-tools experimental plugin-packs/postcss-bundler plugin-packs/postcss-preset-env plugins/css-blank-pseudo plugins/css-has-pseudo plugins/css-prefers-color-scheme plugins/media-queries-aspect-ratio-number-values plugins/postcss-media-queries-aspect-ratio-number-values plugins/postcss-attribute-case-insensitive plugins/postcss-cascade-layers plugins/postcss-color-function plugins/postcss-color-functional-notation plugins/postcss-color-hex-alpha plugins/postcss-color-mix-function plugins/postcss-color-rebeccapurple plugins/postcss-conditional-values plugins/postcss-custom-media plugins/postcss-custom-properties plugins/postcss-custom-selectors plugins/postcss-design-tokens plugins/postcss-dir-pseudo-class plugins/postcss-double-position-gradients plugins/postcss-exponential-functions plugins/postcss-extract plugins/postcss-focus-visible plugins/postcss-focus-within plugins/postcss-font-format-keywords plugins/postcss-gamut-mapping plugins/postcss-gap-properties plugins/postcss-global-data plugins/postcss-gradients-interpolation-method plugins/postcss-hwb-function plugins/postcss-ic-unit plugins/postcss-image-set-function plugins/postcss-initial plugins/postcss-is-pseudo-class plugins/postcss-lab-function plugins/postcss-logical plugins/postcss-logical-float-and-clear plugins/postcss-logical-resize plugins/postcss-logical-viewport-units plugins/postcss-media-minmax plugins/postcss-minify plugins/postcss-nested-calc plugins/postcss-nesting plugins/postcss-normalize-display-values plugins/postcss-oklab-function plugins/postcss-overflow-shorthand plugins/postcss-place plugins/postcss-progressive-custom-properties plugins/postcss-pseudo-class-any-link plugins/postcss-rebase-url plugins/postcss-relative-color-syntax plugins/postcss-scope-pseudo-class plugins/postcss-selector-not plugins/postcss-slow-plugins plugins/postcss-stepped-value-functions PostCSS Stepped Value Functions plugins/postcss-text-decoration-shorthand plugins/postcss-trigonometric-functions PostCSS Trigonometric Functions plugins/postcss-unset-value
Projects
None yet
Development

Successfully merging this pull request may close these issues.

packages provide wrong types under node16 module resolution
1 participant