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: add production/development export conditions #9977

Merged
merged 1 commit into from
Jan 4, 2024

Conversation

danielroe
Copy link
Member

@danielroe danielroe commented Jan 3, 2024

In Nitro, we create a minimal node_modules/ just for our final output. This traces the files that are used, respecting the correct export conditions.

At the moment, NODE_ENV governs whether we load the prod/dev CJS versions of the Vue packages. However, we can support custom export conditions like production and development (see nodejs reference). These have broad community support and can be used on the CLI (for example, with node --conditions=development index.js) and by bundlers like Nitro which have support for them.

This PR adds production/development conditions for the Node/CJS bundles. To make it backwards compatible it:

  1. adds ./* as a subpath export so any file that was previously fully specified can continue to be fully specified (e.g. @vue/compiler-core/package.json
  2. Adds a default condition that falls back the previous behaviour (e.g. if no production/development condition is explicitly specified)

I've tested this with Nuxt (see repo and Stackblitz). It enables us to reduce the output bundle by 1.2Mb.

Related nitrojs/nitro#2046

Copy link

github-actions bot commented Jan 3, 2024

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 89.4 kB 34 kB 30.7 kB
vue.global.prod.js 146 kB 53.3 kB 47.5 kB

Usages

Name Size Gzip Brotli
createApp 49.8 kB 19.5 kB 17.8 kB
createSSRApp 53.1 kB 20.8 kB 19 kB
defineCustomElement 52 kB 20.2 kB 18.5 kB
overall 63.2 kB 24.4 kB 22.2 kB

@yyx990803
Copy link
Member

/ecosystem-ci run

@vue-bot
Copy link
Contributor

vue-bot commented Jan 4, 2024

📝 Ran ecosystem CI: Open

suite result latest scheduled
language-tools failure failure
nuxt success success
pinia success success
quasar success success
router success success
test-utils success success
vant success success
vite-plugin-vue success success
vitepress success success
vue-i18n success success
vue-macros failure failure
vuetify failure failure
vueuse success success
vue-simple-compiler success success

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.

3 participants