-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
3p-frame
: Prefer #core/mode
to getMode
#35669
Conversation
function mockMode(mode) { | ||
env.sandbox.stub(window.parent, '__AMP_MODE').value(mode); | ||
function mockMode(options) { | ||
env.sandbox.stub(window.parent, '__AMP_MODE').value(options); |
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.
Is this line still necessary?
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.
This is the one call where removing the line breaks the test case:
amphtml/test/unit/3p/test-3p-frame.js
Lines 153 to 158 in 5ece445
mockMode({ | |
localDev: true, | |
development: false, | |
test: false, | |
version: '$internalRuntimeVersion$', | |
}); |
It looks like this is specifically because the mode
changes when not mocked via window:
amphtml/src/iframe-attributes.js
Line 90 in 7df04fa
'mode': getModeObject(), |
I propose we leave the stub for now, and in a separate PR, see about updating getModeObject
to reference #core/mode
over getMode(win)
:
Lines 25 to 33 in 7df04fa
export function getModeObject(opt_win) { | |
return { | |
localDev: getMode(opt_win).localDev, | |
development: getMode(opt_win).development, | |
esm: IS_ESM, | |
test: getMode(opt_win).test, | |
rtvVersion: getMode(opt_win).rtvVersion, | |
}; | |
} |
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.
SGTM
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.
It looks like this is not being DCE'd correctly; the component bundle sizes are spiking. Taking a look now
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.
I had seen ~150B increase in some bundles, but I locally built this PR and its merge base and compared the files directly to find no size diff. Looks like an artifact of CI using a different merge base or something similar. Re-approving
Thanks for looking into this! |
This change enables 3p iframe Bento components to reference the mode without having to be on an AMP document.