Skip to content

Commit

Permalink
import relative rewrite fix: change __wb_rewrite_import__(url) -> __w…
Browse files Browse the repository at this point in the history
…b_rewrite_import__(base, url)

where base is either empty or the 'import.meta.url' (if used in a module)
if base is provided, resolve url with base to ensure relative urls resolve to correct module-relative url
bump to 3.5.0
part of fix for issue raised in #116
  • Loading branch information
ikreymer committed Mar 28, 2023
1 parent e903398 commit 43ffb10
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@webrecorder/wombat",
"version": "3.4.7",
"version": "3.5.0",
"main": "index.js",
"license": "AGPL-3.0-or-later",
"author": "Ilya Kreymer, Webrecorder Software",
Expand Down
8 changes: 6 additions & 2 deletions src/wombat.js
Original file line number Diff line number Diff line change
Expand Up @@ -5368,8 +5368,12 @@ Wombat.prototype.initCheckThisFunc = function(win) {

Wombat.prototype.initImportWrapperFunc = function(win) {
var wombat = this;
win.____wb_rewrite_import__ = function(url) {
return import(/*webpackIgnore: true*/ wombat.rewriteUrl(url));
win.____wb_rewrite_import__ = function(base, url) {
// if base provided (import.meta.url), use that as base for imports
if (base) {
url = new URL(url, base).href;
}
return import(/*webpackIgnore: true*/ wombat.rewriteUrl(url, false, 'esm_'));
};
};

Expand Down

0 comments on commit 43ffb10

Please sign in to comment.