[Bug] browserslist and targets have no effect on the output of the build (potential performance problems as well)
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 30/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- babel, javascript
调研方向
从最小复现步骤开始:将 browserslist 设置和依赖项添加到 package.json,然后运行 ember build -e production。将生成的 my-app.js 与链接的 input.js 和 output.js 进行比较,包括 private-method 错误。完成标准是:配置的 Chrome 和 Firefox 目标保留受支持的原生语法,并避免所示的意外转换。
由索引模型根据 Issue 内容生成。
描述
Originally reported here: https://github.com/emberjs/ember.js/issues/19790
🐞 Describe the Bug
After some investigation here: https://stackoverflow.com/questions/69547969/with-babel-how-do-i-not-compile-away-class-properties-since-browsers-support
And a minimal babel repro here: https://github.com/NullVoxPopuli/babel-transpilation-tests
I expect that setting my targets to last 1 firefox versions would allow me to keep native class properties. and only transpile what is decororated.
I believe fixing this could provide a bit of a boost to everyone's build times. Today all class properties are transpiled to a time when class properties were not implemented in the browser).
🔬 Minimal Reproduction
- ember new my-app
- cd my-app
- remove safari from targets, leaving only
last 1 Chrome versionsandlast 1 firefox versions - add browserslist to package.json
- add browserslist as devDependency
yarn browserslist --update-db- run
ember build -e production - in the my-app.js, I expect all occurrences of
rootURLto be involved in an assignment, rather than a function call.
result: https://github.com/NullVoxPopuli/repro-for-emberjs-19790
😕 Actual Behavior
Living in the dark ages
🤔 Expected Behavior
Utilize support for native properties, private properties, methods, etc.
🌍 Environment
- Ember: - CLI 3.28.0
- Node.js/npm: -14.17.6
- OS: - n/a
- Browser: - n/a
➕ Additional Context
See the comparison between these two files:
Input: https://github.com/NullVoxPopuli/babel-transpilation-tests/blob/main/input.js
Output: https://github.com/NullVoxPopuli/babel-transpilation-tests/blob/main/output.js
This is correct.
But when I add that input file to ember, I get this for the output:
/home/nullvoxpopuli/Development/tmp/my-app/my-app/input.js: Class private methods are not enabled.
2 | #a = 'hi';
3 |
> 4 | get #b() {
| ^
5 | return 'hello' + this.#a;
6 | }
7 |
which... I guess is unrelated, but should still be fixed. Now, If I change the private methods/getters to public:
I get this mess:
var e, t, r
function n(e, t, r) {(function (e, t) {if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object")})(e, t), t.set(e, r)} function i(e, t) {
var r = function (e, t, r) {
if (!t.has(e)) throw new TypeError("attempted to " + r + " private field on non-instance")
return t.get(e)
}(e, t, "get")
return function (e, t) {
if (t.get) return t.get.call(e)
return t.value
}(e, r)
} r = new WeakMap, e = class {
constructor() {
var e, i, a, l
n(this, r, {writable: !0, value: "hi"}), e = this, i = "g", l = this, (a = t) && Object.defineProperty(e, i, {enumerable: a.enumerable, configurable: a.configurable, writable: a.writable, value: a.initializer ? a.initializer.call(l) : void 0})
} get b() {return "hello" + i(this, r)} get c() {return this.b}
}, a = e.prototype, l = "g", o = [f], u = {configurable: !0, enumerable: !0, writable: !0, initializer: null}, p = {}, Object.keys(u).forEach((function (e) {p[e] = u[e]})), p.enumerable = !!p.enumerable, p.configurable = !!p.configurable, ("value" in p || p.initializer) && (p.writable = !0), p = o.slice().reverse().reduce((function (e, t) {return t(a, l, e) || e}), p), d && void 0 !== p.initializer && (p.value = p.initializer ? p.initializer.call(d) : void 0, p.initializer = void 0), void 0 === p.initializer && (Object.defineProperty(a, l, p), p = null), t = p
var a, l, o, u, d, p
which is way wrong.
- 主要语言
- JavaScript
- 星标
- 151
- 派生
- 115
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
emberjs/ember-cli-babel 的其他 Issue
-
难度 1/5 1 小时以内 新手友好度 68/100
emberjs/ember-cli-babel#508 ·
-
Add support for Babel v8可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 4/5 3-5 天 新手友好度 38/100
emberjs/ember-cli-babel#535 · 1 条评论 ·
-
难度 4/5 3-5 天 新手友好度 35/100
emberjs/ember-cli-babel#533 ·
-
难度 4/5 3-5 天 新手友好度 35/100
emberjs/ember-cli-babel#519 · 6 条评论 · 8 个 reaction ·
-
难度 3/5 1-2 天 新手友好度 35/100
emberjs/ember-cli-babel#517 ·
查看 emberjs/ember-cli-babel 的全部 Issue
相似的 Issue
-
neutral:fix
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
wazuh/wazuh-documentation#10611 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
remotion-dev/remotion#12905 ·
维护者通常 1 天内回复
-
enhancement websites
难度 2/5 1-3 小时 新手友好度 78/100
quarto-dev/quarto-cli#15255 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
PolicyEngine/cliff-watch#44 ·