-
Notifications
You must be signed in to change notification settings - Fork 373
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
fix(build): fix tree shaking and bundle size #1343
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
const babelConfig = require("./scripts/build/babel.config") | ||
|
||
module.exports = babelConfig({ modules: true }) | ||
module.exports = babelConfig(true) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,7 +31,7 @@ | |
} | ||
}, | ||
"engines": { | ||
"node": ">=10.0.0" | ||
"node": ">=14.0.0" | ||
}, | ||
"files": [ | ||
"LICENSE", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1 @@ | ||
if (process.env.NODE_ENV === "production") { | ||
module.exports = require("./cjs/compile.production.min.js") | ||
} else { | ||
module.exports = require("./cjs/compile.development.js") | ||
} | ||
module.exports = require("./cjs/compile.js") |
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1 @@ | ||
if (process.env.NODE_ENV === "production") { | ||
module.exports = require("./cjs/core.production.min.js") | ||
} else { | ||
module.exports = require("./cjs/core.development.js") | ||
} | ||
module.exports = require("./cjs/index.js") |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
export { | ||
setupI18n, | ||
I18n, | ||
} from "./i18n" | ||
|
||
export type { | ||
AllMessages, | ||
MessageDescriptor, | ||
Messages, | ||
Comment on lines
1
to
9
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Without typescript plugin, rollup treat type only exports as regular, and obviously fail. Here we do a little help for him and manually mark them as type only. |
||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1 @@ | ||
if (process.env.NODE_ENV === "production") { | ||
module.exports = require("./cjs/detect-locale.production.min.js") | ||
} else { | ||
module.exports = require("./cjs/detect-locale.development.js") | ||
} | ||
module.exports = require("./cjs/index.js") |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,7 @@ | |
"url": "https://github.com/lingui/js-lingui/issues" | ||
}, | ||
"engines": { | ||
"node": ">=10.0.0" | ||
"node": ">=14.0.0" | ||
}, | ||
"files": [ | ||
"LICENSE", | ||
|
@@ -41,7 +41,8 @@ | |
"loader-utils": "^2.0.0" | ||
}, | ||
"devDependencies": { | ||
"memory-fs": "^0.5.0" | ||
"memory-fs": "^0.5.0", | ||
"webpack": "^4.44.2" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That was defined on monorepo root but actually used here, i fixed it. |
||
}, | ||
"peerDependencies": { | ||
"webpack": "^4.0.0 || ^5.0.0" | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1 @@ | ||
if (process.env.NODE_ENV === "production") { | ||
module.exports = require("./cjs/react.production.min.js") | ||
} else { | ||
module.exports = require("./cjs/react.development.js") | ||
} | ||
module.exports = require("./cjs/index.js") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's very important change. If we would access this with relative path, tree shaker would not be able to eliminate this import.
Because of package import, tree shaker first looks into package's pakage.json, see
{sideEffects: false}
and then remove it from the bundle.