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

Let downstream application decide about transpiling and polyfills #1470

Open
StefanBrand opened this issue Jan 17, 2024 · 0 comments
Open

Let downstream application decide about transpiling and polyfills #1470

StefanBrand opened this issue Jan 17, 2024 · 0 comments
Assignees

Comments

@StefanBrand
Copy link

StefanBrand commented Jan 17, 2024

General information

  • json-editor version: 2.13.1

Expected behavior

Bundle in downstream application is responsible for transpiling. json-editor does not bundle all of core-js. Bundle size of downstream application decreases.

Actual behavior

All of core-js is bundled with json-editor, bundle is the main entry point. Downstream application is bloated with polyfills that are not needed.

Steps to reproduce the behavior

  1. npx webpack --config config/webpack.prod.js --profile --json > stats.json && npx webpack-bundle-analyzer stats.json dist -> Parsed size is 515kB
  2. remove babel-loader from webpack.common.js
  3. npx webpack --config config/webpack.prod.js --profile --json > stats.json && npx webpack-bundle-analyzer stats.json dist -> Parsed size is 265kB

Workaround in downstream application

Import JSONEditor like this: import { JSONEditor } from "@json-editor/json-editor/src/core.js";

Solution

Change

"main": "dist/jsoneditor.js",

-  "main": "dist/jsoneditor.js",
+  "main": "src/core.js",

More info about entry points: https://vitejs.dev/guide/build.html#library-mode

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

No branches or pull requests

3 participants