-
-
Notifications
You must be signed in to change notification settings - Fork 864
web: Fix extension webpack import not working (close #10981) #19664
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
base: master
Are you sure you want to change the base?
web: Fix extension webpack import not working (close #10981) #19664
Conversation
8b7e49f
to
0c1291a
Compare
return prop in obj && (obj as Record<PropertyKey, unknown>)[prop] !== ""; | ||
} | ||
|
||
// Copied from Webpack: https://github.com/webpack/webpack/blob/f1bdec5cc70236083e45b665831d5d79d6485db7/lib/runtime/AutoPublicPathRuntimeModule.js#L75 |
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 link may be confusing.
It actually comes from webpack automatic publicPath. Specifically refers to get publicPath from the currentScript.src
.
web/packages/extension/src/ruffle.ts
Outdated
@@ -57,6 +58,60 @@ function openInNewTab(swf: URL): void { | |||
window.postMessage(message, "*"); | |||
} | |||
|
|||
function polyfillCurrentScript(): void { |
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 found the relevant code that has used currentScript.src
in these files and make polyfills for these files.
- web/packages/extension/src/ruffle.ts
- web/packages/core/src/current-script.ts
web/packages/selfhosted/js/ruffle.js(Intentionally ignored because the extension never use it)
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 find the name confusing. We aren't polyfilling currentScript
, but something webpack related?
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.
Actually can you please add a comment outlining what we are doing here?
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 changed the function name polyfillCurrentScript
to polyfillCurrentScriptWebpackPublicPath
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.
Can you also add a comment as suggested? If possible, I'd suggest it describe both what we are doing and why we need to do it.
web/packages/extension/src/ruffle.ts
Outdated
); | ||
} | ||
} | ||
// TODO: Process other situations when mask url not webkit-masked-url://hidden/ |
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.
Since the current problems are relatively easy to solve in a targeted manner, I made a simple fix. But this may not be the best or most general solution, so I left a todo here
web/packages/extension/src/ruffle.ts
Outdated
}; | ||
// Reset webpack public path should be safe when it is using mask url | ||
if ("webkit-masked-url://hidden/" === scriptUrl) { | ||
const webpackCurrentPublicPath = __webpack_public_path__; |
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.
The __webpack_public_path__
runtime code is actually like __webpack_require__.p
, so it could be set and get. But this is a webpack only logic.
0c1291a
to
fca80bc
Compare
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.
Note: My review comes from the perspective of suggesting simplications to the added code, without actually considering how much of the added code is necessary. My knowledge of webpack is unfortunately limited, so hopefully someone else can review from that perspective.
e96bdc7
to
9404730
Compare
Thank you very much for the review. I have modified my code as required and re-pushed it. Please review it again when you have time |
9404730
to
bc02471
Compare
bc02471
to
fb16b96
Compare
Close #10981
Continue with PR #19348, this PR is used to fix the
ruffle.js
webpack import module.