-
Notifications
You must be signed in to change notification settings - Fork 132
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
Unable to match certain webpack bundles #33
Comments
Fixed, it checks for a few more patterns like |
Another one spotted: exports.id = 885;
exports.ids = [885];
exports.modules = {.../* webpack 5 modules */}; I wonder, is it possible for users to provide extra chunks in AST to support code splitting bundles? |
@j4k0xb This is still unfinished, since |
which one is it? |
See |
This is also something I would love to see, though it probably should be it's own issue.
@j4k0xb Do you mean how they work in webpack/etc itself? Or just in implementing support for them in Not sure if this will be helpful, but this gist has some notes/references I captured while understanding more about it myself:
From a quick GitHub code search, these might be interesting too:
|
The matching logic is here: (() => {
var installedChunks = {
'377': 1
};
__webpack_require__.O.require = chunkId => installedChunks[chunkId];
__webpack_require__.f.require = (chunkId, promises) => {
if (!installedChunks[chunkId]) {
(chunk => {
var moreModules = chunk.modules;
var chunkIds = chunk.ids;
var runtime = chunk.runtime;
for (var moduleId in moreModules) {
if (__webpack_require__.o(moreModules, moduleId)) {
__webpack_require__.m[moduleId] = moreModules[moduleId];
}
}
if (runtime) {
runtime(__webpack_require__);
}
for (var i = 0; i < chunkIds.length; i++) {
installedChunks[chunkIds[i]] = 1;
}
__webpack_require__.O();
})(require(`./${__webpack_require__.u(chunkId)}`));
}
};
})(); |
We may also parse nested webpack chunks: https://github.com/webpack/webpack/tree/main/lib/CompatibilityPlugin.js |
Should also match webpack ESM modules in Sample: https://fars.ee/GIKB.js |
Some unpacked samples for further inspection. Notice how some webpack runtime globals still got persisted (search for regex |
It already converts all kinds of sequences before in |
Found another issue in that bundle (fars.ee/FrBW.js): 71017: module => {
module.exports = require("path");
}, should not be transformed to: module.exports = require( /*webcrack:missing*/"./path.js"); The code needs to be refactored to find references to the webcrack/packages/webcrack/src/unpack/webpack/bundle.ts Lines 26 to 39 in 9180938
|
#50 / deploy-preview-50--webcrack.netlify.app contains a rewrite of the whole matching logic (very experimental)
var __webpack_modules__ = { ... };
// ...
function __webpack_require__(moduleId) {
// ...
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
}
|
Describe the bug
Could not recognize a certain webpack bundle.
Details
Webpack runtime requirements in the sample:
runtimeId = "__webpack_require__.j";
onChunksLoaded = "__webpack_require__.O";
nodeModuleDecorator = "__webpack_require__.nmd";
ensureChunkHandlers = "__webpack_require__.f";
hasOwnProperty = "__webpack_require__.o";
ensureChunk = "__webpack_require__.e";
exports = "__webpack_exports__";
getChunkScriptFilename = "__webpack_require__.u";
definePropertyGetters = "__webpack_require__.d";
compatGetDefaultExport = "__webpack_require__.n";
startup = "__webpack_require__.x";
moduleFactories = "__webpack_require__.m";
All wrapped in an IIFE.
Expected Behaviour
__webpack_require__
and__webpack_modules__
should be inferred from usage, and unpacked correctlyCode
https://fars.ee/FrBW.js
Logs
No response
The text was updated successfully, but these errors were encountered: