mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 18:38:55 +00:00
webpack test and add empty prototype prop to module (#3421)
This commit is contained in:
@@ -142,10 +142,10 @@ void generateNodeModuleModule(JSC::JSGlobalObject *globalObject,
|
||||
exportValues.append(
|
||||
jsCast<Zig::GlobalObject *>(globalObject)->lazyRequireCacheObject());
|
||||
|
||||
exportNames.append(JSC::Identifier::fromString(vm, "builtinModules"_s));
|
||||
exportNames.append(JSC::Identifier::fromString(vm, "prototype"_s));
|
||||
exportValues.append(constructEmptyObject(globalObject));
|
||||
|
||||
exportNames.append(JSC::Identifier::fromString(vm, "globalPaths"_s));
|
||||
exportValues.append(JSC::constructEmptyArray(globalObject, 0));
|
||||
exportNames.append(JSC::Identifier::fromString(vm, "builtinModules"_s));
|
||||
|
||||
JSC::JSArray *builtinModules = JSC::JSArray::create(
|
||||
vm,
|
||||
@@ -167,5 +167,8 @@ void generateNodeModuleModule(JSC::JSGlobalObject *globalObject,
|
||||
builtinModules->putDirectIndex(globalObject, 6,
|
||||
JSC::jsString(vm, String("bun:sqlite"_s)));
|
||||
exportValues.append(builtinModules);
|
||||
|
||||
exportNames.append(JSC::Identifier::fromString(vm, "globalPaths"_s));
|
||||
exportValues.append(JSC::constructEmptyArray(globalObject, 0));
|
||||
}
|
||||
} // namespace Zig
|
||||
|
||||
7
test/js/third_party/webpack/package.json
vendored
Normal file
7
test/js/third_party/webpack/package.json
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"name": "webpack-test",
|
||||
"version": "2.0.0",
|
||||
"dependencies": {
|
||||
"webpack": "5.88.0"
|
||||
}
|
||||
}
|
||||
11
test/js/third_party/webpack/test.js
vendored
Normal file
11
test/js/third_party/webpack/test.js
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
import { world } from "./world.js";
|
||||
|
||||
function component() {
|
||||
const element = document.createElement("div");
|
||||
|
||||
element.innerHTML = "hello " + world();
|
||||
|
||||
return element;
|
||||
}
|
||||
|
||||
document.body.appendChild(component());
|
||||
27
test/js/third_party/webpack/webpack.test.ts
vendored
Normal file
27
test/js/third_party/webpack/webpack.test.ts
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
import { bunExe, bunEnv } from "harness";
|
||||
import { existsSync, rmdirSync } from "fs";
|
||||
import { join } from "path";
|
||||
|
||||
afterEach(() => {
|
||||
rmdirSync(join(import.meta.dir, "dist"), { recursive: true });
|
||||
});
|
||||
|
||||
test("webpack works", () => {
|
||||
Bun.spawnSync({
|
||||
cmd: [bunExe(), "-b", "webpack", "--entry", "./test.js", "-o", "./dist/test1/main.js"],
|
||||
cwd: import.meta.dir,
|
||||
env: bunEnv,
|
||||
});
|
||||
|
||||
expect(existsSync(join(import.meta.dir, "dist", "test1/main.js"))).toBe(true);
|
||||
});
|
||||
|
||||
test("webpack --watch works", async () => {
|
||||
Bun.spawnSync({
|
||||
cmd: ["timeout", "3", bunExe(), "-b", "webpack", "--entry", "./test.js", "-o", "./dist/test2/main.js", "--watch"],
|
||||
cwd: import.meta.dir,
|
||||
env: bunEnv,
|
||||
});
|
||||
|
||||
expect(existsSync(join(import.meta.dir, "dist", "test2/main.js"))).toBe(true);
|
||||
});
|
||||
3
test/js/third_party/webpack/world.js
vendored
Normal file
3
test/js/third_party/webpack/world.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export function world() {
|
||||
return "world";
|
||||
}
|
||||
@@ -23,7 +23,9 @@
|
||||
"svelte": "^3.55.1",
|
||||
"typescript": "^5.0.2",
|
||||
"undici": "^5.20.0",
|
||||
"vitest": "^0.32.2"
|
||||
"vitest": "^0.32.2",
|
||||
"webpack": "5.88.0",
|
||||
"webpack-cli": "4.7.2"
|
||||
},
|
||||
"private": true,
|
||||
"scripts": {
|
||||
|
||||
Reference in New Issue
Block a user