- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Worked on feedbacks, added example modules
Showing
16 changed files
with
1,338 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
patch_cache_in_browser(arguments[4], arguments[5]) | ||
|
||
function patch_cache_in_browser (source_cache, module_cache) { | ||
for (const key of Object.keys(source_cache)) { | ||
const [module, names] = source_cache[key] | ||
const dependencies = names || {} | ||
source_cache[key][0] = patch(module, dependencies) | ||
} | ||
function patch (module, dependencies) { | ||
const MAP = {} | ||
for (const [name, number] of Object.entries(dependencies)) MAP[name] = number | ||
return (...args) => { | ||
const original = args[0] | ||
require.cache = module_cache | ||
require.resolve = resolve | ||
args[0] = require | ||
return module(...args) | ||
function require (name) { | ||
const identifier = resolve(name) | ||
if (require.cache[identifier]) return require.cache[identifier] | ||
const exports = require.cache[identifier] = original(name) | ||
return exports | ||
} | ||
} | ||
function resolve (name) { return MAP[name] } | ||
} | ||
} | ||
require('./page') // or whatever is otherwise the main entry of our project |
Oops, something went wrong.