-
Notifications
You must be signed in to change notification settings - Fork 698
Open
Description
What problem does this feature solve?
- Require
treeshake.propertyReadSideEffectsconfiguration option - Basic unused property access tree shaking - unused
obj.propertyexpressions are not being removed
Current Behavior vs Expected Behavior
Test Case Setup
I've created a test case comparing Rolldown (via rolldown-vite) with standard Vite/Rollup. Here's the simplified test code:
constants.ts:
export const API_ENDPOINTS = {
USERS: '/api/users',
POSTS: '/api/posts'
}main.ts:
import { API_ENDPOINTS } from './constant.js'
API_ENDPOINTS.USERS // Should be tree-shaken
export default {}Actual Results
Rolldown output: repl
//#region constant.js
const API_ENDPOINTS = {
USERS: "/api/users",
POSTS: "/api/posts"
};
//#endregion
//#region index.ts
API_ENDPOINTS.USERS;
var index_default = {};
//#endregion
export { index_default as default };Vite/Rollup output with better tree shaking: repl
var main = {};
export { main as default };What does the proposed API look like?
Rollup supports the treeshake.propertyReadSideEffects option.
Expected Configuration:
// vite.config.js
export default defineConfig({
build: {
rolldownOptions: {
treeshake: {
propertyReadSideEffects: false
}
}
}
})Reactions are currently unavailable