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

Retry to fix object spread helper compatibility #9384

Merged
merged 1 commit into from May 25, 2019

Conversation

saschanaz
Copy link
Contributor

@saschanaz saschanaz commented Jan 22, 2019

Q                       A
Fixed Issues? Fixes #9322
Patch: Bug Fix?
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
License MIT

Retries #9341.

This adds helpers._objectSpread2() where only the even arguments would be considered as spreads.

@nicolo-ribaudo
Copy link
Member

Can you add a comment that the old helper can be removed in the next major release?

@saschanaz
Copy link
Contributor Author

No idea what's causing failure to rename.

@saschanaz
Copy link
Contributor Author

Can you add a comment that the old helper can be removed in the next major release?

Inside the helper or above helpers.objectSpread line?

@babel-bot
Copy link
Collaborator

babel-bot commented Jan 22, 2019

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/10860/

@saschanaz
Copy link
Contributor Author

It seems somehow the helper name can't include a trailing number?

@nicolo-ribaudo
Copy link
Member

Yeah it can. It will be renamed to _objectSpread when inlined but it isn't a problem: @babel/runtime/helpers/objectSpread will still point to the old helper and @babel/runtime/helpers/objectSpread2 to the new one.

@saschanaz
Copy link
Contributor Author

Can this be merged or do this have any more blockers?

@saschanaz
Copy link
Contributor Author

saschanaz commented Feb 18, 2019

Any news for this? @nicolo-ribaudo

@saschanaz
Copy link
Contributor Author

@nicolo-ribaudo How about we just treat null/undefined always as {}? That way we can keep the compatibility with the previous behavior without adding objectSpread2.

@nicolo-ribaudo
Copy link
Member

It wouldn't work, because the old helper handles all the arguments the same way.

@nicolo-ribaudo nicolo-ribaudo added PR: Bug Fix 🐛 A type of pull request used for our changelog categories PR: Needs Review A pull request awaiting more approvals labels Feb 22, 2019
@saschanaz
Copy link
Contributor Author

saschanaz commented Feb 22, 2019 via email

helpers.objectSpread2 = helper("7.0.0-beta.0")`
import defineProperty from "defineProperty";

export default function _objectSpread(target) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it be named objectSpread2? I wonder in the case someone uses babel-runtime, this might be a problem, but I don't know exactly how runtime works.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is a default export, the name doesn't matter.
Anyway, we should rename it for consistency.

Copy link
Member

@danez danez Mar 3, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But where is the name in generated output coming from? Because right now it is called _objectSpread even with he new helper, which made me think it might collide in the runtime again.

I thought it might be the name of the function here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does generateUidIdentifier("objectSpread2"), which removes 2 before generating the id.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would objectSpreadTwo is okay or should I fix the function to not remove 2?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's ok as it is now for me.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean this can be ignored?

Anyway, we should rename it for consistency.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should rename the helper:

export default function _objectSpread2

But is is not a problem if that 2 then gets automatically removed by generateUid.

Copy link
Member

@danez danez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the long wait. Can you please rebase the PR, so that it can be merged?

packages/babel-helpers/src/helpers.js Outdated Show resolved Hide resolved
@danez danez added this to the v7.5.0 milestone May 25, 2019
@buildsize
Copy link

buildsize bot commented May 25, 2019

File name Previous Size New Size Change
babel-preset-env.js 2.28 MB 2.05 MB -235.61 KB (10%)
babel-preset-env.min.js 1.31 MB 1.1 MB -213.93 KB (16%)
babel.js 2.82 MB 2.77 MB -46.25 KB (2%)
babel.min.js 1.56 MB 1.55 MB -18.31 KB (1%)

…babel#9341)" (babel#9379)"

This reverts commit 43b83f8.

Fix objectSpread helper breaking old codes

remove tests to regenerate later

renamed output

new name

try using word

add comment as requested

revert inline name changes

add 2 for consistency

Update packages/babel-helpers/src/helpers.js

Co-Authored-By: Daniel Tschinder <daniel@tschinder.de>
@nicolo-ribaudo nicolo-ribaudo added Spec: Object Rest/Spread and removed PR: Needs Review A pull request awaiting more approvals labels May 25, 2019
@nicolo-ribaudo nicolo-ribaudo merged commit a596da2 into babel:master May 25, 2019
@nicolo-ribaudo
Copy link
Member

Thanks!

@mathieutu
Copy link

Hi folks. Thanks for you work.

Just to be sure, do you confirm that this PR will fix the issue #8749?

Do you have any idea of its release planning?

Thanks!

@cloudkite
Copy link

This change breaks IE11 compatibility when using object spread syntax without using polyfills as getOwnPropertyDescriptors is not available in IE11.

@nicolo-ribaudo
Copy link
Member

Could you please open a new issue? 🙏

@QingLeiLi
Copy link

QingLeiLi commented Jul 5, 2019

I got the error

ModuleNotFoundError: Module not found: Error: Can't resolve '@babel/runtime/helpers/objectSpread2'

There must be something wrong in babel-plugin-proposal-object-rest-spread.

ADD:objectSpread2 was add in the @babel/runtime-corejs2 package, but the helperGenerator method will search the helper in the @babel/runtime package only, except set the corejs option to 2.

@pwnreza
Copy link

pwnreza commented Jul 5, 2019

WhatsApp Image 2019-07-05 at 13 24 32

Same error as referenced by @edi9999
We are depending on building our RN app via pre-installed set of node_modules.
So we are pretty desperate for a fix 🙏

@kimroen
Copy link

kimroen commented Jul 5, 2019

I got the error

ModuleNotFoundError: Module not found: Error: Can't resolve '@babel/runtime/helpers/objectSpread2'

There must be something wrong in babel-plugin-proposal-object-rest-spread.

ADD:objectSpread2 was add in the @babel/runtime-corejs2 package, but the helperGenerator method will search the helper in the @babel/runtime package only, except set the corejs option to 2.

We're getting a similar error after upgrading from 7.4.3 to 7.5.0. The error we're getting is this:

"Unknown helper objectSpread2".

@QingLeiLi
Copy link

I got the error

ModuleNotFoundError: Module not found: Error: Can't resolve '@babel/runtime/helpers/objectSpread2'

There must be something wrong in babel-plugin-proposal-object-rest-spread.
ADD:objectSpread2 was add in the @babel/runtime-corejs2 package, but the helperGenerator method will search the helper in the @babel/runtime package only, except set the corejs option to 2.

We're getting a similar error after upgrading from 7.4.3 to 7.5.0. The error we're getting is this:

"Unknown helper objectSpread2".

Yeah, add @babel/plugin-transform-runtime option
{ corejs: 2, }
make it works again.

@Udbhav12
Copy link

Udbhav12 commented Jul 5, 2019

@QingLeiLi Can you please share your entire package.json file ?

@QingLeiLi
Copy link

QingLeiLi commented Jul 8, 2019

@QingLeiLi Can you please share your entire package.json file ?

package.json ? Do you mean babel config?

// babel.config.js
module.exports = {
        presets: [
            [
                '@babel/preset-env',
                {
                    modules: 'false',
                    targets: {
                        ios: '9',
                        android: '4.4'
                    },
                    useBuiltIns: 'usage'
                }
            ],
            ['@babel/preset-react'],
            ['@babel/preset-typescript']
        ],
        plugins: [
            ['@babel/plugin-transform-runtime', {
            	// point
                "corejs": 2,
            }],
            '@babel/plugin-proposal-class-properties',
            [
                "@babel/plugin-proposal-decorators",
                {
                    "decoratorsBeforeExport": false
                }
            ]
        ],
};

@pwnreza
Copy link

pwnreza commented Jul 8, 2019

WhatsApp Image 2019-07-05 at 13 24 32

Same error as referenced by @edi9999
We are depending on building our RN app via pre-installed set of node_modules.
So we are pretty desperate for a fix 🙏

See here

@kimroen
Copy link

kimroen commented Jul 8, 2019

Just wanted to mention that the issue I was describing above was fixed by this PR: #10170

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue PR: Bug Fix 🐛 A type of pull request used for our changelog categories Spec: Object Rest/Spread
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Object spread still calls getter function after transform
10 participants