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

Build fragments a possible tree shaking #7851

Closed
char0n opened this issue Feb 19, 2022 · 0 comments
Closed

Build fragments a possible tree shaking #7851

char0n opened this issue Feb 19, 2022 · 0 comments
Assignees

Comments

@char0n
Copy link
Member

char0n commented Feb 19, 2022

I've already documented current build fragments and how I foresee their future in this issue: #7831

I have problem using swagger-ui-es-bundle.js as it bundles the React with it. This build fragment is mapped in package.json in following way:

  "module": "dist/swagger-ui-es-bundle.js",

This means that when I use swagger-ui inside swagger-editor I end up bundling React twice which has side effects like these:

image

To translate this: When I want to use hooks, the app crashes as hooks as smart enough to realize the app is running two Reacts.

To fix that, me and I guess a lot of people as well need to use following webpack config:

      resolve: {
        alias: {
          "swagger-ui": path.resolve(projectBasePath, "node_modules", "swagger-ui", "dist", "swagger-ui-es-bundle-core.js"),
        },
      },

This works but the swagger-ui-es-bundle-core.js is commonjs bundle which pulls whole highlight.js and refractor libraries in. This issues about about creating remediation for swagger-ui-es-bundle-core.js build fragment and not to pull whole highlight.js and refractor libraries with it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant