Skip to content

build: add exports field for useSES #24557

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
wants to merge 1 commit into from

Conversation

huozhi
Copy link
Contributor

@huozhi huozhi commented May 14, 2022

Summary

Add exports field to use-sync-external-store for usage in esm modules (.mjs).

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '...blabla/node_modules/use-sync-external-store/with-selector' imported from ...`
Did you mean to import use-sync-external-store/with-selector.js?
    at new NodeError (internal/errors.js:322:7)
    at finalizeResolution (internal/modules/esm/resolve.js:318:11)
    at moduleResolve (internal/modules/esm/resolve.js:776:10)
    at Loader.defaultResolve [as _resolve] (internal/modules/esm/resolve.js:887:11)
    at Loader.resolve (internal/modules/esm/loader.js:89:40)
    at Loader.getModuleJob (internal/modules/esm/loader.js:242:28)
    at ModuleWrap.<anonymous> (internal/modules/esm/module_job.js:76:40)
    at link (internal/modules/esm/module_job.js:75:36) {
  type: 'NodeError',
  code: 'ERR_MODULE_NOT_FOUND'
}

How did you test this change?

We added useESE in swr for react 18 support, and trying to test it with next.js, I got the above error when running next build. The reason seems because of exports field is missing in useESE that break the subpath imports

@sizebot
Copy link

sizebot commented May 14, 2022

Comparing: 4c03bb6...bc314f6

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable/react-dom/cjs/react-dom.production.min.js = 131.48 kB 131.48 kB = 42.14 kB 42.14 kB
oss-experimental/react-dom/cjs/react-dom.production.min.js = 136.72 kB 136.72 kB = 43.69 kB 43.69 kB
facebook-www/ReactDOM-prod.classic.js = 441.11 kB 441.11 kB = 80.41 kB 80.41 kB
facebook-www/ReactDOM-prod.modern.js = 426.32 kB 426.32 kB = 78.23 kB 78.23 kB
facebook-www/ReactDOMForked-prod.classic.js = 441.11 kB 441.11 kB = 80.41 kB 80.41 kB
oss-experimental/use-sync-external-store/cjs/use-sync-external-store-with-selector.development.js +30.96% 5.64 kB 7.39 kB +42.63% 1.81 kB 2.58 kB
oss-stable-semver/use-sync-external-store/cjs/use-sync-external-store-with-selector.development.js +30.96% 5.64 kB 7.39 kB +42.63% 1.81 kB 2.58 kB
oss-stable/use-sync-external-store/cjs/use-sync-external-store-with-selector.development.js +30.96% 5.64 kB 7.39 kB +42.63% 1.81 kB 2.58 kB
oss-experimental/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js +29.76% 5.70 kB 7.39 kB +41.49% 1.83 kB 2.59 kB
oss-stable-semver/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js +29.76% 5.70 kB 7.39 kB +41.49% 1.83 kB 2.59 kB
oss-stable/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js +29.76% 5.70 kB 7.39 kB +41.49% 1.83 kB 2.59 kB
oss-experimental/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js = 1.11 kB 1.07 kB = 0.62 kB 0.60 kB
oss-stable-semver/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js = 1.11 kB 1.07 kB = 0.62 kB 0.60 kB
oss-stable/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js = 1.11 kB 1.07 kB = 0.62 kB 0.60 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name +/- Base Current +/- gzip Base gzip Current gzip
oss-experimental/use-sync-external-store/cjs/use-sync-external-store-with-selector.development.js +30.96% 5.64 kB 7.39 kB +42.63% 1.81 kB 2.58 kB
oss-stable-semver/use-sync-external-store/cjs/use-sync-external-store-with-selector.development.js +30.96% 5.64 kB 7.39 kB +42.63% 1.81 kB 2.58 kB
oss-stable/use-sync-external-store/cjs/use-sync-external-store-with-selector.development.js +30.96% 5.64 kB 7.39 kB +42.63% 1.81 kB 2.58 kB
oss-experimental/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js +29.76% 5.70 kB 7.39 kB +41.49% 1.83 kB 2.59 kB
oss-stable-semver/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js +29.76% 5.70 kB 7.39 kB +41.49% 1.83 kB 2.59 kB
oss-stable/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js +29.76% 5.70 kB 7.39 kB +41.49% 1.83 kB 2.59 kB
oss-experimental/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js = 1.11 kB 1.07 kB = 0.62 kB 0.60 kB
oss-stable-semver/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js = 1.11 kB 1.07 kB = 0.62 kB 0.60 kB
oss-stable/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js = 1.11 kB 1.07 kB = 0.62 kB 0.60 kB

Generated by 🚫 dangerJS against bc314f6

shim wildcard with extension

fix shim/with-selector path
@huozhi huozhi force-pushed the build/use-ses-exports branch from 5345109 to bc314f6 Compare May 16, 2022 19:51
@huozhi huozhi marked this pull request as ready for review May 17, 2022 21:48
@huozhi huozhi marked this pull request as draft May 17, 2022 21:49
@huozhi
Copy link
Contributor Author

huozhi commented May 17, 2022

Hi react folks, any idea which subpath exports is missing that lead to this error in test? Wanna get some hints to fix them

@huozhi huozhi marked this pull request as ready for review May 19, 2022 20:27
@huozhi
Copy link
Contributor Author

huozhi commented May 19, 2022

cc @acdlite @gaearon do you have any insights what's missing in the PR?

@gaearon
Copy link
Collaborator

gaearon commented May 26, 2022

There's an existing PR in #24440 so we should probably merge that one. But the author says it's a breaking change. Why is it?

@huozhi
Copy link
Contributor Author

huozhi commented May 27, 2022

Thanks for referencing the existing one! I'm not sure the reason why is that. Maybe the file path changing will breaks code that are directly importing it?
I can close this one and we continue the discussion there

@huozhi huozhi closed this May 27, 2022
@huozhi huozhi deleted the build/use-ses-exports branch May 27, 2022 09:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants