aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-04-25 08:19:40 -0700
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-04-25 08:19:40 -0700
commit2256d43a32164433431f387ebc7c40597bb10638 (patch)
tree19e69966c73b8353df789e8886f9e18c7e9b49f3
parent947634c9ed2e9f33b884b96686762a1a64a6a083 (diff)
downloadbun-2256d43a32164433431f387ebc7c40597bb10638.tar.gz
bun-2256d43a32164433431f387ebc7c40597bb10638.tar.zst
bun-2256d43a32164433431f387ebc7c40597bb10638.zip
now it works
-rw-r--r--src/bun.js/api/JSBundler.zig4
-rw-r--r--src/bun.js/builtins/cpp/BundlerPluginBuiltins.cpp15
-rw-r--r--src/bun.js/builtins/js/BundlerPlugin.js13
3 files changed, 15 insertions, 17 deletions
diff --git a/src/bun.js/api/JSBundler.zig b/src/bun.js/api/JSBundler.zig
index ae21e7acc..60933f3dc 100644
--- a/src/bun.js/api/JSBundler.zig
+++ b/src/bun.js/api/JSBundler.zig
@@ -795,7 +795,7 @@ pub const JSBundler = struct {
which: JSValue,
) void {
switch (which.to(i32)) {
- 1 => {
+ 0 => {
var this: *JSBundler.Resolve = bun.cast(*Resolve, ctx);
var completion = this.completion orelse return;
this.value = .{
@@ -803,7 +803,7 @@ pub const JSBundler = struct {
};
completion.bundler.onResolveAsync(this);
},
- 0 => {
+ 1 => {
var this: *Load = bun.cast(*Load, ctx);
var completion = this.completion orelse return;
this.value = .{
diff --git a/src/bun.js/builtins/cpp/BundlerPluginBuiltins.cpp b/src/bun.js/builtins/cpp/BundlerPluginBuiltins.cpp
index 22fc70c95..1f2053ad5 100644
--- a/src/bun.js/builtins/cpp/BundlerPluginBuiltins.cpp
+++ b/src/bun.js/builtins/cpp/BundlerPluginBuiltins.cpp
@@ -48,7 +48,7 @@ namespace WebCore {
const JSC::ConstructAbility s_bundlerPluginRunOnResolvePluginsCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
const JSC::ConstructorKind s_bundlerPluginRunOnResolvePluginsCodeConstructorKind = JSC::ConstructorKind::None;
const JSC::ImplementationVisibility s_bundlerPluginRunOnResolvePluginsCodeImplementationVisibility = JSC::ImplementationVisibility::Public;
-const int s_bundlerPluginRunOnResolvePluginsCodeLength = 3287;
+const int s_bundlerPluginRunOnResolvePluginsCodeLength = 3300;
static const JSC::Intrinsic s_bundlerPluginRunOnResolvePluginsCodeIntrinsic = JSC::NoIntrinsic;
const char* const s_bundlerPluginRunOnResolvePluginsCode =
"(function (\n" \
@@ -74,7 +74,7 @@ const char* const s_bundlerPluginRunOnResolvePluginsCode =
"\n" \
" var promiseResult = (async (inputPath, inputNamespace, importer, kind) => {\n" \
" var results = this.onResolve.@get(inputNamespace);\n" \
- " if (!resuls) {\n" \
+ " if (!results) {\n" \
" this.onResolveAsync(internalID, null, null, null);\n" \
" return null;\n" \
" }\n" \
@@ -87,6 +87,7 @@ const char* const s_bundlerPluginRunOnResolvePluginsCode =
" namespace: inputNamespace,\n" \
" kind,\n" \
" });\n" \
+ "\n" \
" while (\n" \
" result &&\n" \
" @isPromise(result) &&\n" \
@@ -108,6 +109,7 @@ const char* const s_bundlerPluginRunOnResolvePluginsCode =
" continue;\n" \
" }\n" \
"\n" \
+ "\n" \
" var {\n" \
" path,\n" \
" namespace: userNamespace = inputNamespace,\n" \
@@ -129,7 +131,6 @@ const char* const s_bundlerPluginRunOnResolvePluginsCode =
" if (!userNamespace) {\n" \
" userNamespace = inputNamespace;\n" \
" }\n" \
- "\n" \
" if (typeof external !== \"boolean\" && !@isUndefinedOrNull(external)) {\n" \
" @throwTypeError(\n" \
" 'onResolve plugins \"external\" field must be boolean or unspecified'\n" \
@@ -140,14 +141,13 @@ const char* const s_bundlerPluginRunOnResolvePluginsCode =
" if (!external) {\n" \
" if (userNamespace === \"file\") {\n" \
" //\n" \
+ " \n" \
" if (path[0] !== \"/\" || path.includes(\"..\")) {\n" \
" @throwTypeError(\n" \
" 'onResolve plugin \"path\" must be absolute when the namespace is \"file\"'\n" \
" );\n" \
" }\n" \
" }\n" \
- "\n" \
- "\n" \
" if (userNamespace === \"dataurl\") {\n" \
" if (!path.startsWith(\"data:\")) {\n" \
" @throwTypeError(\n" \
@@ -156,8 +156,7 @@ const char* const s_bundlerPluginRunOnResolvePluginsCode =
" }\n" \
" }\n" \
" }\n" \
- "\n" \
- " this.onReslveAsync(internalID, path, userNamespace, external);\n" \
+ " this.onResolveAsync(internalID, path, userNamespace, external);\n" \
" return null;\n" \
" }\n" \
" }\n" \
@@ -447,7 +446,7 @@ const char* const s_bundlerPluginRunOnLoadPluginsCode =
" promiseResult.then(\n" \
" () => {},\n" \
" (e) => {\n" \
- " this.addError(internalID, e, 0);\n" \
+ " this.addError(internalID, e, 1);\n" \
" }\n" \
" );\n" \
" }\n" \
diff --git a/src/bun.js/builtins/js/BundlerPlugin.js b/src/bun.js/builtins/js/BundlerPlugin.js
index 7f8170eb2..9fbb323ed 100644
--- a/src/bun.js/builtins/js/BundlerPlugin.js
+++ b/src/bun.js/builtins/js/BundlerPlugin.js
@@ -54,7 +54,7 @@ function runOnResolvePlugins(
var promiseResult = (async (inputPath, inputNamespace, importer, kind) => {
var results = this.onResolve.@get(inputNamespace);
- if (!resuls) {
+ if (!results) {
this.onResolveAsync(internalID, null, null, null);
return null;
}
@@ -67,6 +67,7 @@ function runOnResolvePlugins(
namespace: inputNamespace,
kind,
});
+
while (
result &&
@isPromise(result) &&
@@ -88,6 +89,7 @@ function runOnResolvePlugins(
continue;
}
+
var {
path,
namespace: userNamespace = inputNamespace,
@@ -109,7 +111,6 @@ function runOnResolvePlugins(
if (!userNamespace) {
userNamespace = inputNamespace;
}
-
if (typeof external !== "boolean" && !@isUndefinedOrNull(external)) {
@throwTypeError(
'onResolve plugins "external" field must be boolean or unspecified'
@@ -120,14 +121,13 @@ function runOnResolvePlugins(
if (!external) {
if (userNamespace === "file") {
// TODO: Windows
+
if (path[0] !== "/" || path.includes("..")) {
@throwTypeError(
'onResolve plugin "path" must be absolute when the namespace is "file"'
);
}
}
-
-
if (userNamespace === "dataurl") {
if (!path.startsWith("data:")) {
@throwTypeError(
@@ -136,8 +136,7 @@ function runOnResolvePlugins(
}
}
}
-
- this.onReslveAsync(internalID, path, userNamespace, external);
+ this.onResolveAsync(internalID, path, userNamespace, external);
return null;
}
}
@@ -413,7 +412,7 @@ function runOnLoadPlugins(internalID, path, namespace, defaultLoaderId) {
promiseResult.then(
() => {},
(e) => {
- this.addError(internalID, e, 0);
+ this.addError(internalID, e, 1);
}
);
}