mirror of
https://github.com/oven-sh/bun
synced 2026-02-18 06:41:50 +00:00
Compare commits
64 Commits
bun-v0.0.2
...
bun-v0.0.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
940570af59 | ||
|
|
bdfb5a91b1 | ||
|
|
29b986684d | ||
|
|
e48a0877ef | ||
|
|
22837d69b7 | ||
|
|
af306b523b | ||
|
|
ba20fd7566 | ||
|
|
6d1330d601 | ||
|
|
f3be0c79c2 | ||
|
|
10c01af692 | ||
|
|
a68a1983cf | ||
|
|
90a647fb72 | ||
|
|
3cbf209d5b | ||
|
|
bee45c4fdc | ||
|
|
61202cb464 | ||
|
|
0091944161 | ||
|
|
78cd857bf6 | ||
|
|
4fe1b4df1c | ||
|
|
2a1235c9db | ||
|
|
4bb41b95a8 | ||
|
|
f78f4854a4 | ||
|
|
ff01dfa03d | ||
|
|
638b204d1e | ||
|
|
58e88c4aed | ||
|
|
8433919342 | ||
|
|
8150b9aeba | ||
|
|
01601fc8a7 | ||
|
|
7b24042d5f | ||
|
|
2177dda242 | ||
|
|
0585c86390 | ||
|
|
528caab47c | ||
|
|
b150df34e0 | ||
|
|
da80c3b309 | ||
|
|
e8804bd80f | ||
|
|
2300886008 | ||
|
|
57ed3c89a2 | ||
|
|
1a284a1c94 | ||
|
|
f12dd51c00 | ||
|
|
e00c1e99d6 | ||
|
|
39323b46ba | ||
|
|
9dff80aeee | ||
|
|
9f7d05bab4 | ||
|
|
53c0a4b568 | ||
|
|
8f460a9be3 | ||
|
|
204b07f46b | ||
|
|
a48a02bade | ||
|
|
2326a1e105 | ||
|
|
c4dc6d9bff | ||
|
|
6213a73e6f | ||
|
|
9c109b744f | ||
|
|
42c1d54b3f | ||
|
|
5e634cd612 | ||
|
|
79c7fe0f7a | ||
|
|
8e86d2cf1d | ||
|
|
4e12a4c013 | ||
|
|
e869cdca9f | ||
|
|
ab565f1a3c | ||
|
|
90cd3bf4cb | ||
|
|
9752ee8819 | ||
|
|
9f1e0660dd | ||
|
|
7c05bb7d1d | ||
|
|
bb0faacf06 | ||
|
|
9ae35ec581 | ||
|
|
b1ca1eb228 |
35
Makefile
35
Makefile
@@ -14,6 +14,8 @@ DEBUG_BUN := $(shell realpath $(DEBUG_BIN)/bun-debug)
|
||||
BUILD_ID := $(shell cat ./build-id)
|
||||
PACKAGE_JSON_VERSION := 0.0.$(BUILD_ID)
|
||||
BUN_BUILD_TAG := bun-v$(PACKAGE_JSON_VERSION)
|
||||
CC := clang
|
||||
CXX := clang++
|
||||
|
||||
bun: vendor build-obj bun-link-lld-release
|
||||
|
||||
@@ -113,21 +115,24 @@ test-install:
|
||||
|
||||
test-all: test-install test-with-hmr test-no-hmr
|
||||
|
||||
copy-test-node-modules:
|
||||
rm -rf integration/snippets/package-json-exports/node_modules
|
||||
cp -r integration/snippets/package-json-exports/_node_modules_copy integration/snippets/package-json-exports/node_modules
|
||||
kill-bun:
|
||||
-killall -9 bun bun-debug
|
||||
|
||||
test-with-hmr: kill-bun
|
||||
test-with-hmr: kill-bun copy-test-node-modules
|
||||
BUN_BIN=$(RELEASE_BUN) node integration/scripts/browser.js
|
||||
|
||||
test-no-hmr: kill-bun
|
||||
test-no-hmr: kill-bun copy-test-node-modules
|
||||
-killall bun -9;
|
||||
DISABLE_HMR="DISABLE_HMR" BUN_BIN=$(RELEASE_BUN) node integration/scripts/browser.js
|
||||
|
||||
test-dev-with-hmr:
|
||||
test-dev-with-hmr: copy-test-node-modules
|
||||
-killall bun-debug -9;
|
||||
BUN_BIN=$(DEBUG_BUN) node integration/scripts/browser.js
|
||||
|
||||
test-dev-no-hmr:
|
||||
test-dev-no-hmr: copy-test-node-modules
|
||||
-killall bun-debug -9;
|
||||
DISABLE_HMR="DISABLE_HMR" BUN_BIN=$(DEBUG_BUN) node integration/scripts/browser.js
|
||||
|
||||
@@ -136,22 +141,22 @@ test-dev-all: test-dev-with-hmr test-dev-no-hmr
|
||||
test-dev: test-dev-with-hmr
|
||||
|
||||
jsc-copy-headers:
|
||||
find src/JavaScript/jsc/WebKit/WebKitBuild/Release/JavaScriptCore/Headers/JavaScriptCore/ -name "*.h" -exec cp {} src/JavaScript/jsc/WebKit/WebKitBuild/Release/JavaScriptCore/PrivateHeaders/JavaScriptCore \;
|
||||
find src/javascript/jsc/WebKit/WebKitBuild/Release/JavaScriptCore/Headers/JavaScriptCore/ -name "*.h" -exec cp {} src/JavaScript/jsc/WebKit/WebKitBuild/Release/JavaScriptCore/PrivateHeaders/JavaScriptCore \;
|
||||
|
||||
jsc-build-mac-compile:
|
||||
cd src/javascript/jsc/WebKit && ICU_INCLUDE_DIRS="$(HOMEBREW_PREFIX)opt/icu4c/include" ./Tools/Scripts/build-jsc --jsc-only --cmakeargs="-DENABLE_STATIC_JSC=ON -DCMAKE_BUILD_TYPE=relwithdebinfo"
|
||||
|
||||
jsc-build-linux-compile:
|
||||
cd src/javascript/jsc/WebKit && ./Tools/Scripts/build-jsc --jsc-only --cmakeargs="-DENABLE_STATIC_JSC=ON -DCMAKE_BUILD_TYPE=relwithdebinfo
|
||||
CC=$(CC) CXX=$(CXX) cd src/javascript/jsc/WebKit && ./Tools/Scripts/build-jsc --jsc-only --cmakeargs="-DENABLE_STATIC_JSC=ON -DCMAKE_BUILD_TYPE=relwithdebinfo"
|
||||
|
||||
jsc-build-mac: jsc-build-mac-compile jsc-build-mac-copy
|
||||
|
||||
jsc-build-linux: jsc-build-linux-compile jsc-build-mac-copy
|
||||
|
||||
jsc-build-mac-copy:
|
||||
cp src/JavaScript/jsc/WebKit/WebKitBuild/Release/lib/libJavaScriptCore.a src/deps/libJavaScriptCore.a
|
||||
cp src/JavaScript/jsc/WebKit/WebKitBuild/Release/lib/libWTF.a src/deps/libWTF.a
|
||||
cp src/JavaScript/jsc/WebKit/WebKitBuild/Release/lib/libbmalloc.a src/deps/libbmalloc.a
|
||||
cp src/javascript/jsc/WebKit/WebKitBuild/Release/lib/libJavaScriptCore.a src/deps/libJavaScriptCore.a
|
||||
cp src/javascript/jsc/WebKit/WebKitBuild/Release/lib/libWTF.a src/deps/libWTF.a
|
||||
cp src/javascript/jsc/WebKit/WebKitBuild/Release/lib/libbmalloc.a src/deps/libbmalloc.a
|
||||
|
||||
JSC_FILES := src/deps/libJavaScriptCore.a \
|
||||
src/deps/libWTF.a \
|
||||
@@ -213,7 +218,7 @@ mimalloc:
|
||||
cd src/deps/mimalloc; cmake .; make;
|
||||
|
||||
bun-link-lld-debug:
|
||||
clang++ $(BUN_LLD_FLAGS) \
|
||||
$(CXX) $(BUN_LLD_FLAGS) \
|
||||
$(DEBUG_BIN)/bun-debug.o \
|
||||
-Wl,-dead_strip \
|
||||
-ftls-model=local-exec \
|
||||
@@ -221,7 +226,7 @@ bun-link-lld-debug:
|
||||
-o $(DEBUG_BIN)/bun-debug
|
||||
|
||||
bun-link-lld-release:
|
||||
clang++ $(BUN_LLD_FLAGS) \
|
||||
$(CXX) $(BUN_LLD_FLAGS) \
|
||||
$(BIN_DIR)/bun.o \
|
||||
-o $(BIN_DIR)/bun \
|
||||
-Wl,-dead_strip \
|
||||
@@ -231,7 +236,7 @@ bun-link-lld-release:
|
||||
rm $(BIN_DIR)/bun.o
|
||||
|
||||
bun-link-lld-release-aarch64:
|
||||
clang++ $(BUN_LLD_FLAGS) \
|
||||
$(CXX) $(BUN_LLD_FLAGS) \
|
||||
build/macos-aarch64/bun.o \
|
||||
-o build/macos-aarch64/bun \
|
||||
-Wl,-dead_strip \
|
||||
@@ -242,14 +247,14 @@ bun-link-lld-release-aarch64:
|
||||
# We do this outside of build.zig for performance reasons
|
||||
# The C compilation stuff with build.zig is really slow and we don't need to run this as often as the rest
|
||||
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp
|
||||
clang++ -c -o $@ $< \
|
||||
$(CXX) -c -o $@ $< \
|
||||
$(CLANG_FLAGS) \
|
||||
-O1
|
||||
|
||||
sizegen:
|
||||
clang++ src/javascript/jsc/headergen/sizegen.cpp -o /tmp/sizegen $(CLANG_FLAGS) -O1
|
||||
$(CXX) src/javascript/jsc/headergen/sizegen.cpp -o /tmp/sizegen $(CLANG_FLAGS) -O1
|
||||
/tmp/sizegen > src/javascript/jsc/bindings/sizes.zig
|
||||
|
||||
picohttp:
|
||||
clang -O3 -g -c src/deps/picohttpparser.c -Isrc/deps -o src/deps/picohttpparser.o; cd ../../
|
||||
$(CC) -O3 -g -c src/deps/picohttpparser.c -Isrc/deps -o src/deps/picohttpparser.o; cd ../../
|
||||
|
||||
|
||||
107
README.md
107
README.md
@@ -125,7 +125,7 @@ Bun is a project with incredibly large scope, and it's early days.
|
||||
|
||||
| Feature | In |
|
||||
| ---------------------------------------------------------------------------------------------------------------------- | -------------- |
|
||||
| Symlinks | Resolver |
|
||||
| ~Symlinks~ | Resolver |
|
||||
| [Finish Fast Refresh](https://github.com/Jarred-Sumner/bun/issues/18) | JSX Transpiler |
|
||||
| Source Maps | JavaScript |
|
||||
| Source Maps | CSS |
|
||||
@@ -411,6 +411,111 @@ For developing frameworks, you can also do `bun bun --use ./relative-path-to-fra
|
||||
|
||||
If you're interested in adding a framework integration, please reach out. There's a lot here and it's not entirely documented yet.
|
||||
|
||||
# Reference
|
||||
|
||||
### `bun bun`
|
||||
|
||||
Run `bun bun ./path-to.js` to generate a `node_modules.bun` file containing all imported dependencies (recursively).
|
||||
|
||||
**Why bundle?**
|
||||
|
||||
- For browsers, loading entire apps without bundling dependencies is typically slow. With a fast bundler & transpiler, the bottleneck eventually becomes the web browser's ability to run many network requests concurrently. There are many workarounds for this. `<link rel="modulepreload">`, HTTP/3, etc but none are more effective than bundling. If you have reproducible evidence to the contrary, feel free to submit an issue. It would be better if bundling wasn't necessary.
|
||||
- On the server, bundling reduces the number of filesystem lookups to load JavaScript. While filesystem lookups are faster than HTTP requests, there's still overhead.
|
||||
|
||||
**What is `.bun`?**
|
||||
|
||||
The `.bun` file contains:
|
||||
|
||||
- all the bundled source code
|
||||
- all the bundled source code metadata
|
||||
- project metadata & configuration
|
||||
|
||||
Here are some of the questions `.bun` files answer:
|
||||
|
||||
- when I import `react/index.js`, where in the `.bun` is the code for that? (not resolving, just the code)
|
||||
- what modules of a package are used?
|
||||
- what framework is used? (e.g. Next.js)
|
||||
- where is the routes directory?
|
||||
- how big is each imported dependency?
|
||||
- what is the hash of the bundle's contents? (for etags)
|
||||
- what is the name & version of every npm package exported in this bundle?
|
||||
- what modules from which packages are used in this project? ("project" defined as all the entry points used to generate the .bun)
|
||||
|
||||
All in one file.
|
||||
|
||||
It's a little like a build cache, but designed for reuse. I hope people will eventually check it into version control so their coworkers don't have to run `npm install` as often.
|
||||
|
||||
##### Position-independent code
|
||||
|
||||
From a design perspective, the most important part of the `.bun` format is how code is organized. Each module is exported by a hash like this:
|
||||
|
||||
```js
|
||||
// preact/dist/preact.module.js
|
||||
export var $eb6819b = $$m({
|
||||
"preact/dist/preact.module.js": (module, exports) => {
|
||||
var n, l, u, i, t, o, r, f, e = {}, c = [], s = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;
|
||||
// ... rest of code
|
||||
```
|
||||
|
||||
This makes bundled modules [position-independent](https://en.wikipedia.org/wiki/Position-independent_code). In theory, one could import only the exact modules in-use without reparsing code and without generating a new bundle. One bundle can dynamically become many bundles comprising only the modules in use on the webpage. Thanks to the metadata with the byte offsets, a web server can send each module to browsers [zero-copy](https://en.wikipedia.org/wiki/Zero-copy) using [sendfile](https://man7.org/linux/man-pages/man2/sendfile.2.html). Bun itself is not quite this smart yet, but these optimizations would be useful in production and potentially very useful for React Server Components.
|
||||
|
||||
To see the schema inside, have a look at [`JavascriptBundleContainer`](./src/api/schema.d.ts#:~:text=export%20interface-,JavascriptBundleContainer,-%7B). You can find JavaScript bindings to read the metadata in [src/api/schema.js](./src/api/schema.js). This is not really an API yet. It's missing the part where it gets the binary data from the bottom of the file. Someday, I want this to be usable by other tools too.
|
||||
|
||||
**Where is the code?**
|
||||
|
||||
`.bun` files are marked as executable.
|
||||
|
||||
To print out the code, run `./node_modules.bun` in your terminal or run `bun ./path-to-node_modules.bun`.
|
||||
|
||||
Here is a copy-pastable example:
|
||||
|
||||
```bash
|
||||
./node_modules.bun > node_modules.js
|
||||
```
|
||||
|
||||
This works because every `.bun` file starts with this:
|
||||
|
||||
```bash
|
||||
#!/usr/bin/env bun
|
||||
```
|
||||
|
||||
To deploy to production with Bun, you'll want to get the code from the `.bun` file and stick that somewhere your web server can find it (or if you're using Vercel or a Rails app, in a `public` folder).
|
||||
|
||||
Note that `.bun` is a binary file format, so just opening it in VSCode or vim might render strangely.
|
||||
|
||||
**Advanced**
|
||||
|
||||
By default, `bun bun` only bundles external dependencies that are `import`ed or `require`d in either app code or another external dependency. An "external depenendency" is defined as, "A JavaScript-like file that has `/node_modules/` in the resolved file path and a corresponding `package.json`".
|
||||
|
||||
To force bun to bundle packages which are not located in a `node_modules` folder (i.e. the final, resolved path following all symlinks), add a `bun` section to the root project's `package.json` with `alwaysBundle` set to an array of package names to always bundle. Here's an example:
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "my-package-name-in-here",
|
||||
"bun": {
|
||||
"alwaysBundle": ["@mybigcompany/my-workspace-package"]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Bundled dependencies are not eligible for Hot Module Reloading. The code is served to browsers & Bun.js verbatim. But, in the future, it may be sectioned off into only parts of the bundle being used. That's possible in the current version of the `.bun` file (so long as you know which files are necessary), but it's not implemented yet. Longer-term, it will include all `import` and `export` of each module inside.
|
||||
|
||||
**What is the module ID hash?**
|
||||
|
||||
The `$eb6819b` hash used here:
|
||||
|
||||
```js
|
||||
export var $eb6819b = $$m({
|
||||
```
|
||||
|
||||
Is generated like this:
|
||||
|
||||
1. Murmur3 32 bit hash of `package.name@package.version`. This is the hash uniquely identifying the npm package.
|
||||
2. Wyhash 64 of the `package.hash` + `package_path`. `package_path` means "relative to the root of the npm package, where is the module imported?". For example, if you imported `react/jsx-dev-runtime.js`, the `package_path` is `jsx-dev-runtime.js`. `react-dom/cjs/react-dom.development.js` would be `cjs/react-dom.development.js`
|
||||
3. Truncate the hash generated above to a `u32`
|
||||
|
||||
The implementation details of this module ID hash will vary between versions of Bun. The important part is the metadata contains the module IDs, the package paths, and the package hashes so it shouldn't really matter in practice if other tooling wants to make use of any of this.
|
||||
|
||||
# Credits
|
||||
|
||||
- While written in Zig instead of Go, Bun's JS transpiler, CSS lexer, and node module resolver source code is based off of @evanw's esbuild project. @evanw did a fantastic job with esbuild.
|
||||
|
||||
@@ -20,6 +20,7 @@ const bunProcess = child_process.spawn(bunExec, bunFlags, {
|
||||
shell: false,
|
||||
});
|
||||
console.log("$", bunExec, bunFlags.join(" "));
|
||||
const isDebug = bunExec.endsWith("-debug");
|
||||
|
||||
bunProcess.stderr.pipe(process.stderr);
|
||||
bunProcess.stdout.pipe(process.stdout);
|
||||
@@ -32,12 +33,27 @@ process.on("beforeExit", () => {
|
||||
});
|
||||
|
||||
function writeSnapshot(name, code) {
|
||||
const file = path.join(
|
||||
__dirname,
|
||||
"../snapshots" + (DISABLE_HMR ? "-no-hmr" : ""),
|
||||
name
|
||||
let file = path.join(__dirname, "../snapshots", name);
|
||||
|
||||
if (!DISABLE_HMR) {
|
||||
file =
|
||||
file.substring(0, file.length - path.extname(file).length) +
|
||||
".hmr" +
|
||||
path.extname(file);
|
||||
}
|
||||
|
||||
if (!fs.existsSync(path.dirname(file))) {
|
||||
fs.mkdirSync(path.dirname(file), { recursive: true });
|
||||
}
|
||||
|
||||
fs.writeFileSync(
|
||||
isDebug
|
||||
? file.substring(0, file.length - path.extname(file).length) +
|
||||
".debug" +
|
||||
path.extname(file)
|
||||
: file,
|
||||
code
|
||||
);
|
||||
fs.writeFileSync(file, code);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
@@ -95,6 +111,12 @@ async function main() {
|
||||
"/ts-fallback-rewrite-works.js",
|
||||
"/tsx-fallback-rewrite-works.js",
|
||||
"/lodash-regexp.js",
|
||||
"/unicode-identifiers.js",
|
||||
"/string-escapes.js",
|
||||
"/package-json-exports/index.js",
|
||||
"/array-args-with-default-values.js",
|
||||
"/forbid-in-is-correct.js",
|
||||
"/code-simplification-neql-define.js",
|
||||
];
|
||||
tests.reverse();
|
||||
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
*.js
|
||||
@@ -0,0 +1,25 @@
|
||||
var lines;
|
||||
const data = () => lines.map(([a = null, b = null, c = null, d = null]) => ({
|
||||
a,
|
||||
b,
|
||||
c,
|
||||
d
|
||||
}));
|
||||
export function test() {
|
||||
let ran = false;
|
||||
lines = [
|
||||
[undefined, undefined, undefined, undefined],
|
||||
[undefined, undefined, undefined, undefined],
|
||||
[undefined, undefined, undefined, undefined],
|
||||
[undefined, undefined, undefined, undefined]
|
||||
];
|
||||
for (let foo of data()) {
|
||||
console.assert(foo.a === null);
|
||||
console.assert(foo.b === null);
|
||||
console.assert(foo.c === null);
|
||||
console.assert(foo.d === null);
|
||||
ran = true;
|
||||
}
|
||||
console.assert(ran);
|
||||
testDone(import.meta.url);
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
import {
|
||||
__HMRModule as HMR
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
import {
|
||||
__HMRClient as Bun
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
Bun.activate(true);
|
||||
|
||||
var hmr = new HMR(3474597122, "array-args-with-default-values.js"), exports = hmr.exports;
|
||||
(hmr._load = function() {
|
||||
var lines;
|
||||
const data = () => lines.map(([a = null, b = null, c = null, d = null]) => ({
|
||||
a,
|
||||
b,
|
||||
c,
|
||||
d
|
||||
}));
|
||||
function test() {
|
||||
let ran = false;
|
||||
lines = [
|
||||
[undefined, undefined, undefined, undefined],
|
||||
[undefined, undefined, undefined, undefined],
|
||||
[undefined, undefined, undefined, undefined],
|
||||
[undefined, undefined, undefined, undefined]
|
||||
];
|
||||
for (let foo of data()) {
|
||||
console.assert(foo.a === null);
|
||||
console.assert(foo.b === null);
|
||||
console.assert(foo.c === null);
|
||||
console.assert(foo.d === null);
|
||||
ran = true;
|
||||
}
|
||||
console.assert(ran);
|
||||
testDone(import.meta.url);
|
||||
}
|
||||
hmr.exportAll({
|
||||
test: () => test
|
||||
});
|
||||
})();
|
||||
var $$hmr_test = hmr.exports.test;
|
||||
hmr._update = function(exports) {
|
||||
$$hmr_test = exports.test;
|
||||
};
|
||||
|
||||
export {
|
||||
$$hmr_test as test
|
||||
};
|
||||
47
integration/snapshots/array-args-with-default-values.hmr.js
Normal file
47
integration/snapshots/array-args-with-default-values.hmr.js
Normal file
@@ -0,0 +1,47 @@
|
||||
import {
|
||||
__HMRModule as HMR
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
import {
|
||||
__HMRClient as Bun
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
Bun.activate(false);
|
||||
|
||||
var hmr = new HMR(3474597122, "array-args-with-default-values.js"), exports = hmr.exports;
|
||||
(hmr._load = function() {
|
||||
var lines;
|
||||
const data = () => lines.map(([a = null, b = null, c = null, d = null]) => ({
|
||||
a,
|
||||
b,
|
||||
c,
|
||||
d
|
||||
}));
|
||||
function test() {
|
||||
let ran = false;
|
||||
lines = [
|
||||
[undefined, undefined, undefined, undefined],
|
||||
[undefined, undefined, undefined, undefined],
|
||||
[undefined, undefined, undefined, undefined],
|
||||
[undefined, undefined, undefined, undefined]
|
||||
];
|
||||
for (let foo of data()) {
|
||||
console.assert(foo.a === null);
|
||||
console.assert(foo.b === null);
|
||||
console.assert(foo.c === null);
|
||||
console.assert(foo.d === null);
|
||||
ran = true;
|
||||
}
|
||||
console.assert(ran);
|
||||
testDone(import.meta.url);
|
||||
}
|
||||
hmr.exportAll({
|
||||
test: () => test
|
||||
});
|
||||
})();
|
||||
var $$hmr_test = hmr.exports.test;
|
||||
hmr._update = function(exports) {
|
||||
$$hmr_test = exports.test;
|
||||
};
|
||||
|
||||
export {
|
||||
$$hmr_test as test
|
||||
};
|
||||
25
integration/snapshots/array-args-with-default-values.js
Normal file
25
integration/snapshots/array-args-with-default-values.js
Normal file
@@ -0,0 +1,25 @@
|
||||
var lines;
|
||||
const data = () => lines.map(([a = null, b = null, c = null, d = null]) => ({
|
||||
a,
|
||||
b,
|
||||
c,
|
||||
d
|
||||
}));
|
||||
export function test() {
|
||||
let ran = false;
|
||||
lines = [
|
||||
[undefined, undefined, undefined, undefined],
|
||||
[undefined, undefined, undefined, undefined],
|
||||
[undefined, undefined, undefined, undefined],
|
||||
[undefined, undefined, undefined, undefined]
|
||||
];
|
||||
for (let foo of data()) {
|
||||
console.assert(foo.a === null);
|
||||
console.assert(foo.b === null);
|
||||
console.assert(foo.c === null);
|
||||
console.assert(foo.d === null);
|
||||
ran = true;
|
||||
}
|
||||
console.assert(ran);
|
||||
testDone(import.meta.url);
|
||||
}
|
||||
30
integration/snapshots/bundled-entry-point.hmr.debug.js
Normal file
30
integration/snapshots/bundled-entry-point.hmr.debug.js
Normal file
@@ -0,0 +1,30 @@
|
||||
import {
|
||||
__require as require
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
import {
|
||||
__HMRModule as HMR
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
import {
|
||||
__HMRClient as Bun
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
import * as $bbcd215f from "http://localhost:8080/node_modules/react/index.js";
|
||||
Bun.activate(true);
|
||||
|
||||
var hmr = new HMR(3012834585, "bundled-entry-point.js"), exports = hmr.exports;
|
||||
(hmr._load = function() {
|
||||
var hello = null ?? "world";
|
||||
function test() {
|
||||
return testDone(import.meta.url);
|
||||
}
|
||||
hmr.exportAll({
|
||||
test: () => test
|
||||
});
|
||||
})();
|
||||
var $$hmr_test = hmr.exports.test;
|
||||
hmr._update = function(exports) {
|
||||
$$hmr_test = exports.test;
|
||||
};
|
||||
|
||||
export {
|
||||
$$hmr_test as test
|
||||
};
|
||||
30
integration/snapshots/bundled-entry-point.hmr.js
Normal file
30
integration/snapshots/bundled-entry-point.hmr.js
Normal file
@@ -0,0 +1,30 @@
|
||||
import {
|
||||
__require as require
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
import {
|
||||
__HMRModule as HMR
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
import {
|
||||
__HMRClient as Bun
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
import * as $bbcd215f from "http://localhost:8080/node_modules/react/index.js";
|
||||
Bun.activate(false);
|
||||
|
||||
var hmr = new HMR(3012834585, "bundled-entry-point.js"), exports = hmr.exports;
|
||||
(hmr._load = function() {
|
||||
var hello = null ?? "world";
|
||||
function test() {
|
||||
return testDone(import.meta.url);
|
||||
}
|
||||
hmr.exportAll({
|
||||
test: () => test
|
||||
});
|
||||
})();
|
||||
var $$hmr_test = hmr.exports.test;
|
||||
hmr._update = function(exports) {
|
||||
$$hmr_test = exports.test;
|
||||
};
|
||||
|
||||
export {
|
||||
$$hmr_test as test
|
||||
};
|
||||
@@ -1,30 +1,9 @@
|
||||
import {
|
||||
__require as require
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
import {
|
||||
__HMRModule as HMR
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
import {
|
||||
__HMRClient as Bun
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
import * as $bbcd215f from "http://localhost:8080/node_modules/react/index.js";
|
||||
Bun.activate(false);
|
||||
var hello = null ?? "world";
|
||||
|
||||
var hmr = new HMR(3012834585, "bundled-entry-point.js"), exports = hmr.exports;
|
||||
(hmr._load = function() {
|
||||
var hello = null ?? "world";
|
||||
function test() {
|
||||
return testDone(import.meta.url);
|
||||
}
|
||||
hmr.exportAll({
|
||||
test: () => test
|
||||
});
|
||||
})();
|
||||
var $$hmr_test = hmr.exports.test;
|
||||
hmr._update = function(exports) {
|
||||
$$hmr_test = exports.test;
|
||||
};
|
||||
|
||||
export {
|
||||
$$hmr_test as test
|
||||
};
|
||||
export function test() {
|
||||
return testDone(import.meta.url);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
import {
|
||||
__require as require
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
import {
|
||||
__cJS2eSM
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
import * as _login_b977_0 from "http://localhost:8080/_login.js";
|
||||
import * as _login_b977_1 from "http://localhost:8080/_login.js";
|
||||
import _login from "http://localhost:8080/_login.js";
|
||||
import _auth from "http://localhost:8080/_auth.js";
|
||||
import * as _loginReally from "http://localhost:8080/_login.js";
|
||||
import * as _loginReally2 from "http://localhost:8080/_login.js";
|
||||
import * as _authReally from "http://localhost:8080/_auth.js";
|
||||
|
||||
export default __cJS2eSM(function(module, exports) {
|
||||
;
|
||||
|
||||
;
|
||||
;
|
||||
;
|
||||
;
|
||||
module.exports.iAmCommonJs = true;
|
||||
exports.YouAreCommonJS = true;
|
||||
require(_login_b977_0);
|
||||
require(_login_b977_1);
|
||||
Object.defineProperty(module.exports,"login",{get: () => _login, enumerable: true, configurable: true});
|
||||
var test = function test() {
|
||||
return testDone(import.meta.url);
|
||||
};
|
||||
Object.defineProperty(module.exports,"test",{get: () => test, enumerable: true, configurable: true});
|
||||
var foo, bar;
|
||||
Object.defineProperties(module.exports,{'foo': {get: () => foo, set: ($_newValue) => {foo = $_newValue;}, enumerable: true, configurable: true},
|
||||
'bar': {get: () => bar, set: ($_newValue) => {bar = $_newValue;}, enumerable: true, configurable: true}});
|
||||
}, "cjs-transform-shouldnt-have-static-imports-in-cjs-function.js");
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
import {
|
||||
__require as require
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
import {
|
||||
__cJS2eSM
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
import * as _login_b977_0 from "http://localhost:8080/_login.js";
|
||||
import * as _login_b977_1 from "http://localhost:8080/_login.js";
|
||||
import _login from "http://localhost:8080/_login.js";
|
||||
import _auth from "http://localhost:8080/_auth.js";
|
||||
import * as _loginReally from "http://localhost:8080/_login.js";
|
||||
import * as _loginReally2 from "http://localhost:8080/_login.js";
|
||||
import * as _authReally from "http://localhost:8080/_auth.js";
|
||||
|
||||
export default __cJS2eSM(function(module, exports) {
|
||||
;
|
||||
|
||||
;
|
||||
;
|
||||
;
|
||||
;
|
||||
module.exports.iAmCommonJs = true;
|
||||
exports.YouAreCommonJS = true;
|
||||
require(_login_b977_0);
|
||||
require(_login_b977_1);
|
||||
Object.defineProperty(module.exports,"login",{get: () => _login, enumerable: true, configurable: true});
|
||||
var test = function test() {
|
||||
return testDone(import.meta.url);
|
||||
};
|
||||
Object.defineProperty(module.exports,"test",{get: () => test, enumerable: true, configurable: true});
|
||||
var foo, bar;
|
||||
Object.defineProperties(module.exports,{'foo': {get: () => foo, set: ($_newValue) => {foo = $_newValue;}, enumerable: true, configurable: true},
|
||||
'bar': {get: () => bar, set: ($_newValue) => {bar = $_newValue;}, enumerable: true, configurable: true}});
|
||||
}, "cjs-transform-shouldnt-have-static-imports-in-cjs-function.js");
|
||||
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ export default __cJS2eSM(function(module, exports) {
|
||||
return testDone(import.meta.url);
|
||||
};
|
||||
Object.defineProperty(module.exports,"test",{get: () => test, enumerable: true, configurable: true});
|
||||
var foo, bar;
|
||||
let foo, bar;
|
||||
Object.defineProperties(module.exports,{'foo': {get: () => foo, set: ($_newValue) => {foo = $_newValue;}, enumerable: true, configurable: true},
|
||||
'bar': {get: () => bar, set: ($_newValue) => {bar = $_newValue;}, enumerable: true, configurable: true}});
|
||||
}, "cjs-transform-shouldnt-have-static-imports-in-cjs-function.js");
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
var testFailed = false;
|
||||
const invariant = () => {
|
||||
testFailed = true;
|
||||
};
|
||||
var $$m = (arg) => {
|
||||
var module = {exports: {} }, exports = module.exports;
|
||||
return arg(module, exports);
|
||||
};
|
||||
var size = 100, ttl = 3600;
|
||||
export var $f332019d = $$m({
|
||||
"relay-runtime/lib/network/RelayQueryResponseCache.js": (module, exports) => {
|
||||
var RelayQueryResponseCache = function() {
|
||||
var foo = function RelayQueryResponseCache(_ref) {
|
||||
var size = _ref.size, ttl = _ref.ttl;
|
||||
!(size > 0) && invariant(false, "RelayQueryResponseCache: Expected the max cache size to be > 0, got " + "`%s`.", size);
|
||||
!(ttl > 0) && invariant(false, "RelayQueryResponseCache: Expected the max ttl to be > 0, got `%s`.", ttl);
|
||||
};
|
||||
foo({size: 100, ttl: 3600 });
|
||||
};
|
||||
RelayQueryResponseCache();
|
||||
}
|
||||
}["relay-runtime/lib/network/RelayQueryResponseCache.js"]);
|
||||
export function test() {
|
||||
var foo = () => result;
|
||||
if (testFailed)
|
||||
throw new Error("invariant should not be called");
|
||||
return testDone(import.meta.url);
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
import {
|
||||
__HMRModule as HMR
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
import {
|
||||
__HMRClient as Bun
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
Bun.activate(true);
|
||||
|
||||
var hmr = new HMR(726376257, "code-simplification-neql-define.js"), exports = hmr.exports;
|
||||
(hmr._load = function() {
|
||||
var testFailed = false;
|
||||
const invariant = () => {
|
||||
testFailed = true;
|
||||
};
|
||||
var $$m = (arg) => {
|
||||
var module = {exports: {} }, exports = module.exports;
|
||||
return arg(module, exports);
|
||||
};
|
||||
var size = 100, ttl = 3600;
|
||||
var $f332019d = $$m({
|
||||
"relay-runtime/lib/network/RelayQueryResponseCache.js": (module, exports) => {
|
||||
var RelayQueryResponseCache = function() {
|
||||
var foo = function RelayQueryResponseCache(_ref) {
|
||||
var size = _ref.size, ttl = _ref.ttl;
|
||||
!(size > 0) && invariant(false, "RelayQueryResponseCache: Expected the max cache size to be > 0, got " + "`%s`.", size);
|
||||
!(ttl > 0) && invariant(false, "RelayQueryResponseCache: Expected the max ttl to be > 0, got `%s`.", ttl);
|
||||
};
|
||||
foo({size: 100, ttl: 3600 });
|
||||
};
|
||||
RelayQueryResponseCache();
|
||||
}
|
||||
}["relay-runtime/lib/network/RelayQueryResponseCache.js"]);
|
||||
function test() {
|
||||
var foo = () => result;
|
||||
if (testFailed)
|
||||
throw new Error("invariant should not be called");
|
||||
return testDone(import.meta.url);
|
||||
}
|
||||
hmr.exportAll({
|
||||
$f332019d: () => $f332019d,
|
||||
test: () => test
|
||||
});
|
||||
})();
|
||||
var $$hmr_$f332019d = hmr.exports.$f332019d, $$hmr_test = hmr.exports.test;
|
||||
hmr._update = function(exports) {
|
||||
$$hmr_$f332019d = exports.$f332019d;
|
||||
$$hmr_test = exports.test;
|
||||
};
|
||||
|
||||
export {
|
||||
$$hmr_$f332019d as $f332019d,
|
||||
$$hmr_test as test
|
||||
};
|
||||
53
integration/snapshots/code-simplification-neql-define.hmr.js
Normal file
53
integration/snapshots/code-simplification-neql-define.hmr.js
Normal file
@@ -0,0 +1,53 @@
|
||||
import {
|
||||
__HMRModule as HMR
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
import {
|
||||
__HMRClient as Bun
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
Bun.activate(false);
|
||||
|
||||
var hmr = new HMR(726376257, "code-simplification-neql-define.js"), exports = hmr.exports;
|
||||
(hmr._load = function() {
|
||||
var testFailed = false;
|
||||
const invariant = () => {
|
||||
testFailed = true;
|
||||
};
|
||||
var $$m = (arg) => {
|
||||
var module = {exports: {} }, exports = module.exports;
|
||||
return arg(module, exports);
|
||||
};
|
||||
var size = 100, ttl = 3600;
|
||||
var $f332019d = $$m({
|
||||
"relay-runtime/lib/network/RelayQueryResponseCache.js": (module, exports) => {
|
||||
var RelayQueryResponseCache = function() {
|
||||
var foo = function RelayQueryResponseCache(_ref) {
|
||||
var size = _ref.size, ttl = _ref.ttl;
|
||||
!(size > 0) && invariant(false, "RelayQueryResponseCache: Expected the max cache size to be > 0, got " + "`%s`.", size);
|
||||
!(ttl > 0) && invariant(false, "RelayQueryResponseCache: Expected the max ttl to be > 0, got `%s`.", ttl);
|
||||
};
|
||||
foo({size: 100, ttl: 3600 });
|
||||
};
|
||||
RelayQueryResponseCache();
|
||||
}
|
||||
}["relay-runtime/lib/network/RelayQueryResponseCache.js"]);
|
||||
function test() {
|
||||
var foo = () => result;
|
||||
if (testFailed)
|
||||
throw new Error("invariant should not be called");
|
||||
return testDone(import.meta.url);
|
||||
}
|
||||
hmr.exportAll({
|
||||
$f332019d: () => $f332019d,
|
||||
test: () => test
|
||||
});
|
||||
})();
|
||||
var $$hmr_$f332019d = hmr.exports.$f332019d, $$hmr_test = hmr.exports.test;
|
||||
hmr._update = function(exports) {
|
||||
$$hmr_$f332019d = exports.$f332019d;
|
||||
$$hmr_test = exports.test;
|
||||
};
|
||||
|
||||
export {
|
||||
$$hmr_$f332019d as $f332019d,
|
||||
$$hmr_test as test
|
||||
};
|
||||
28
integration/snapshots/code-simplification-neql-define.js
Normal file
28
integration/snapshots/code-simplification-neql-define.js
Normal file
@@ -0,0 +1,28 @@
|
||||
var testFailed = false;
|
||||
const invariant = () => {
|
||||
testFailed = true;
|
||||
};
|
||||
var $$m = (arg) => {
|
||||
var module = {exports: {} }, exports = module.exports;
|
||||
return arg(module, exports);
|
||||
};
|
||||
var size = 100, ttl = 3600;
|
||||
export var $f332019d = $$m({
|
||||
"relay-runtime/lib/network/RelayQueryResponseCache.js": (module, exports) => {
|
||||
var RelayQueryResponseCache = function() {
|
||||
var foo = function RelayQueryResponseCache(_ref) {
|
||||
var size = _ref.size, ttl = _ref.ttl;
|
||||
!(size > 0) && invariant(false, "RelayQueryResponseCache: Expected the max cache size to be > 0, got " + "`%s`.", size);
|
||||
!(ttl > 0) && invariant(false, "RelayQueryResponseCache: Expected the max ttl to be > 0, got `%s`.", ttl);
|
||||
};
|
||||
foo({size: 100, ttl: 3600 });
|
||||
};
|
||||
RelayQueryResponseCache();
|
||||
}
|
||||
}["relay-runtime/lib/network/RelayQueryResponseCache.js"]);
|
||||
export function test() {
|
||||
var foo = () => result;
|
||||
if (testFailed)
|
||||
throw new Error("invariant should not be called");
|
||||
return testDone(import.meta.url);
|
||||
}
|
||||
74
integration/snapshots/export.hmr.debug.js
Normal file
74
integration/snapshots/export.hmr.debug.js
Normal file
@@ -0,0 +1,74 @@
|
||||
import {
|
||||
__HMRModule as HMR
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
import {
|
||||
__HMRClient as Bun
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
import what from "http://localhost:8080/_auth.js";
|
||||
import * as where from "http://localhost:8080/_auth.js";
|
||||
Bun.activate(true);
|
||||
|
||||
var hmr = new HMR(1879780259, "export.js"), exports = hmr.exports;
|
||||
(hmr._load = function() {
|
||||
var yoyoyo = "yoyoyo";
|
||||
function hey() {
|
||||
return true;
|
||||
}
|
||||
var foo = () => {
|
||||
};
|
||||
var bar = 100;
|
||||
var powerLevel = Symbol("9001");
|
||||
function test() {
|
||||
hey();
|
||||
foo();
|
||||
if (where.default !== "hi")
|
||||
throw new Error(`_auth import is incorrect.`);
|
||||
console.assert(powerLevel.description === "9001", "Symbol is not exported correctly");
|
||||
return testDone(import.meta.url);
|
||||
}
|
||||
hmr.exportAll({
|
||||
yoyoyo: () => yoyoyo,
|
||||
default: () => hey,
|
||||
foo: () => foo,
|
||||
bar: () => bar,
|
||||
powerLevel: () => powerLevel,
|
||||
what: () => what,
|
||||
when: () => what,
|
||||
whence: () => what,
|
||||
where: () => where,
|
||||
booop: () => bar,
|
||||
test: () => test
|
||||
});
|
||||
})();
|
||||
var $$hmr_yoyoyo = hmr.exports.yoyoyo, $$hmr_default = hmr.exports.default, $$hmr_foo = hmr.exports.foo, $$hmr_bar = hmr.exports.bar, $$hmr_powerLevel = hmr.exports.powerLevel, $$hmr_what = hmr.exports.what, $$hmr_when = hmr.exports.when, $$hmr_whence = hmr.exports.whence, $$hmr_where = hmr.exports.where, $$hmr_booop = hmr.exports.booop, $$hmr_test = hmr.exports.test;
|
||||
hmr._update = function(exports) {
|
||||
$$hmr_yoyoyo = exports.yoyoyo;
|
||||
$$hmr_default = exports.default;
|
||||
$$hmr_foo = exports.foo;
|
||||
$$hmr_bar = exports.bar;
|
||||
$$hmr_powerLevel = exports.powerLevel;
|
||||
$$hmr_what = exports.what;
|
||||
$$hmr_when = exports.when;
|
||||
$$hmr_whence = exports.whence;
|
||||
$$hmr_where = exports.where;
|
||||
$$hmr_booop = exports.booop;
|
||||
$$hmr_test = exports.test;
|
||||
};
|
||||
|
||||
export {
|
||||
$$hmr_yoyoyo as yoyoyo,
|
||||
$$hmr_default as default,
|
||||
$$hmr_foo as foo,
|
||||
$$hmr_bar as bar,
|
||||
$$hmr_powerLevel as powerLevel,
|
||||
$$hmr_what as what,
|
||||
$$hmr_when as when,
|
||||
$$hmr_whence as whence,
|
||||
$$hmr_where as where,
|
||||
$$hmr_booop as booop,
|
||||
$$hmr_test as test
|
||||
};
|
||||
export {default as auth} from "http://localhost:8080/_auth.js";
|
||||
export {default as login} from "http://localhost:8080/_login.js";
|
||||
export * from "http://localhost:8080/_bacon.js";
|
||||
export {} from "http://localhost:8080/_bacon.js";
|
||||
74
integration/snapshots/export.hmr.js
Normal file
74
integration/snapshots/export.hmr.js
Normal file
@@ -0,0 +1,74 @@
|
||||
import {
|
||||
__HMRModule as HMR
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
import {
|
||||
__HMRClient as Bun
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
import what from "http://localhost:8080/_auth.js";
|
||||
import * as where from "http://localhost:8080/_auth.js";
|
||||
Bun.activate(false);
|
||||
|
||||
var hmr = new HMR(1879780259, "export.js"), exports = hmr.exports;
|
||||
(hmr._load = function() {
|
||||
var yoyoyo = "yoyoyo";
|
||||
function hey() {
|
||||
return true;
|
||||
}
|
||||
var foo = () => {
|
||||
};
|
||||
var bar = 100;
|
||||
var powerLevel = Symbol("9001");
|
||||
function test() {
|
||||
hey();
|
||||
foo();
|
||||
if (where.default !== "hi")
|
||||
throw new Error(`_auth import is incorrect.`);
|
||||
console.assert(powerLevel.description === "9001", "Symbol is not exported correctly");
|
||||
return testDone(import.meta.url);
|
||||
}
|
||||
hmr.exportAll({
|
||||
yoyoyo: () => yoyoyo,
|
||||
default: () => hey,
|
||||
foo: () => foo,
|
||||
bar: () => bar,
|
||||
powerLevel: () => powerLevel,
|
||||
what: () => what,
|
||||
when: () => what,
|
||||
whence: () => what,
|
||||
where: () => where,
|
||||
booop: () => bar,
|
||||
test: () => test
|
||||
});
|
||||
})();
|
||||
var $$hmr_yoyoyo = hmr.exports.yoyoyo, $$hmr_default = hmr.exports.default, $$hmr_foo = hmr.exports.foo, $$hmr_bar = hmr.exports.bar, $$hmr_powerLevel = hmr.exports.powerLevel, $$hmr_what = hmr.exports.what, $$hmr_when = hmr.exports.when, $$hmr_whence = hmr.exports.whence, $$hmr_where = hmr.exports.where, $$hmr_booop = hmr.exports.booop, $$hmr_test = hmr.exports.test;
|
||||
hmr._update = function(exports) {
|
||||
$$hmr_yoyoyo = exports.yoyoyo;
|
||||
$$hmr_default = exports.default;
|
||||
$$hmr_foo = exports.foo;
|
||||
$$hmr_bar = exports.bar;
|
||||
$$hmr_powerLevel = exports.powerLevel;
|
||||
$$hmr_what = exports.what;
|
||||
$$hmr_when = exports.when;
|
||||
$$hmr_whence = exports.whence;
|
||||
$$hmr_where = exports.where;
|
||||
$$hmr_booop = exports.booop;
|
||||
$$hmr_test = exports.test;
|
||||
};
|
||||
|
||||
export {
|
||||
$$hmr_yoyoyo as yoyoyo,
|
||||
$$hmr_default as default,
|
||||
$$hmr_foo as foo,
|
||||
$$hmr_bar as bar,
|
||||
$$hmr_powerLevel as powerLevel,
|
||||
$$hmr_what as what,
|
||||
$$hmr_when as when,
|
||||
$$hmr_whence as whence,
|
||||
$$hmr_where as where,
|
||||
$$hmr_booop as booop,
|
||||
$$hmr_test as test
|
||||
};
|
||||
export {default as auth} from "http://localhost:8080/_auth.js";
|
||||
export {default as login} from "http://localhost:8080/_login.js";
|
||||
export * from "http://localhost:8080/_bacon.js";
|
||||
export {} from "http://localhost:8080/_bacon.js";
|
||||
@@ -1,74 +1,31 @@
|
||||
import {
|
||||
__HMRModule as HMR
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
import {
|
||||
__HMRClient as Bun
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
import what from "http://localhost:8080/_auth.js";
|
||||
import * as where from "http://localhost:8080/_auth.js";
|
||||
Bun.activate(false);
|
||||
|
||||
var hmr = new HMR(1879780259, "export.js"), exports = hmr.exports;
|
||||
(hmr._load = function() {
|
||||
var yoyoyo = "yoyoyo";
|
||||
function hey() {
|
||||
return true;
|
||||
}
|
||||
var foo = () => {
|
||||
};
|
||||
var bar = 100;
|
||||
var powerLevel = Symbol("9001");
|
||||
function test() {
|
||||
hey();
|
||||
foo();
|
||||
if (where.default !== "hi")
|
||||
throw new Error(`_auth import is incorrect.`);
|
||||
console.assert(powerLevel.description === "9001", "Symbol is not exported correctly");
|
||||
return testDone(import.meta.url);
|
||||
}
|
||||
hmr.exportAll({
|
||||
yoyoyo: () => yoyoyo,
|
||||
default: () => hey,
|
||||
foo: () => foo,
|
||||
bar: () => bar,
|
||||
powerLevel: () => powerLevel,
|
||||
what: () => what,
|
||||
when: () => what,
|
||||
whence: () => what,
|
||||
where: () => where,
|
||||
booop: () => bar,
|
||||
test: () => test
|
||||
});
|
||||
})();
|
||||
var $$hmr_yoyoyo = hmr.exports.yoyoyo, $$hmr_default = hmr.exports.default, $$hmr_foo = hmr.exports.foo, $$hmr_bar = hmr.exports.bar, $$hmr_powerLevel = hmr.exports.powerLevel, $$hmr_what = hmr.exports.what, $$hmr_when = hmr.exports.when, $$hmr_whence = hmr.exports.whence, $$hmr_where = hmr.exports.where, $$hmr_booop = hmr.exports.booop, $$hmr_test = hmr.exports.test;
|
||||
hmr._update = function(exports) {
|
||||
$$hmr_yoyoyo = exports.yoyoyo;
|
||||
$$hmr_default = exports.default;
|
||||
$$hmr_foo = exports.foo;
|
||||
$$hmr_bar = exports.bar;
|
||||
$$hmr_powerLevel = exports.powerLevel;
|
||||
$$hmr_what = exports.what;
|
||||
$$hmr_when = exports.when;
|
||||
$$hmr_whence = exports.whence;
|
||||
$$hmr_where = exports.where;
|
||||
$$hmr_booop = exports.booop;
|
||||
$$hmr_test = exports.test;
|
||||
};
|
||||
|
||||
export {
|
||||
$$hmr_yoyoyo as yoyoyo,
|
||||
$$hmr_default as default,
|
||||
$$hmr_foo as foo,
|
||||
$$hmr_bar as bar,
|
||||
$$hmr_powerLevel as powerLevel,
|
||||
$$hmr_what as what,
|
||||
$$hmr_when as when,
|
||||
$$hmr_whence as whence,
|
||||
$$hmr_where as where,
|
||||
$$hmr_booop as booop,
|
||||
$$hmr_test as test
|
||||
};
|
||||
export {default as auth} from "http://localhost:8080/_auth.js";
|
||||
|
||||
export {default as login} from "http://localhost:8080/_login.js";
|
||||
export * from "http://localhost:8080/_bacon.js";
|
||||
export let yoyoyo = "yoyoyo";
|
||||
|
||||
export default function hey() {
|
||||
return true;
|
||||
}
|
||||
export const foo = () => {
|
||||
};
|
||||
export var bar = 100;
|
||||
export let powerLevel = Symbol("9001");
|
||||
|
||||
export {what};
|
||||
export {what as when, what as whence};
|
||||
export {} from "http://localhost:8080/_bacon.js";
|
||||
import * as where from "http://localhost:8080/_auth.js";
|
||||
|
||||
export {where};
|
||||
|
||||
export {bar as booop};
|
||||
export function test() {
|
||||
hey();
|
||||
foo();
|
||||
if (where.default !== "hi")
|
||||
throw new Error(`_auth import is incorrect.`);
|
||||
console.assert(powerLevel.description === "9001", "Symbol is not exported correctly");
|
||||
return testDone(import.meta.url);
|
||||
}
|
||||
|
||||
8
integration/snapshots/forbid-in-is-correct.debug.js
Normal file
8
integration/snapshots/forbid-in-is-correct.debug.js
Normal file
@@ -0,0 +1,8 @@
|
||||
var foo = () => {
|
||||
var D = (i, r) => () => (r || i((r = {exports: {} }).exports, r), r.exports);
|
||||
return D;
|
||||
};
|
||||
export function test() {
|
||||
foo();
|
||||
testDone(import.meta.url);
|
||||
}
|
||||
30
integration/snapshots/forbid-in-is-correct.hmr.debug.js
Normal file
30
integration/snapshots/forbid-in-is-correct.hmr.debug.js
Normal file
@@ -0,0 +1,30 @@
|
||||
import {
|
||||
__HMRModule as HMR
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
import {
|
||||
__HMRClient as Bun
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
Bun.activate(true);
|
||||
|
||||
var hmr = new HMR(346837007, "forbid-in-is-correct.js"), exports = hmr.exports;
|
||||
(hmr._load = function() {
|
||||
var foo = () => {
|
||||
var D = (i, r) => () => (r || i((r = {exports: {} }).exports, r), r.exports);
|
||||
return D;
|
||||
};
|
||||
function test() {
|
||||
foo();
|
||||
testDone(import.meta.url);
|
||||
}
|
||||
hmr.exportAll({
|
||||
test: () => test
|
||||
});
|
||||
})();
|
||||
var $$hmr_test = hmr.exports.test;
|
||||
hmr._update = function(exports) {
|
||||
$$hmr_test = exports.test;
|
||||
};
|
||||
|
||||
export {
|
||||
$$hmr_test as test
|
||||
};
|
||||
30
integration/snapshots/forbid-in-is-correct.hmr.js
Normal file
30
integration/snapshots/forbid-in-is-correct.hmr.js
Normal file
@@ -0,0 +1,30 @@
|
||||
import {
|
||||
__HMRModule as HMR
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
import {
|
||||
__HMRClient as Bun
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
Bun.activate(false);
|
||||
|
||||
var hmr = new HMR(346837007, "forbid-in-is-correct.js"), exports = hmr.exports;
|
||||
(hmr._load = function() {
|
||||
var foo = () => {
|
||||
var D = (i, r) => () => (r || i((r = {exports: {} }).exports, r), r.exports);
|
||||
return D;
|
||||
};
|
||||
function test() {
|
||||
foo();
|
||||
testDone(import.meta.url);
|
||||
}
|
||||
hmr.exportAll({
|
||||
test: () => test
|
||||
});
|
||||
})();
|
||||
var $$hmr_test = hmr.exports.test;
|
||||
hmr._update = function(exports) {
|
||||
$$hmr_test = exports.test;
|
||||
};
|
||||
|
||||
export {
|
||||
$$hmr_test as test
|
||||
};
|
||||
8
integration/snapshots/forbid-in-is-correct.js
Normal file
8
integration/snapshots/forbid-in-is-correct.js
Normal file
@@ -0,0 +1,8 @@
|
||||
var foo = () => {
|
||||
var D = (i, r) => () => (r || i((r = {exports: {} }).exports, r), r.exports);
|
||||
return D;
|
||||
};
|
||||
export function test() {
|
||||
foo();
|
||||
testDone(import.meta.url);
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
import {
|
||||
__HMRModule as HMR
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
import {
|
||||
__HMRClient as Bun
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
Bun.activate(true);
|
||||
|
||||
var hmr = new HMR(713665787, "global-is-remapped-to-globalThis.js"), exports = hmr.exports;
|
||||
(hmr._load = function() {
|
||||
function test() {
|
||||
console.assert(globalThis === globalThis);
|
||||
return testDone(import.meta.url);
|
||||
}
|
||||
hmr.exportAll({
|
||||
test: () => test
|
||||
});
|
||||
})();
|
||||
var $$hmr_test = hmr.exports.test;
|
||||
hmr._update = function(exports) {
|
||||
$$hmr_test = exports.test;
|
||||
};
|
||||
|
||||
export {
|
||||
$$hmr_test as test
|
||||
};
|
||||
@@ -0,0 +1,26 @@
|
||||
import {
|
||||
__HMRModule as HMR
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
import {
|
||||
__HMRClient as Bun
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
Bun.activate(false);
|
||||
|
||||
var hmr = new HMR(713665787, "global-is-remapped-to-globalThis.js"), exports = hmr.exports;
|
||||
(hmr._load = function() {
|
||||
function test() {
|
||||
console.assert(globalThis === globalThis);
|
||||
return testDone(import.meta.url);
|
||||
}
|
||||
hmr.exportAll({
|
||||
test: () => test
|
||||
});
|
||||
})();
|
||||
var $$hmr_test = hmr.exports.test;
|
||||
hmr._update = function(exports) {
|
||||
$$hmr_test = exports.test;
|
||||
};
|
||||
|
||||
export {
|
||||
$$hmr_test as test
|
||||
};
|
||||
@@ -1,26 +1,4 @@
|
||||
import {
|
||||
__HMRModule as HMR
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
import {
|
||||
__HMRClient as Bun
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
Bun.activate(false);
|
||||
|
||||
var hmr = new HMR(713665787, "global-is-remapped-to-globalThis.js"), exports = hmr.exports;
|
||||
(hmr._load = function() {
|
||||
function test() {
|
||||
console.assert(globalThis === globalThis);
|
||||
return testDone(import.meta.url);
|
||||
}
|
||||
hmr.exportAll({
|
||||
test: () => test
|
||||
});
|
||||
})();
|
||||
var $$hmr_test = hmr.exports.test;
|
||||
hmr._update = function(exports) {
|
||||
$$hmr_test = exports.test;
|
||||
};
|
||||
|
||||
export {
|
||||
$$hmr_test as test
|
||||
};
|
||||
export function test() {
|
||||
console.assert(globalThis === globalThis);
|
||||
return testDone(import.meta.url);
|
||||
}
|
||||
|
||||
41
integration/snapshots/lodash-regexp.hmr.debug.js
Normal file
41
integration/snapshots/lodash-regexp.hmr.debug.js
Normal file
@@ -0,0 +1,41 @@
|
||||
import {
|
||||
__require as require
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
import {
|
||||
__HMRModule as HMR
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
import {
|
||||
__HMRClient as Bun
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
import * as $60f52dc2 from "http://localhost:8080/node_modules/lodash/lodash.js";
|
||||
var { shuffle} = require($60f52dc2);
|
||||
Bun.activate(true);
|
||||
|
||||
var hmr = new HMR(2158065009, "lodash-regexp.js"), exports = hmr.exports;
|
||||
(hmr._load = function() {
|
||||
function test() {
|
||||
const foo = [1, 2, 3, 4, 6];
|
||||
const bar = shuffle(foo);
|
||||
console.assert(bar !== foo);
|
||||
console.assert(bar.length === foo.length);
|
||||
bar.sort();
|
||||
foo.sort();
|
||||
for (let i = 0;i < bar.length; i++) {
|
||||
console.assert(bar[i] === foo[i], "expected " + i + " to be " + foo[i]);
|
||||
console.assert(typeof bar[i] === "number");
|
||||
console.assert(typeof foo[i] === "number");
|
||||
}
|
||||
return testDone(import.meta.url);
|
||||
}
|
||||
hmr.exportAll({
|
||||
test: () => test
|
||||
});
|
||||
})();
|
||||
var $$hmr_test = hmr.exports.test;
|
||||
hmr._update = function(exports) {
|
||||
$$hmr_test = exports.test;
|
||||
};
|
||||
|
||||
export {
|
||||
$$hmr_test as test
|
||||
};
|
||||
41
integration/snapshots/lodash-regexp.hmr.js
Normal file
41
integration/snapshots/lodash-regexp.hmr.js
Normal file
@@ -0,0 +1,41 @@
|
||||
import {
|
||||
__require as require
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
import {
|
||||
__HMRModule as HMR
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
import {
|
||||
__HMRClient as Bun
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
import * as $60f52dc2 from "http://localhost:8080/node_modules/lodash/lodash.js";
|
||||
var { shuffle} = require($60f52dc2);
|
||||
Bun.activate(false);
|
||||
|
||||
var hmr = new HMR(2158065009, "lodash-regexp.js"), exports = hmr.exports;
|
||||
(hmr._load = function() {
|
||||
function test() {
|
||||
const foo = [1, 2, 3, 4, 6];
|
||||
const bar = shuffle(foo);
|
||||
console.assert(bar !== foo);
|
||||
console.assert(bar.length === foo.length);
|
||||
bar.sort();
|
||||
foo.sort();
|
||||
for (let i = 0;i < bar.length; i++) {
|
||||
console.assert(bar[i] === foo[i], "expected " + i + " to be " + foo[i]);
|
||||
console.assert(typeof bar[i] === "number");
|
||||
console.assert(typeof foo[i] === "number");
|
||||
}
|
||||
return testDone(import.meta.url);
|
||||
}
|
||||
hmr.exportAll({
|
||||
test: () => test
|
||||
});
|
||||
})();
|
||||
var $$hmr_test = hmr.exports.test;
|
||||
hmr._update = function(exports) {
|
||||
$$hmr_test = exports.test;
|
||||
};
|
||||
|
||||
export {
|
||||
$$hmr_test as test
|
||||
};
|
||||
@@ -1,41 +1,21 @@
|
||||
import {
|
||||
__require as require
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
import {
|
||||
__HMRModule as HMR
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
import {
|
||||
__HMRClient as Bun
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
import * as $60f52dc2 from "http://localhost:8080/node_modules/lodash/lodash.js";
|
||||
var { shuffle} = require($60f52dc2);
|
||||
Bun.activate(false);
|
||||
export function test() {
|
||||
const foo = [1, 2, 3, 4, 6];
|
||||
|
||||
var hmr = new HMR(2158065009, "lodash-regexp.js"), exports = hmr.exports;
|
||||
(hmr._load = function() {
|
||||
function test() {
|
||||
const foo = [1, 2, 3, 4, 6];
|
||||
const bar = shuffle(foo);
|
||||
console.assert(bar !== foo);
|
||||
console.assert(bar.length === foo.length);
|
||||
bar.sort();
|
||||
foo.sort();
|
||||
for (let i = 0;i < bar.length; i++) {
|
||||
console.assert(bar[i] === foo[i], "expected " + i + " to be " + foo[i]);
|
||||
console.assert(typeof bar[i] === "number");
|
||||
console.assert(typeof foo[i] === "number");
|
||||
}
|
||||
return testDone(import.meta.url);
|
||||
const bar = shuffle(foo);
|
||||
console.assert(bar !== foo);
|
||||
console.assert(bar.length === foo.length);
|
||||
bar.sort();
|
||||
foo.sort();
|
||||
for (let i = 0;i < bar.length; i++) {
|
||||
console.assert(bar[i] === foo[i], "expected " + i + " to be " + foo[i]);
|
||||
console.assert(typeof bar[i] === "number");
|
||||
console.assert(typeof foo[i] === "number");
|
||||
}
|
||||
hmr.exportAll({
|
||||
test: () => test
|
||||
});
|
||||
})();
|
||||
var $$hmr_test = hmr.exports.test;
|
||||
hmr._update = function(exports) {
|
||||
$$hmr_test = exports.test;
|
||||
};
|
||||
return testDone(import.meta.url);
|
||||
}
|
||||
|
||||
export {
|
||||
$$hmr_test as test
|
||||
};
|
||||
|
||||
46
integration/snapshots/multiple-imports.hmr.debug.js
Normal file
46
integration/snapshots/multiple-imports.hmr.debug.js
Normal file
@@ -0,0 +1,46 @@
|
||||
import {
|
||||
__HMRClient as Bun
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
import {
|
||||
__require as require
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
import {
|
||||
__HMRModule as HMR
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
import * as JSX from "http://localhost:8080/node_modules/react/jsx-dev-runtime.js";
|
||||
import * as $bbcd215f from "http://localhost:8080/node_modules/react/index.js";
|
||||
var JSXClassic = require($bbcd215f);
|
||||
var jsx = require(JSX).jsxDEV, fileName = "multiple-imports.js", JSXFrag = require(JSX, JSXClassic).Fragment;
|
||||
|
||||
var { default: React} = require($bbcd215f);
|
||||
var { default: React2} = require($bbcd215f);
|
||||
Bun.activate(true);
|
||||
|
||||
var hmr = new HMR(2165509932, "multiple-imports.js"), exports = hmr.exports;
|
||||
(hmr._load = function() {
|
||||
const bacon = React;
|
||||
const bacon2 = jsx(JSXFrag, {
|
||||
children: ["hello"]
|
||||
}, undefined, true, {
|
||||
fileName,
|
||||
lineNumber: 92
|
||||
}, this);
|
||||
function test() {
|
||||
console.assert(bacon === React);
|
||||
console.assert(bacon === React2);
|
||||
console.assert(typeof bacon2 !== "undefined");
|
||||
console.assert(React.isValidElement(bacon2));
|
||||
return testDone(import.meta.url);
|
||||
}
|
||||
hmr.exportAll({
|
||||
test: () => test
|
||||
});
|
||||
})();
|
||||
var $$hmr_test = hmr.exports.test;
|
||||
hmr._update = function(exports) {
|
||||
$$hmr_test = exports.test;
|
||||
};
|
||||
|
||||
export {
|
||||
$$hmr_test as test
|
||||
};
|
||||
46
integration/snapshots/multiple-imports.hmr.js
Normal file
46
integration/snapshots/multiple-imports.hmr.js
Normal file
@@ -0,0 +1,46 @@
|
||||
import {
|
||||
__HMRClient as Bun
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
import {
|
||||
__require as require
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
import {
|
||||
__HMRModule as HMR
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
import * as JSX from "http://localhost:8080/node_modules/react/jsx-dev-runtime.js";
|
||||
import * as $bbcd215f from "http://localhost:8080/node_modules/react/index.js";
|
||||
var JSXClassic = require($bbcd215f);
|
||||
var jsx = require(JSX).jsxDEV, fileName = "multiple-imports.js", JSXFrag = require(JSX, JSXClassic).Fragment;
|
||||
|
||||
var { default: React} = require($bbcd215f);
|
||||
var { default: React2} = require($bbcd215f);
|
||||
Bun.activate(false);
|
||||
|
||||
var hmr = new HMR(2165509932, "multiple-imports.js"), exports = hmr.exports;
|
||||
(hmr._load = function() {
|
||||
const bacon = React;
|
||||
const bacon2 = jsx(JSXFrag, {
|
||||
children: ["hello"]
|
||||
}, undefined, true, {
|
||||
fileName,
|
||||
lineNumber: 92
|
||||
}, this);
|
||||
function test() {
|
||||
console.assert(bacon === React);
|
||||
console.assert(bacon === React2);
|
||||
console.assert(typeof bacon2 !== "undefined");
|
||||
console.assert(React.isValidElement(bacon2));
|
||||
return testDone(import.meta.url);
|
||||
}
|
||||
hmr.exportAll({
|
||||
test: () => test
|
||||
});
|
||||
})();
|
||||
var $$hmr_test = hmr.exports.test;
|
||||
hmr._update = function(exports) {
|
||||
$$hmr_test = exports.test;
|
||||
};
|
||||
|
||||
export {
|
||||
$$hmr_test as test
|
||||
};
|
||||
@@ -1,12 +1,6 @@
|
||||
import {
|
||||
__HMRClient as Bun
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
import {
|
||||
__require as require
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
import {
|
||||
__HMRModule as HMR
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
import * as JSX from "http://localhost:8080/node_modules/react/jsx-dev-runtime.js";
|
||||
import * as $bbcd215f from "http://localhost:8080/node_modules/react/index.js";
|
||||
var JSXClassic = require($bbcd215f);
|
||||
@@ -14,33 +8,18 @@ var jsx = require(JSX).jsxDEV, fileName = "multiple-imports.js", JSXFrag = requi
|
||||
|
||||
var { default: React} = require($bbcd215f);
|
||||
var { default: React2} = require($bbcd215f);
|
||||
Bun.activate(false);
|
||||
const bacon = React;
|
||||
|
||||
var hmr = new HMR(2165509932, "multiple-imports.js"), exports = hmr.exports;
|
||||
(hmr._load = function() {
|
||||
const bacon = React;
|
||||
const bacon2 = jsx(JSXFrag, {
|
||||
children: ["hello"]
|
||||
}, undefined, true, {
|
||||
fileName,
|
||||
lineNumber: 92
|
||||
}, this);
|
||||
function test() {
|
||||
console.assert(bacon === React);
|
||||
console.assert(bacon === React2);
|
||||
console.assert(typeof bacon2 !== "undefined");
|
||||
console.assert(React.isValidElement(bacon2));
|
||||
return testDone(import.meta.url);
|
||||
}
|
||||
hmr.exportAll({
|
||||
test: () => test
|
||||
});
|
||||
})();
|
||||
var $$hmr_test = hmr.exports.test;
|
||||
hmr._update = function(exports) {
|
||||
$$hmr_test = exports.test;
|
||||
};
|
||||
|
||||
export {
|
||||
$$hmr_test as test
|
||||
};
|
||||
const bacon2 = jsx(JSXFrag, {
|
||||
children: ["hello"]
|
||||
}, undefined, true, {
|
||||
fileName,
|
||||
lineNumber: 92
|
||||
}, this);
|
||||
export function test() {
|
||||
console.assert(bacon === React);
|
||||
console.assert(bacon === React2);
|
||||
console.assert(typeof bacon2 !== "undefined");
|
||||
console.assert(React.isValidElement(bacon2));
|
||||
return testDone(import.meta.url);
|
||||
}
|
||||
|
||||
17
integration/snapshots/package-json-exports/index.debug.js
Normal file
17
integration/snapshots/package-json-exports/index.debug.js
Normal file
@@ -0,0 +1,17 @@
|
||||
import {
|
||||
__require as require
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
import * as $4068f25b from "http://localhost:8080/package-json-exports/node_modules/inexact/browser/index.js";
|
||||
var InexactRoot = require($4068f25b);
|
||||
import * as $d2a171d2 from "http://localhost:8080/package-json-exports/node_modules/inexact/browser/dir/file.js";
|
||||
var InexactFile = require($d2a171d2);
|
||||
import * as $522c6d1f from "http://localhost:8080/package-json-exports/node_modules/inexact/browser/foo.js";
|
||||
var ExactFile = require($522c6d1f);
|
||||
export async function test() {
|
||||
console.assert(InexactRoot.target === "browser");
|
||||
|
||||
console.assert(InexactFile.target === "browser");
|
||||
console.assert(ExactFile.target === "browser");
|
||||
return testDone(import.meta.url);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
import {
|
||||
__require as require
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
import {
|
||||
__HMRModule as HMR
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
import {
|
||||
__HMRClient as Bun
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
import * as $4068f25b from "http://localhost:8080/package-json-exports/node_modules/inexact/browser/index.js";
|
||||
var InexactRoot = require($4068f25b);
|
||||
import * as $d2a171d2 from "http://localhost:8080/package-json-exports/node_modules/inexact/browser/dir/file.js";
|
||||
var InexactFile = require($d2a171d2);
|
||||
import * as $522c6d1f from "http://localhost:8080/package-json-exports/node_modules/inexact/browser/foo.js";
|
||||
var ExactFile = require($522c6d1f);
|
||||
Bun.activate(true);
|
||||
|
||||
var hmr = new HMR(1953708113, "package-json-exports/index.js"), exports = hmr.exports;
|
||||
(hmr._load = function() {
|
||||
async function test() {
|
||||
console.assert(InexactRoot.target === "browser");
|
||||
console.assert(InexactFile.target === "browser");
|
||||
console.assert(ExactFile.target === "browser");
|
||||
return testDone(import.meta.url);
|
||||
}
|
||||
hmr.exportAll({
|
||||
test: () => test
|
||||
});
|
||||
})();
|
||||
var $$hmr_test = hmr.exports.test;
|
||||
hmr._update = function(exports) {
|
||||
$$hmr_test = exports.test;
|
||||
};
|
||||
|
||||
export {
|
||||
$$hmr_test as test
|
||||
};
|
||||
37
integration/snapshots/package-json-exports/index.hmr.js
Normal file
37
integration/snapshots/package-json-exports/index.hmr.js
Normal file
@@ -0,0 +1,37 @@
|
||||
import {
|
||||
__require as require
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
import {
|
||||
__HMRModule as HMR
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
import {
|
||||
__HMRClient as Bun
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
import * as $4068f25b from "http://localhost:8080/package-json-exports/node_modules/inexact/browser/index.js";
|
||||
var InexactRoot = require($4068f25b);
|
||||
import * as $d2a171d2 from "http://localhost:8080/package-json-exports/node_modules/inexact/browser/dir/file.js";
|
||||
var InexactFile = require($d2a171d2);
|
||||
import * as $522c6d1f from "http://localhost:8080/package-json-exports/node_modules/inexact/browser/foo.js";
|
||||
var ExactFile = require($522c6d1f);
|
||||
Bun.activate(false);
|
||||
|
||||
var hmr = new HMR(1953708113, "package-json-exports/index.js"), exports = hmr.exports;
|
||||
(hmr._load = function() {
|
||||
async function test() {
|
||||
console.assert(InexactRoot.target === "browser");
|
||||
console.assert(InexactFile.target === "browser");
|
||||
console.assert(ExactFile.target === "browser");
|
||||
return testDone(import.meta.url);
|
||||
}
|
||||
hmr.exportAll({
|
||||
test: () => test
|
||||
});
|
||||
})();
|
||||
var $$hmr_test = hmr.exports.test;
|
||||
hmr._update = function(exports) {
|
||||
$$hmr_test = exports.test;
|
||||
};
|
||||
|
||||
export {
|
||||
$$hmr_test as test
|
||||
};
|
||||
17
integration/snapshots/package-json-exports/index.js
Normal file
17
integration/snapshots/package-json-exports/index.js
Normal file
@@ -0,0 +1,17 @@
|
||||
import {
|
||||
__require as require
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
import * as $4068f25b from "http://localhost:8080/package-json-exports/node_modules/inexact/browser/index.js";
|
||||
var InexactRoot = require($4068f25b);
|
||||
import * as $d2a171d2 from "http://localhost:8080/package-json-exports/node_modules/inexact/browser/dir/file.js";
|
||||
var InexactFile = require($d2a171d2);
|
||||
import * as $522c6d1f from "http://localhost:8080/package-json-exports/node_modules/inexact/browser/foo.js";
|
||||
var ExactFile = require($522c6d1f);
|
||||
export async function test() {
|
||||
console.assert(InexactRoot.target === "browser");
|
||||
|
||||
console.assert(InexactFile.target === "browser");
|
||||
console.assert(ExactFile.target === "browser");
|
||||
return testDone(import.meta.url);
|
||||
}
|
||||
|
||||
34
integration/snapshots/string-escapes.debug.js
Normal file
34
integration/snapshots/string-escapes.debug.js
Normal file
@@ -0,0 +1,34 @@
|
||||
var tab = "\t";
|
||||
var シ = "wow";
|
||||
var f = "";
|
||||
var obj = {
|
||||
"\r\n": "\r\n",
|
||||
"\n": "\n",
|
||||
"\t": "\t",
|
||||
"\u2028": "\u2028",
|
||||
"\u2029": "\u2029",
|
||||
"😊": "😊",
|
||||
"😃": "😃",
|
||||
"㋡": "㋡",
|
||||
"☺": "☺",
|
||||
シ: "シ",
|
||||
f,
|
||||
"☹": "☹",
|
||||
"☻": "☻",
|
||||
children: 123
|
||||
};
|
||||
const foo = () => {
|
||||
};
|
||||
const Bar = foo("a", {
|
||||
children: 123
|
||||
});
|
||||
const carriage = obj["\r\n"];
|
||||
const newline = obj["\n"];
|
||||
|
||||
export {obj};
|
||||
export function test() {
|
||||
console.assert(carriage === "\r\n");
|
||||
console.assert(newline === "\n");
|
||||
console.assert(tab === "\t");
|
||||
return testDone(import.meta.url);
|
||||
}
|
||||
57
integration/snapshots/string-escapes.hmr.debug.js
Normal file
57
integration/snapshots/string-escapes.hmr.debug.js
Normal file
@@ -0,0 +1,57 @@
|
||||
import {
|
||||
__HMRModule as HMR
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
import {
|
||||
__HMRClient as Bun
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
Bun.activate(true);
|
||||
|
||||
var hmr = new HMR(2482749838, "string-escapes.js"), exports = hmr.exports;
|
||||
(hmr._load = function() {
|
||||
var tab = "\t";
|
||||
var シ = "wow";
|
||||
var f = "";
|
||||
var obj = {
|
||||
"\r\n": "\r\n",
|
||||
"\n": "\n",
|
||||
"\t": "\t",
|
||||
"\u2028": "\u2028",
|
||||
"\u2029": "\u2029",
|
||||
"😊": "😊",
|
||||
"😃": "😃",
|
||||
"㋡": "㋡",
|
||||
"☺": "☺",
|
||||
シ: "シ",
|
||||
f,
|
||||
"☹": "☹",
|
||||
"☻": "☻",
|
||||
children: 123
|
||||
};
|
||||
const foo = () => {
|
||||
};
|
||||
const Bar = foo("a", {
|
||||
children: 123
|
||||
});
|
||||
const carriage = obj["\r\n"];
|
||||
const newline = obj["\n"];
|
||||
function test() {
|
||||
console.assert(carriage === "\r\n");
|
||||
console.assert(newline === "\n");
|
||||
console.assert(tab === "\t");
|
||||
return testDone(import.meta.url);
|
||||
}
|
||||
hmr.exportAll({
|
||||
obj: () => obj,
|
||||
test: () => test
|
||||
});
|
||||
})();
|
||||
var $$hmr_obj = hmr.exports.obj, $$hmr_test = hmr.exports.test;
|
||||
hmr._update = function(exports) {
|
||||
$$hmr_obj = exports.obj;
|
||||
$$hmr_test = exports.test;
|
||||
};
|
||||
|
||||
export {
|
||||
$$hmr_obj as obj,
|
||||
$$hmr_test as test
|
||||
};
|
||||
57
integration/snapshots/string-escapes.hmr.js
Normal file
57
integration/snapshots/string-escapes.hmr.js
Normal file
@@ -0,0 +1,57 @@
|
||||
import {
|
||||
__HMRModule as HMR
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
import {
|
||||
__HMRClient as Bun
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
Bun.activate(false);
|
||||
|
||||
var hmr = new HMR(2482749838, "string-escapes.js"), exports = hmr.exports;
|
||||
(hmr._load = function() {
|
||||
var tab = "\t";
|
||||
var シ = "wow";
|
||||
var f = "";
|
||||
var obj = {
|
||||
"\r\n": "\r\n",
|
||||
"\n": "\n",
|
||||
"\t": "\t",
|
||||
"\u2028": "\u2028",
|
||||
"\u2029": "\u2029",
|
||||
"😊": "😊",
|
||||
"😃": "😃",
|
||||
"㋡": "㋡",
|
||||
"☺": "☺",
|
||||
シ: "シ",
|
||||
f,
|
||||
"☹": "☹",
|
||||
"☻": "☻",
|
||||
children: 123
|
||||
};
|
||||
const foo = () => {
|
||||
};
|
||||
const Bar = foo("a", {
|
||||
children: 123
|
||||
});
|
||||
const carriage = obj["\r\n"];
|
||||
const newline = obj["\n"];
|
||||
function test() {
|
||||
console.assert(carriage === "\r\n");
|
||||
console.assert(newline === "\n");
|
||||
console.assert(tab === "\t");
|
||||
return testDone(import.meta.url);
|
||||
}
|
||||
hmr.exportAll({
|
||||
obj: () => obj,
|
||||
test: () => test
|
||||
});
|
||||
})();
|
||||
var $$hmr_obj = hmr.exports.obj, $$hmr_test = hmr.exports.test;
|
||||
hmr._update = function(exports) {
|
||||
$$hmr_obj = exports.obj;
|
||||
$$hmr_test = exports.test;
|
||||
};
|
||||
|
||||
export {
|
||||
$$hmr_obj as obj,
|
||||
$$hmr_test as test
|
||||
};
|
||||
34
integration/snapshots/string-escapes.js
Normal file
34
integration/snapshots/string-escapes.js
Normal file
@@ -0,0 +1,34 @@
|
||||
var tab = "\t";
|
||||
var シ = "wow";
|
||||
var f = "";
|
||||
var obj = {
|
||||
"\r\n": "\r\n",
|
||||
"\n": "\n",
|
||||
"\t": "\t",
|
||||
"\u2028": "\u2028",
|
||||
"\u2029": "\u2029",
|
||||
"😊": "😊",
|
||||
"😃": "😃",
|
||||
"㋡": "㋡",
|
||||
"☺": "☺",
|
||||
シ: "シ",
|
||||
f,
|
||||
"☹": "☹",
|
||||
"☻": "☻",
|
||||
children: 123
|
||||
};
|
||||
const foo = () => {
|
||||
};
|
||||
const Bar = foo("a", {
|
||||
children: 123
|
||||
});
|
||||
const carriage = obj["\r\n"];
|
||||
const newline = obj["\n"];
|
||||
|
||||
export {obj};
|
||||
export function test() {
|
||||
console.assert(carriage === "\r\n");
|
||||
console.assert(newline === "\n");
|
||||
console.assert(tab === "\t");
|
||||
return testDone(import.meta.url);
|
||||
}
|
||||
25
integration/snapshots/ts-fallback-rewrite-works.hmr.debug.js
Normal file
25
integration/snapshots/ts-fallback-rewrite-works.hmr.debug.js
Normal file
@@ -0,0 +1,25 @@
|
||||
import {
|
||||
__HMRModule as HMR
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
import {
|
||||
__HMRClient as Bun
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
Bun.activate(true);
|
||||
|
||||
var hmr = new HMR(421762902, "ts-fallback-rewrite-works.ts"), exports = hmr.exports;
|
||||
(hmr._load = function() {
|
||||
function test() {
|
||||
return testDone(import.meta.url);
|
||||
}
|
||||
hmr.exportAll({
|
||||
test: () => test
|
||||
});
|
||||
})();
|
||||
var $$hmr_test = hmr.exports.test;
|
||||
hmr._update = function(exports) {
|
||||
$$hmr_test = exports.test;
|
||||
};
|
||||
|
||||
export {
|
||||
$$hmr_test as test
|
||||
};
|
||||
25
integration/snapshots/ts-fallback-rewrite-works.hmr.js
Normal file
25
integration/snapshots/ts-fallback-rewrite-works.hmr.js
Normal file
@@ -0,0 +1,25 @@
|
||||
import {
|
||||
__HMRModule as HMR
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
import {
|
||||
__HMRClient as Bun
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
Bun.activate(false);
|
||||
|
||||
var hmr = new HMR(421762902, "ts-fallback-rewrite-works.ts"), exports = hmr.exports;
|
||||
(hmr._load = function() {
|
||||
function test() {
|
||||
return testDone(import.meta.url);
|
||||
}
|
||||
hmr.exportAll({
|
||||
test: () => test
|
||||
});
|
||||
})();
|
||||
var $$hmr_test = hmr.exports.test;
|
||||
hmr._update = function(exports) {
|
||||
$$hmr_test = exports.test;
|
||||
};
|
||||
|
||||
export {
|
||||
$$hmr_test as test
|
||||
};
|
||||
@@ -1,25 +1,3 @@
|
||||
import {
|
||||
__HMRModule as HMR
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
import {
|
||||
__HMRClient as Bun
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
Bun.activate(false);
|
||||
|
||||
var hmr = new HMR(421762902, "ts-fallback-rewrite-works.ts"), exports = hmr.exports;
|
||||
(hmr._load = function() {
|
||||
function test() {
|
||||
return testDone(import.meta.url);
|
||||
}
|
||||
hmr.exportAll({
|
||||
test: () => test
|
||||
});
|
||||
})();
|
||||
var $$hmr_test = hmr.exports.test;
|
||||
hmr._update = function(exports) {
|
||||
$$hmr_test = exports.test;
|
||||
};
|
||||
|
||||
export {
|
||||
$$hmr_test as test
|
||||
};
|
||||
export function test() {
|
||||
return testDone(import.meta.url);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
import {
|
||||
__HMRModule as HMR
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
import {
|
||||
__HMRClient as Bun
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
Bun.activate(true);
|
||||
|
||||
var hmr = new HMR(2117426367, "tsx-fallback-rewrite-works.tsx"), exports = hmr.exports;
|
||||
(hmr._load = function() {
|
||||
function test() {
|
||||
return testDone(import.meta.url);
|
||||
}
|
||||
hmr.exportAll({
|
||||
test: () => test
|
||||
});
|
||||
})();
|
||||
var $$hmr_test = hmr.exports.test;
|
||||
hmr._update = function(exports) {
|
||||
$$hmr_test = exports.test;
|
||||
};
|
||||
|
||||
export {
|
||||
$$hmr_test as test
|
||||
};
|
||||
25
integration/snapshots/tsx-fallback-rewrite-works.hmr.js
Normal file
25
integration/snapshots/tsx-fallback-rewrite-works.hmr.js
Normal file
@@ -0,0 +1,25 @@
|
||||
import {
|
||||
__HMRModule as HMR
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
import {
|
||||
__HMRClient as Bun
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
Bun.activate(false);
|
||||
|
||||
var hmr = new HMR(2117426367, "tsx-fallback-rewrite-works.tsx"), exports = hmr.exports;
|
||||
(hmr._load = function() {
|
||||
function test() {
|
||||
return testDone(import.meta.url);
|
||||
}
|
||||
hmr.exportAll({
|
||||
test: () => test
|
||||
});
|
||||
})();
|
||||
var $$hmr_test = hmr.exports.test;
|
||||
hmr._update = function(exports) {
|
||||
$$hmr_test = exports.test;
|
||||
};
|
||||
|
||||
export {
|
||||
$$hmr_test as test
|
||||
};
|
||||
@@ -1,25 +1,3 @@
|
||||
import {
|
||||
__HMRModule as HMR
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
import {
|
||||
__HMRClient as Bun
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
Bun.activate(false);
|
||||
|
||||
var hmr = new HMR(2117426367, "tsx-fallback-rewrite-works.tsx"), exports = hmr.exports;
|
||||
(hmr._load = function() {
|
||||
function test() {
|
||||
return testDone(import.meta.url);
|
||||
}
|
||||
hmr.exportAll({
|
||||
test: () => test
|
||||
});
|
||||
})();
|
||||
var $$hmr_test = hmr.exports.test;
|
||||
hmr._update = function(exports) {
|
||||
$$hmr_test = exports.test;
|
||||
};
|
||||
|
||||
export {
|
||||
$$hmr_test as test
|
||||
};
|
||||
export function test() {
|
||||
return testDone(import.meta.url);
|
||||
}
|
||||
|
||||
35
integration/snapshots/type-only-imports.hmr.debug.ts
Normal file
35
integration/snapshots/type-only-imports.hmr.debug.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import {
|
||||
__HMRModule as HMR
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
import {
|
||||
__HMRClient as Bun
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
Bun.activate(true);
|
||||
|
||||
var hmr = new HMR(650094581, "type-only-imports.ts"), exports = hmr.exports;
|
||||
(hmr._load = function() {
|
||||
var baconator = true;
|
||||
var SilentSymbolCollisionsAreOkayInTypeScript = true;
|
||||
function test() {
|
||||
console.assert(SilentSymbolCollisionsAreOkayInTypeScript);
|
||||
console.assert(baconator);
|
||||
return testDone(import.meta.url);
|
||||
}
|
||||
hmr.exportAll({
|
||||
baconator: () => baconator,
|
||||
SilentSymbolCollisionsAreOkayInTypeScript: () => SilentSymbolCollisionsAreOkayInTypeScript,
|
||||
test: () => test
|
||||
});
|
||||
})();
|
||||
var $$hmr_baconator = hmr.exports.baconator, $$hmr_SilentSymbolCollisionsAreOkayInTypeScript = hmr.exports.SilentSymbolCollisionsAreOkayInTypeScript, $$hmr_test = hmr.exports.test;
|
||||
hmr._update = function(exports) {
|
||||
$$hmr_baconator = exports.baconator;
|
||||
$$hmr_SilentSymbolCollisionsAreOkayInTypeScript = exports.SilentSymbolCollisionsAreOkayInTypeScript;
|
||||
$$hmr_test = exports.test;
|
||||
};
|
||||
|
||||
export {
|
||||
$$hmr_baconator as baconator,
|
||||
$$hmr_SilentSymbolCollisionsAreOkayInTypeScript as SilentSymbolCollisionsAreOkayInTypeScript,
|
||||
$$hmr_test as test
|
||||
};
|
||||
35
integration/snapshots/type-only-imports.hmr.ts
Normal file
35
integration/snapshots/type-only-imports.hmr.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import {
|
||||
__HMRModule as HMR
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
import {
|
||||
__HMRClient as Bun
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
Bun.activate(false);
|
||||
|
||||
var hmr = new HMR(650094581, "type-only-imports.ts"), exports = hmr.exports;
|
||||
(hmr._load = function() {
|
||||
var baconator = true;
|
||||
var SilentSymbolCollisionsAreOkayInTypeScript = true;
|
||||
function test() {
|
||||
console.assert(SilentSymbolCollisionsAreOkayInTypeScript);
|
||||
console.assert(baconator);
|
||||
return testDone(import.meta.url);
|
||||
}
|
||||
hmr.exportAll({
|
||||
baconator: () => baconator,
|
||||
SilentSymbolCollisionsAreOkayInTypeScript: () => SilentSymbolCollisionsAreOkayInTypeScript,
|
||||
test: () => test
|
||||
});
|
||||
})();
|
||||
var $$hmr_baconator = hmr.exports.baconator, $$hmr_SilentSymbolCollisionsAreOkayInTypeScript = hmr.exports.SilentSymbolCollisionsAreOkayInTypeScript, $$hmr_test = hmr.exports.test;
|
||||
hmr._update = function(exports) {
|
||||
$$hmr_baconator = exports.baconator;
|
||||
$$hmr_SilentSymbolCollisionsAreOkayInTypeScript = exports.SilentSymbolCollisionsAreOkayInTypeScript;
|
||||
$$hmr_test = exports.test;
|
||||
};
|
||||
|
||||
export {
|
||||
$$hmr_baconator as baconator,
|
||||
$$hmr_SilentSymbolCollisionsAreOkayInTypeScript as SilentSymbolCollisionsAreOkayInTypeScript,
|
||||
$$hmr_test as test
|
||||
};
|
||||
@@ -1,35 +1,7 @@
|
||||
import {
|
||||
__HMRModule as HMR
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
import {
|
||||
__HMRClient as Bun
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
Bun.activate(false);
|
||||
|
||||
var hmr = new HMR(650094581, "type-only-imports.ts"), exports = hmr.exports;
|
||||
(hmr._load = function() {
|
||||
var baconator = true;
|
||||
var SilentSymbolCollisionsAreOkayInTypeScript = true;
|
||||
function test() {
|
||||
console.assert(SilentSymbolCollisionsAreOkayInTypeScript);
|
||||
console.assert(baconator);
|
||||
return testDone(import.meta.url);
|
||||
}
|
||||
hmr.exportAll({
|
||||
baconator: () => baconator,
|
||||
SilentSymbolCollisionsAreOkayInTypeScript: () => SilentSymbolCollisionsAreOkayInTypeScript,
|
||||
test: () => test
|
||||
});
|
||||
})();
|
||||
var $$hmr_baconator = hmr.exports.baconator, $$hmr_SilentSymbolCollisionsAreOkayInTypeScript = hmr.exports.SilentSymbolCollisionsAreOkayInTypeScript, $$hmr_test = hmr.exports.test;
|
||||
hmr._update = function(exports) {
|
||||
$$hmr_baconator = exports.baconator;
|
||||
$$hmr_SilentSymbolCollisionsAreOkayInTypeScript = exports.SilentSymbolCollisionsAreOkayInTypeScript;
|
||||
$$hmr_test = exports.test;
|
||||
};
|
||||
|
||||
export {
|
||||
$$hmr_baconator as baconator,
|
||||
$$hmr_SilentSymbolCollisionsAreOkayInTypeScript as SilentSymbolCollisionsAreOkayInTypeScript,
|
||||
$$hmr_test as test
|
||||
};
|
||||
export const baconator = true;
|
||||
export const SilentSymbolCollisionsAreOkayInTypeScript = true;
|
||||
export function test() {
|
||||
console.assert(SilentSymbolCollisionsAreOkayInTypeScript);
|
||||
console.assert(baconator);
|
||||
return testDone(import.meta.url);
|
||||
}
|
||||
|
||||
7
integration/snapshots/unicode-identifiers.debug.js
Normal file
7
integration/snapshots/unicode-identifiers.debug.js
Normal file
@@ -0,0 +1,7 @@
|
||||
var ε = 1.0e-06, ε2 = ε * ε, π = Math.PI, τ = 2 * π, τε = τ - ε, halfπ = π / 2, d3_radians = π / 180, d3_degrees = 180 / π;
|
||||
|
||||
export {d3_radians};
|
||||
export function test() {
|
||||
console.assert(ε === 1.0e-06);
|
||||
return testDone(import.meta.url);
|
||||
}
|
||||
30
integration/snapshots/unicode-identifiers.hmr.debug.js
Normal file
30
integration/snapshots/unicode-identifiers.hmr.debug.js
Normal file
@@ -0,0 +1,30 @@
|
||||
import {
|
||||
__HMRModule as HMR
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
import {
|
||||
__HMRClient as Bun
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
Bun.activate(true);
|
||||
|
||||
var hmr = new HMR(1398361736, "unicode-identifiers.js"), exports = hmr.exports;
|
||||
(hmr._load = function() {
|
||||
var ε = 1.0e-06, ε2 = ε * ε, π = Math.PI, τ = 2 * π, τε = τ - ε, halfπ = π / 2, d3_radians = π / 180, d3_degrees = 180 / π;
|
||||
function test() {
|
||||
console.assert(ε === 1.0e-06);
|
||||
return testDone(import.meta.url);
|
||||
}
|
||||
hmr.exportAll({
|
||||
d3_radians: () => d3_radians,
|
||||
test: () => test
|
||||
});
|
||||
})();
|
||||
var $$hmr_d3_radians = hmr.exports.d3_radians, $$hmr_test = hmr.exports.test;
|
||||
hmr._update = function(exports) {
|
||||
$$hmr_d3_radians = exports.d3_radians;
|
||||
$$hmr_test = exports.test;
|
||||
};
|
||||
|
||||
export {
|
||||
$$hmr_d3_radians as d3_radians,
|
||||
$$hmr_test as test
|
||||
};
|
||||
30
integration/snapshots/unicode-identifiers.hmr.js
Normal file
30
integration/snapshots/unicode-identifiers.hmr.js
Normal file
@@ -0,0 +1,30 @@
|
||||
import {
|
||||
__HMRModule as HMR
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
import {
|
||||
__HMRClient as Bun
|
||||
} from "http://localhost:8080/__runtime.js";
|
||||
Bun.activate(false);
|
||||
|
||||
var hmr = new HMR(1398361736, "unicode-identifiers.js"), exports = hmr.exports;
|
||||
(hmr._load = function() {
|
||||
var ε = 1.0e-06, ε2 = ε * ε, π = Math.PI, τ = 2 * π, τε = τ - ε, halfπ = π / 2, d3_radians = π / 180, d3_degrees = 180 / π;
|
||||
function test() {
|
||||
console.assert(ε === 1.0e-06);
|
||||
return testDone(import.meta.url);
|
||||
}
|
||||
hmr.exportAll({
|
||||
d3_radians: () => d3_radians,
|
||||
test: () => test
|
||||
});
|
||||
})();
|
||||
var $$hmr_d3_radians = hmr.exports.d3_radians, $$hmr_test = hmr.exports.test;
|
||||
hmr._update = function(exports) {
|
||||
$$hmr_d3_radians = exports.d3_radians;
|
||||
$$hmr_test = exports.test;
|
||||
};
|
||||
|
||||
export {
|
||||
$$hmr_d3_radians as d3_radians,
|
||||
$$hmr_test as test
|
||||
};
|
||||
7
integration/snapshots/unicode-identifiers.js
Normal file
7
integration/snapshots/unicode-identifiers.js
Normal file
@@ -0,0 +1,7 @@
|
||||
var ε = 1.0e-06, ε2 = ε * ε, π = Math.PI, τ = 2 * π, τε = τ - ε, halfπ = π / 2, d3_radians = π / 180, d3_degrees = 180 / π;
|
||||
|
||||
export {d3_radians};
|
||||
export function test() {
|
||||
console.assert(ε === 1.0e-06);
|
||||
return testDone(import.meta.url);
|
||||
}
|
||||
28
integration/snippets/array-args-with-default-values.js
Normal file
28
integration/snippets/array-args-with-default-values.js
Normal file
@@ -0,0 +1,28 @@
|
||||
var lines;
|
||||
const data = () =>
|
||||
lines.map(([a = null, b = null, c = null, d = null]) => ({
|
||||
a,
|
||||
b,
|
||||
c,
|
||||
d,
|
||||
}));
|
||||
|
||||
export function test() {
|
||||
let ran = false;
|
||||
lines = [
|
||||
[undefined, undefined, undefined, undefined],
|
||||
[undefined, undefined, undefined, undefined],
|
||||
[undefined, undefined, undefined, undefined],
|
||||
[undefined, undefined, undefined, undefined],
|
||||
];
|
||||
|
||||
for (let foo of data()) {
|
||||
console.assert(foo.a === null);
|
||||
console.assert(foo.b === null);
|
||||
console.assert(foo.c === null);
|
||||
console.assert(foo.d === null);
|
||||
ran = true;
|
||||
}
|
||||
console.assert(ran);
|
||||
testDone(import.meta.url);
|
||||
}
|
||||
56
integration/snippets/code-simplification-neql-define.js
Normal file
56
integration/snippets/code-simplification-neql-define.js
Normal file
@@ -0,0 +1,56 @@
|
||||
var testFailed = false;
|
||||
const invariant = () => {
|
||||
testFailed = true;
|
||||
};
|
||||
var $$m = (arg) => {
|
||||
var module = { exports: {} },
|
||||
exports = module.exports;
|
||||
return arg(module, exports);
|
||||
};
|
||||
var size = 100,
|
||||
ttl = 3600;
|
||||
|
||||
export var $f332019d = $$m(
|
||||
{
|
||||
"relay-runtime/lib/network/RelayQueryResponseCache.js": (
|
||||
module,
|
||||
exports
|
||||
) => {
|
||||
var RelayQueryResponseCache = function () {
|
||||
var foo = function RelayQueryResponseCache(_ref) {
|
||||
var size = _ref.size,
|
||||
ttl = _ref.ttl;
|
||||
!(size > 0)
|
||||
? process.env.NODE_ENV !== "production"
|
||||
? invariant(
|
||||
false,
|
||||
"RelayQueryResponseCache: Expected the max cache size to be > 0, got " +
|
||||
"`%s`.",
|
||||
size
|
||||
)
|
||||
: invariant(false)
|
||||
: void 0;
|
||||
!(ttl > 0)
|
||||
? process.env.NODE_ENV !== "production"
|
||||
? invariant(
|
||||
false,
|
||||
"RelayQueryResponseCache: Expected the max ttl to be > 0, got `%s`.",
|
||||
ttl
|
||||
)
|
||||
: invariant(false)
|
||||
: void 0;
|
||||
};
|
||||
foo({ size: 100, ttl: 3600 });
|
||||
};
|
||||
RelayQueryResponseCache();
|
||||
},
|
||||
}["relay-runtime/lib/network/RelayQueryResponseCache.js"]
|
||||
);
|
||||
|
||||
export function test() {
|
||||
var foo = () => result;
|
||||
// $f332019d;
|
||||
|
||||
if (testFailed) throw new Error("invariant should not be called");
|
||||
return testDone(import.meta.url);
|
||||
}
|
||||
10
integration/snippets/forbid-in-is-correct.js
Normal file
10
integration/snippets/forbid-in-is-correct.js
Normal file
@@ -0,0 +1,10 @@
|
||||
var foo = () => {
|
||||
// prettier-ignore
|
||||
var D=(i,r)=>()=>(r||i((r={exports:{}}).exports,r),r.exports);
|
||||
return D;
|
||||
};
|
||||
|
||||
export function test() {
|
||||
foo();
|
||||
testDone(import.meta.url);
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export const target = "browser";
|
||||
@@ -0,0 +1 @@
|
||||
export const target = 'browser';
|
||||
@@ -0,0 +1 @@
|
||||
export const target = 'browser';
|
||||
@@ -0,0 +1 @@
|
||||
export const target = 'browser';
|
||||
@@ -0,0 +1 @@
|
||||
export const target = "default";
|
||||
@@ -0,0 +1 @@
|
||||
export const target = "default";
|
||||
@@ -0,0 +1 @@
|
||||
export const target = 'default';
|
||||
@@ -0,0 +1 @@
|
||||
export const target = "default";
|
||||
@@ -0,0 +1 @@
|
||||
export const target = "node";
|
||||
@@ -0,0 +1 @@
|
||||
export const target = "node";
|
||||
@@ -0,0 +1 @@
|
||||
export const target = 'node';
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "inexact",
|
||||
"exports": {
|
||||
".": {
|
||||
"node": "./node/index.js",
|
||||
"browser": "./browser/index.js",
|
||||
"default": "./default/index.js"
|
||||
},
|
||||
"./foo": {
|
||||
"node": "./node/foo.js",
|
||||
"browser": "./browser/foo.js",
|
||||
"default": "./default/foo.js"
|
||||
},
|
||||
"./": {
|
||||
"node": "./node/dir/",
|
||||
"browser": "./browser/dir/",
|
||||
"default": "./default/dir/"
|
||||
}
|
||||
}
|
||||
}
|
||||
11
integration/snippets/package-json-exports/index.js
Normal file
11
integration/snippets/package-json-exports/index.js
Normal file
@@ -0,0 +1,11 @@
|
||||
import * as InexactRoot from "inexact";
|
||||
import * as InexactFile from "inexact/file";
|
||||
import * as ExactFile from "inexact/foo";
|
||||
|
||||
export async function test() {
|
||||
console.assert(InexactRoot.target === "browser");
|
||||
console.assert(InexactFile.target === "browser");
|
||||
console.assert(ExactFile.target === "browser");
|
||||
|
||||
return testDone(import.meta.url);
|
||||
}
|
||||
3
integration/snippets/package-json-exports/package.json
Normal file
3
integration/snippets/package-json-exports/package.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"name": "package-json-exports"
|
||||
}
|
||||
35
integration/snippets/string-escapes.js
Normal file
35
integration/snippets/string-escapes.js
Normal file
@@ -0,0 +1,35 @@
|
||||
var tab = "\t";
|
||||
var シ = "wow";
|
||||
var f = "";
|
||||
var obj = {
|
||||
"\r\n": "\r\n",
|
||||
"\n": "\n",
|
||||
"\t": "\t",
|
||||
"\u2028": "\u2028",
|
||||
"\u2029": "\u2029",
|
||||
"😊": "😊",
|
||||
"😃": "😃",
|
||||
"㋡": "㋡",
|
||||
"☺": "☺",
|
||||
シ: "シ",
|
||||
f: f,
|
||||
"☹": "☹",
|
||||
"☻": "☻",
|
||||
children: 123,
|
||||
};
|
||||
const foo = () => {};
|
||||
const Bar = foo("a", {
|
||||
children: 123,
|
||||
});
|
||||
|
||||
const carriage = obj["\r\n"];
|
||||
const newline = obj["\n"];
|
||||
|
||||
export { obj };
|
||||
|
||||
export function test() {
|
||||
console.assert(carriage === "\r\n");
|
||||
console.assert(newline === "\n");
|
||||
console.assert(tab === "\t");
|
||||
return testDone(import.meta.url);
|
||||
}
|
||||
15
integration/snippets/unicode-identifiers.js
Normal file
15
integration/snippets/unicode-identifiers.js
Normal file
@@ -0,0 +1,15 @@
|
||||
var ε = 1e-6,
|
||||
ε2 = ε * ε,
|
||||
π = Math.PI,
|
||||
τ = 2 * π,
|
||||
τε = τ - ε,
|
||||
halfπ = π / 2,
|
||||
d3_radians = π / 180,
|
||||
d3_degrees = 180 / π;
|
||||
|
||||
export { d3_radians };
|
||||
|
||||
export function test() {
|
||||
console.assert(ε === 1e-6);
|
||||
return testDone(import.meta.url);
|
||||
}
|
||||
138
misctools/gen-unicode-table.js
Normal file
138
misctools/gen-unicode-table.js
Normal file
@@ -0,0 +1,138 @@
|
||||
// Thank you @evanw for this code!!!
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
|
||||
// ES5 reference: https://es5.github.io/
|
||||
//
|
||||
// A conforming implementation of this International standard shall interpret
|
||||
// characters in conformance with the Unicode Standard, Version 3.0 or later
|
||||
// and ISO/IEC 10646-1 with either UCS-2 or UTF-16 as the adopted encoding
|
||||
// form, implementation level 3. If the adopted ISO/IEC 10646-1 subset is not
|
||||
// otherwise specified, it is presumed to be the BMP subset, collection 300.
|
||||
//
|
||||
// UnicodeLetter: any character in the Unicode categories “Uppercase letter (Lu)”,
|
||||
// “Lowercase letter (Ll)”, “Titlecase letter (Lt)”, “Modifier letter (Lm)”,
|
||||
// “Other letter (Lo)”, or “Letter number (Nl)”.
|
||||
const idStartES5 = []
|
||||
.concat(
|
||||
require("@unicode/unicode-3.0.0/General_Category/Uppercase_Letter/code-points"),
|
||||
require("@unicode/unicode-3.0.0/General_Category/Lowercase_Letter/code-points"),
|
||||
require("@unicode/unicode-3.0.0/General_Category/Titlecase_Letter/code-points"),
|
||||
require("@unicode/unicode-3.0.0/General_Category/Modifier_Letter/code-points"),
|
||||
require("@unicode/unicode-3.0.0/General_Category/Other_Letter/code-points")
|
||||
|
||||
// The "letter number" category is not included because old versions of Safari
|
||||
// had a bug where they didn't include it. This means it does not match ES5.
|
||||
// We need to make sure we escape these characters so Safari can read them.
|
||||
// See https://github.com/evanw/esbuild/issues/1349 for more information.
|
||||
// require('@unicode/unicode-3.0.0/General_Category/Letter_Number/code-points'),
|
||||
)
|
||||
.sort((a, b) => a - b);
|
||||
|
||||
// UnicodeCombiningMark: any character in the Unicode categories “Non-spacing mark (Mn)”
|
||||
// or “Combining spacing mark (Mc)”
|
||||
// UnicodeDigit: any character in the Unicode category “Decimal number (Nd)”
|
||||
// UnicodeConnectorPunctuation: any character in the Unicode category “Connector punctuation (Pc)”
|
||||
const idContinueES5 = idStartES5
|
||||
.concat(
|
||||
require("@unicode/unicode-3.0.0/General_Category/Nonspacing_Mark/code-points"),
|
||||
require("@unicode/unicode-3.0.0/General_Category/Spacing_Mark/code-points"),
|
||||
require("@unicode/unicode-3.0.0/General_Category/Decimal_Number/code-points"),
|
||||
require("@unicode/unicode-3.0.0/General_Category/Connector_Punctuation/code-points")
|
||||
)
|
||||
.sort((a, b) => a - b);
|
||||
|
||||
// ESNext reference: https://tc39.es/ecma262/
|
||||
//
|
||||
// A conforming implementation of ECMAScript must interpret source text input
|
||||
// in conformance with the Unicode Standard, Version 5.1.0 or later and ISO/IEC
|
||||
// 10646. If the adopted ISO/IEC 10646-1 subset is not otherwise specified, it
|
||||
// is presumed to be the Unicode set, collection 10646.
|
||||
//
|
||||
// UnicodeIDStart: any Unicode code point with the Unicode property “ID_Start”
|
||||
const idStartESNext = require("@unicode/unicode-13.0.0/Binary_Property/ID_Start/code-points");
|
||||
const idStartESNextSet = new Set(idStartESNext);
|
||||
|
||||
// UnicodeIDContinue: any Unicode code point with the Unicode property “ID_Continue”
|
||||
const idContinueESNext = require("@unicode/unicode-13.0.0/Binary_Property/ID_Continue/code-points");
|
||||
const idContinueESNextSet = new Set(idContinueESNext);
|
||||
|
||||
// These identifiers are valid in both ES5 and ES6+ (i.e. an intersection of both)
|
||||
const idStartES5AndESNext = idStartES5.filter((n) => idStartESNextSet.has(n));
|
||||
const idContinueES5AndESNext = idContinueES5.filter((n) =>
|
||||
idContinueESNextSet.has(n)
|
||||
);
|
||||
|
||||
// These identifiers are valid in either ES5 or ES6+ (i.e. a union of both)
|
||||
const idStartES5OrESNext = [...new Set(idStartES5.concat(idStartESNext))].sort(
|
||||
(a, b) => a - b
|
||||
);
|
||||
const idContinueES5OrESNext = [
|
||||
...new Set(idContinueES5.concat(idContinueESNext)),
|
||||
].sort((a, b) => a - b);
|
||||
|
||||
function generateRangeTable(codePoints) {
|
||||
let lines = [];
|
||||
let index = 0;
|
||||
let latinOffset = 0;
|
||||
|
||||
while (latinOffset < codePoints.length && codePoints[latinOffset] <= 0xff) {
|
||||
latinOffset++;
|
||||
}
|
||||
|
||||
lines.push(`RangeTable.init(`, ` ${latinOffset},`, ` &[_]R16Range{`);
|
||||
|
||||
// 16-bit code points
|
||||
while (index < codePoints.length && codePoints[index] < 0x1000) {
|
||||
let start = codePoints[index];
|
||||
index++;
|
||||
while (
|
||||
index < codePoints.length &&
|
||||
codePoints[index] < 0x1000 &&
|
||||
codePoints[index] === codePoints[index - 1] + 1
|
||||
) {
|
||||
index++;
|
||||
}
|
||||
let end = codePoints[index - 1];
|
||||
lines.push(` .{0x${start.toString(16)}, 0x${end.toString(16)}},`);
|
||||
}
|
||||
|
||||
lines.push(` },`, `&[_]R32Range{`);
|
||||
|
||||
// 32-bit code points
|
||||
while (index < codePoints.length) {
|
||||
let start = codePoints[index];
|
||||
index++;
|
||||
while (
|
||||
index < codePoints.length &&
|
||||
codePoints[index] === codePoints[index - 1] + 1
|
||||
) {
|
||||
index++;
|
||||
}
|
||||
let end = codePoints[index - 1];
|
||||
lines.push(` .{0x${start.toString(16)}, 0x${end.toString(16)}},`);
|
||||
}
|
||||
|
||||
lines.push(` },`, `);`);
|
||||
return lines.join("\n");
|
||||
}
|
||||
|
||||
fs.writeFileSync(
|
||||
path.join(__dirname, "..", "src", "js_lexer", "unicode.zig"),
|
||||
`// This file was automatically generated by ${path.basename(
|
||||
__filename
|
||||
)}. Do not edit.
|
||||
|
||||
const RangeTable = @import("./range_table.zig");
|
||||
|
||||
|
||||
// ES5 || ESNext
|
||||
pub const id_start = ${generateRangeTable(idStartES5OrESNext)}
|
||||
|
||||
// ES5 || ESNext
|
||||
pub const id_continue = ${generateRangeTable(idContinueES5OrESNext)}
|
||||
|
||||
pub const printable_id_start = ${generateRangeTable(idStartESNext)}
|
||||
pub const printable_id_continue = ${generateRangeTable(idContinueESNext)}
|
||||
`
|
||||
);
|
||||
10
misctools/package.json
Normal file
10
misctools/package.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"name": "misctools",
|
||||
"version": "1.0.0",
|
||||
"main": "index.js",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@unicode/unicode-13.0.0": "^1.2.1",
|
||||
"@unicode/unicode-3.0.0": "^1.2.1"
|
||||
}
|
||||
}
|
||||
@@ -4,5 +4,5 @@
|
||||
},
|
||||
"name": "bun-cli-darwin-x64",
|
||||
"repository": "https://github.com/jarred-sumner/bun",
|
||||
"version": "0.0.19"
|
||||
"version": "0.0.20"
|
||||
}
|
||||
|
||||
@@ -9,5 +9,5 @@
|
||||
"postinstall": "node postinstall.js",
|
||||
"prepublishOnly": "rm -rf ./bin/bun; chmod +x ./reset-bin.js; cp ./reset-bin.js ./bin/bun"
|
||||
},
|
||||
"version": "0.0.19"
|
||||
"version": "0.0.20"
|
||||
}
|
||||
|
||||
@@ -132,29 +132,46 @@ const hasDeinit = std.meta.trait.hasFn("deinit")(ValueType);
|
||||
pub fn BSSList(comptime ValueType: type, comptime _count: anytype) type {
|
||||
const count = _count * 2;
|
||||
const max_index = count - 1;
|
||||
var list_type: type = undefined;
|
||||
var list_count = count;
|
||||
const overflow_init_count = std.math.max(count / 8, 32);
|
||||
return struct {
|
||||
pub var backing_buf: [count]ValueType = undefined;
|
||||
pub var backing_buf_used: u16 = 0;
|
||||
const ChunkSize = 256;
|
||||
const OverflowBlock = struct {
|
||||
used: std.atomic.Atomic(u16) = std.atomic.Atomic(u16).init(0),
|
||||
data: [ChunkSize]ValueType = undefined,
|
||||
prev: ?*OverflowBlock = null,
|
||||
|
||||
pub fn append(this: *OverflowBlock, item: ValueType) !*ValueType {
|
||||
const index = this.used.fetchAdd(1, .AcqRel);
|
||||
if (index >= ChunkSize) return error.OutOfMemory;
|
||||
this.data[index] = item;
|
||||
return &this.data[index];
|
||||
}
|
||||
};
|
||||
|
||||
pub var used: u32 = 0;
|
||||
const Allocator = std.mem.Allocator;
|
||||
const Self = @This();
|
||||
const OverflowListType = std.ArrayListUnmanaged(ValueType);
|
||||
|
||||
overflow_list: OverflowListType,
|
||||
allocator: *Allocator,
|
||||
mutex: Mutex = Mutex.init(),
|
||||
head: *OverflowBlock = undefined,
|
||||
tail: OverflowBlock = OverflowBlock{},
|
||||
|
||||
pub var instance: Self = undefined;
|
||||
pub var loaded = false;
|
||||
|
||||
pub inline fn blockIndex(index: u31) usize {
|
||||
return index / ChunkSize;
|
||||
}
|
||||
|
||||
pub fn init(allocator: *std.mem.Allocator) *Self {
|
||||
if (!loaded) {
|
||||
instance = Self{
|
||||
.allocator = allocator,
|
||||
.overflow_list = OverflowListType{},
|
||||
.tail = OverflowBlock{},
|
||||
};
|
||||
instance.head = &instance.tail;
|
||||
loaded = true;
|
||||
}
|
||||
|
||||
@@ -162,121 +179,37 @@ pub fn BSSList(comptime ValueType: type, comptime _count: anytype) type {
|
||||
}
|
||||
|
||||
pub fn isOverflowing() bool {
|
||||
return backing_buf_used >= @as(u16, count);
|
||||
}
|
||||
|
||||
pub fn at(self: *const Self, index: IndexType) ?*ValueType {
|
||||
if (index.index == NotFound.index or index.index == Unassigned.index) return null;
|
||||
|
||||
if (index.is_overflow) {
|
||||
return &self.overflow_list.items[index.index];
|
||||
} else {
|
||||
return &backing_buf[index.index];
|
||||
}
|
||||
return used >= @as(u16, count);
|
||||
}
|
||||
|
||||
pub fn exists(self: *Self, value: ValueType) bool {
|
||||
return isSliceInBuffer(value, backing_buf);
|
||||
}
|
||||
|
||||
pub fn append(self: *Self, value: ValueType) !IndexType {
|
||||
fn appendOverflow(self: *Self, value: ValueType) !*ValueType {
|
||||
used += 1;
|
||||
return self.head.append(value) catch brk: {
|
||||
var new_block = try self.allocator.create(OverflowBlock);
|
||||
new_block.* = OverflowBlock{};
|
||||
new_block.prev = self.head;
|
||||
self.head = new_block;
|
||||
break :brk self.head.append(value);
|
||||
};
|
||||
}
|
||||
|
||||
pub fn append(self: *Self, value: ValueType) !*ValueType {
|
||||
self.mutex.lock();
|
||||
defer self.mutex.unlock();
|
||||
var result = IndexType{ .index = std.math.maxInt(u31), .is_overflow = backing_buf_used > max_index };
|
||||
if (result.is_overflow) {
|
||||
result.index = @intCast(u31, self.overflow_list.items.len);
|
||||
try self.overflow_list.append(self.allocator, value);
|
||||
if (used > max_index) {
|
||||
return self.appendOverflow(value);
|
||||
} else {
|
||||
result.index = backing_buf_used;
|
||||
backing_buf[result.index] = value;
|
||||
backing_buf_used += 1;
|
||||
if (backing_buf_used >= max_index) {
|
||||
self.overflow_list = try @TypeOf(self.overflow_list).initCapacity(self.allocator, overflow_init_count);
|
||||
}
|
||||
const index = used;
|
||||
backing_buf[index] = value;
|
||||
used += 1;
|
||||
return &backing_buf[index];
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
pub const Pair = struct { index: IndexType, value: *ValueType };
|
||||
pub fn appendGet(self: *Self, value: ValueType) !Pair {
|
||||
self.mutex.lock();
|
||||
defer self.mutex.unlock();
|
||||
|
||||
var result = IndexType{ .index = std.math.maxInt(u31), .is_overflow = backing_buf_used > max_index };
|
||||
if (result.is_overflow) {
|
||||
result.index = @intCast(u31, self.overflow_list.items.len);
|
||||
try self.overflow_list.append(self.allocator, value);
|
||||
return Pair{ .index = result, .value = &self.overflow_list.items[result.index] };
|
||||
} else {
|
||||
result.index = backing_buf_used;
|
||||
backing_buf[result.index] = value;
|
||||
backing_buf_used += 1;
|
||||
if (backing_buf_used >= max_index) {
|
||||
self.overflow_list = try @TypeOf(self.overflow_list).initCapacity(self.allocator, overflow_init_count);
|
||||
}
|
||||
return Pair{ .index = result, .value = &backing_buf[result.index] };
|
||||
}
|
||||
}
|
||||
|
||||
pub fn update(self: *Self, result: *IndexType, value: ValueType) !*ValueType {
|
||||
self.mutex.lock();
|
||||
defer self.mutex.unlock();
|
||||
|
||||
if (result.index.index == NotFound.index or result.index.index == Unassigned.index) {
|
||||
result.index.is_overflow = backing_buf_used > max_index;
|
||||
if (result.index.is_overflow) {
|
||||
result.index.index = @intCast(u31, self.overflow_list.items.len);
|
||||
} else {
|
||||
result.index.index = backing_buf_used;
|
||||
backing_buf_used += 1;
|
||||
if (backing_buf_used >= max_index) {
|
||||
self.overflow_list = try @TypeOf(self.overflow_list).initCapacity(self.allocator, overflow_init_count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (result.index.is_overflow) {
|
||||
if (self.overflow_list.items.len == result.index.index) {
|
||||
const real_index = self.overflow_list.items.len;
|
||||
try self.overflow_list.append(self.allocator, value);
|
||||
} else {
|
||||
self.overflow_list.items[result.index.index] = value;
|
||||
}
|
||||
|
||||
return &self.overflow_list.items[result.index.index];
|
||||
} else {
|
||||
backing_buf[result.index.index] = value;
|
||||
|
||||
return &backing_buf[result.index.index];
|
||||
}
|
||||
}
|
||||
|
||||
pub fn remove(self: *Self, index: IndexType) void {
|
||||
@compileError("Not implemented yet.");
|
||||
// switch (index) {
|
||||
// Unassigned.index => {
|
||||
// self.index.remove(_key);
|
||||
// },
|
||||
// NotFound.index => {
|
||||
// self.index.remove(_key);
|
||||
// },
|
||||
// 0...max_index => {
|
||||
// if (hasDeinit(ValueType)) {
|
||||
// backing_buf[index].deinit();
|
||||
// }
|
||||
// backing_buf[index] = undefined;
|
||||
// },
|
||||
// else => {
|
||||
// const i = index - count;
|
||||
// if (hasDeinit(ValueType)) {
|
||||
// self.overflow_list.items[i].deinit();
|
||||
// }
|
||||
// self.overflow_list.items[index - count] = undefined;
|
||||
// },
|
||||
// }
|
||||
|
||||
// return index;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
106
src/ast/ast.js
Normal file
106
src/ast/ast.js
Normal file
@@ -0,0 +1,106 @@
|
||||
globalThis.BunASTNode ??= class BunASTNode {
|
||||
position = -1;
|
||||
};
|
||||
|
||||
if (!globalThis.BunAST) {
|
||||
globalThis.BunAST = {
|
||||
EArray: class EArray extends BunASTNode {
|
||||
#ptr = Number.MAX_SAFE_INTEGER;
|
||||
},
|
||||
EUnary: class EUnary extends BunASTNode {
|
||||
#ptr = Number.MAX_SAFE_INTEGER;
|
||||
},
|
||||
EBinary: class EBinary extends BunASTNode {
|
||||
#ptr = Number.MAX_SAFE_INTEGER;
|
||||
},
|
||||
EClass: class EClass extends BunASTNode {
|
||||
#ptr = Number.MAX_SAFE_INTEGER;
|
||||
},
|
||||
ENew: class ENew extends BunASTNode {
|
||||
#ptr = Number.MAX_SAFE_INTEGER;
|
||||
},
|
||||
EFunction: class EFunction extends BunASTNode {
|
||||
#ptr = Number.MAX_SAFE_INTEGER;
|
||||
},
|
||||
ECall: class ECall extends BunASTNode {
|
||||
#ptr = Number.MAX_SAFE_INTEGER;
|
||||
},
|
||||
EDot: class EDot extends BunASTNode {
|
||||
#ptr = Number.MAX_SAFE_INTEGER;
|
||||
},
|
||||
EIndex: class EIndex extends BunASTNode {
|
||||
#ptr = Number.MAX_SAFE_INTEGER;
|
||||
},
|
||||
EArrow: class EArrow extends BunASTNode {
|
||||
#ptr = Number.MAX_SAFE_INTEGER;
|
||||
},
|
||||
EIdentifier: class EIdentifier extends BunASTNode {
|
||||
#ptr = Number.MAX_SAFE_INTEGER;
|
||||
},
|
||||
EImportIdentifier: class EImportIdentifier extends BunASTNode {
|
||||
#ptr = Number.MAX_SAFE_INTEGER;
|
||||
},
|
||||
EPrivateIdentifier: class EPrivateIdentifier extends BunASTNode {
|
||||
#ptr = Number.MAX_SAFE_INTEGER;
|
||||
},
|
||||
EJsxElement: class EJsxElement extends BunASTNode {
|
||||
#ptr = Number.MAX_SAFE_INTEGER;
|
||||
},
|
||||
EObject: class EObject extends BunASTNode {
|
||||
#ptr = Number.MAX_SAFE_INTEGER;
|
||||
},
|
||||
ESpread: class ESpread extends BunASTNode {
|
||||
#ptr = Number.MAX_SAFE_INTEGER;
|
||||
},
|
||||
ETemplatePart: class ETemplatePart extends BunASTNode {
|
||||
#ptr = Number.MAX_SAFE_INTEGER;
|
||||
},
|
||||
ETemplate: class ETemplate extends BunASTNode {
|
||||
#ptr = Number.MAX_SAFE_INTEGER;
|
||||
},
|
||||
ERegExp: class ERegExp extends BunASTNode {
|
||||
#ptr = Number.MAX_SAFE_INTEGER;
|
||||
},
|
||||
EAwait: class EAwait extends BunASTNode {
|
||||
#ptr = Number.MAX_SAFE_INTEGER;
|
||||
},
|
||||
EYield: class EYield extends BunASTNode {
|
||||
#ptr = Number.MAX_SAFE_INTEGER;
|
||||
},
|
||||
EIf: class EIf extends BunASTNode {
|
||||
no = Number.MAX_SAFE_INTEGER;
|
||||
yes = Number.MAX_SAFE_INTEGER;
|
||||
},
|
||||
ERequire: class ERequire extends BunASTNode {
|
||||
#ptr = Number.MAX_SAFE_INTEGER;
|
||||
},
|
||||
EImport: class EImport extends BunASTNode {
|
||||
#ptr = Number.MAX_SAFE_INTEGER;
|
||||
},
|
||||
EBoolean: class EBoolean extends BunASTNode {
|
||||
val = false;
|
||||
},
|
||||
ENumber: class ENumber extends BunASTNode {
|
||||
val = 0;
|
||||
},
|
||||
EBigInt: class EBigInt extends BunASTNode {
|
||||
#ptr = Number.MAX_SAFE_INTEGER;
|
||||
},
|
||||
EString: class EString extends BunASTNode {
|
||||
#ptr = Number.MAX_SAFE_INTEGER;
|
||||
},
|
||||
EMissing: class EMissing extends BunASTNode {
|
||||
#ptr = Number.MAX_SAFE_INTEGER;
|
||||
},
|
||||
EThis: class EThis extends BunASTNode {},
|
||||
ESuper: class ESuper extends BunASTNode {
|
||||
#ptr = Number.MAX_SAFE_INTEGER;
|
||||
},
|
||||
ENull: class ENull extends BunASTNode {},
|
||||
EUndefined: class EUndefined extends BunASTNode {},
|
||||
ENewTarget: class ENewTarget extends BunASTNode {
|
||||
#ptr = Number.MAX_SAFE_INTEGER;
|
||||
},
|
||||
EImportMeta: class EImportMeta extends BunASTNode {},
|
||||
};
|
||||
}
|
||||
4865
src/bundler.zig
4865
src/bundler.zig
File diff suppressed because it is too large
Load Diff
551
src/cache.zig
551
src/cache.zig
@@ -28,328 +28,251 @@ pub const FsCacheEntry = struct {
|
||||
}
|
||||
};
|
||||
|
||||
pub fn NewCache(comptime cache_files: bool) type {
|
||||
return struct {
|
||||
pub const Set = struct {
|
||||
js: JavaScript,
|
||||
fs: Fs,
|
||||
json: Json,
|
||||
pub const Set = struct {
|
||||
js: JavaScript,
|
||||
fs: Fs,
|
||||
json: Json,
|
||||
|
||||
pub fn init(allocator: *std.mem.Allocator) Set {
|
||||
return Set{
|
||||
.js = JavaScript.init(allocator),
|
||||
.fs = Fs{
|
||||
.mutex = Mutex.init(),
|
||||
.entries = std.StringHashMap(Fs.Entry).init(allocator),
|
||||
.shared_buffer = MutableString.init(allocator, 0) catch unreachable,
|
||||
},
|
||||
.json = Json{
|
||||
.mutex = Mutex.init(),
|
||||
.entries = std.StringHashMap(*Json.Entry).init(allocator),
|
||||
},
|
||||
};
|
||||
}
|
||||
pub fn init(allocator: *std.mem.Allocator) Set {
|
||||
return Set{
|
||||
.js = JavaScript.init(allocator),
|
||||
.fs = Fs{
|
||||
.shared_buffer = MutableString.init(allocator, 0) catch unreachable,
|
||||
},
|
||||
.json = Json{},
|
||||
};
|
||||
pub const Fs = struct {
|
||||
const Entry = FsCacheEntry;
|
||||
}
|
||||
};
|
||||
pub const Fs = struct {
|
||||
const Entry = FsCacheEntry;
|
||||
|
||||
mutex: Mutex,
|
||||
entries: std.StringHashMap(Entry),
|
||||
shared_buffer: MutableString,
|
||||
shared_buffer: MutableString,
|
||||
|
||||
pub fn deinit(c: *Fs) void {
|
||||
var iter = c.entries.iterator();
|
||||
while (iter.next()) |entry| {
|
||||
entry.value.deinit(c.entries.allocator);
|
||||
}
|
||||
c.entries.deinit();
|
||||
pub fn deinit(c: *Fs) void {
|
||||
var iter = c.entries.iterator();
|
||||
while (iter.next()) |entry| {
|
||||
entry.value.deinit(c.entries.allocator);
|
||||
}
|
||||
c.entries.deinit();
|
||||
}
|
||||
|
||||
pub fn readFileShared(
|
||||
c: *Fs,
|
||||
_fs: *fs.FileSystem,
|
||||
path: [:0]const u8,
|
||||
dirname_fd: StoredFileDescriptorType,
|
||||
_file_handle: ?StoredFileDescriptorType,
|
||||
shared: *MutableString,
|
||||
) !Entry {
|
||||
var rfs = _fs.fs;
|
||||
|
||||
var file_handle: std.fs.File = if (_file_handle) |__file| std.fs.File{ .handle = __file } else undefined;
|
||||
|
||||
if (_file_handle == null) {
|
||||
file_handle = try std.fs.openFileAbsoluteZ(path, .{ .read = true });
|
||||
}
|
||||
|
||||
defer {
|
||||
if (rfs.needToCloseFiles() and _file_handle == null) {
|
||||
file_handle.close();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn readFileShared(
|
||||
c: *Fs,
|
||||
_fs: *fs.FileSystem,
|
||||
path: [:0]const u8,
|
||||
dirname_fd: StoredFileDescriptorType,
|
||||
_file_handle: ?StoredFileDescriptorType,
|
||||
shared: *MutableString,
|
||||
) !Entry {
|
||||
var rfs = _fs.fs;
|
||||
|
||||
if (comptime cache_files) {
|
||||
{
|
||||
c.mutex.lock();
|
||||
defer c.mutex.unlock();
|
||||
if (c.entries.get(path)) |entry| {
|
||||
return entry;
|
||||
}
|
||||
// If the file's modification key hasn't changed since it was cached, assume
|
||||
// the contents of the file are also the same and skip reading the file.
|
||||
var mod_key: ?fs.FileSystem.Implementation.ModKey = rfs.modKeyWithFile(path, file_handle) catch |err| handler: {
|
||||
switch (err) {
|
||||
error.FileNotFound, error.AccessDenied => {
|
||||
return err;
|
||||
},
|
||||
else => {
|
||||
if (isDebug) {
|
||||
Output.printError("modkey error: {s}", .{@errorName(err)});
|
||||
}
|
||||
}
|
||||
|
||||
var file_handle: std.fs.File = if (_file_handle) |__file| std.fs.File{ .handle = __file } else undefined;
|
||||
|
||||
if (_file_handle == null) {
|
||||
file_handle = try std.fs.openFileAbsoluteZ(path, .{ .read = true });
|
||||
}
|
||||
|
||||
defer {
|
||||
if (rfs.needToCloseFiles() and _file_handle == null) {
|
||||
file_handle.close();
|
||||
}
|
||||
}
|
||||
|
||||
// If the file's modification key hasn't changed since it was cached, assume
|
||||
// the contents of the file are also the same and skip reading the file.
|
||||
var mod_key: ?fs.FileSystem.Implementation.ModKey = rfs.modKeyWithFile(path, file_handle) catch |err| handler: {
|
||||
switch (err) {
|
||||
error.FileNotFound, error.AccessDenied => {
|
||||
return err;
|
||||
},
|
||||
else => {
|
||||
if (isDebug) {
|
||||
Output.printError("modkey error: {s}", .{@errorName(err)});
|
||||
}
|
||||
break :handler null;
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
var file: fs.File = undefined;
|
||||
if (mod_key) |modk| {
|
||||
file = rfs.readFileWithHandle(path, modk.size, file_handle, true, shared) catch |err| {
|
||||
if (isDebug) {
|
||||
Output.printError("{s}: readFile error -- {s}", .{ path, @errorName(err) });
|
||||
}
|
||||
return err;
|
||||
};
|
||||
} else {
|
||||
file = rfs.readFileWithHandle(path, null, file_handle, true, shared) catch |err| {
|
||||
if (isDebug) {
|
||||
Output.printError("{s}: readFile error -- {s}", .{ path, @errorName(err) });
|
||||
}
|
||||
return err;
|
||||
};
|
||||
}
|
||||
|
||||
const entry = Entry{
|
||||
.contents = file.contents,
|
||||
.mod_key = mod_key,
|
||||
.fd = if (FeatureFlags.store_file_descriptors) file_handle.handle else 0,
|
||||
};
|
||||
|
||||
if (comptime cache_files) {
|
||||
c.mutex.lock();
|
||||
defer c.mutex.unlock();
|
||||
var res = c.entries.getOrPut(path) catch unreachable;
|
||||
|
||||
if (res.found_existing) {
|
||||
res.value_ptr.*.deinit(c.entries.allocator);
|
||||
}
|
||||
res.value_ptr.* = entry;
|
||||
return res.value_ptr.*;
|
||||
} else {
|
||||
return entry;
|
||||
}
|
||||
}
|
||||
|
||||
pub fn readFile(
|
||||
c: *Fs,
|
||||
_fs: *fs.FileSystem,
|
||||
path: string,
|
||||
dirname_fd: StoredFileDescriptorType,
|
||||
comptime use_shared_buffer: bool,
|
||||
_file_handle: ?StoredFileDescriptorType,
|
||||
) !Entry {
|
||||
var rfs = _fs.fs;
|
||||
|
||||
if (comptime cache_files) {
|
||||
{
|
||||
c.mutex.lock();
|
||||
defer c.mutex.unlock();
|
||||
if (c.entries.get(path)) |entry| {
|
||||
return entry;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var file_handle: std.fs.File = if (_file_handle) |__file| std.fs.File{ .handle = __file } else undefined;
|
||||
|
||||
if (_file_handle == null) {
|
||||
if (FeatureFlags.store_file_descriptors and dirname_fd > 0) {
|
||||
file_handle = std.fs.Dir.openFile(std.fs.Dir{ .fd = dirname_fd }, std.fs.path.basename(path), .{ .read = true }) catch |err| brk: {
|
||||
switch (err) {
|
||||
error.FileNotFound => {
|
||||
const handle = try std.fs.openFileAbsolute(path, .{ .read = true });
|
||||
Output.prettyErrorln(
|
||||
"<r><d>Internal error: directory mismatch for directory \"{s}\", fd {d}<r>. You don't need to do anything, but this indicates a bug.",
|
||||
.{ path, dirname_fd },
|
||||
);
|
||||
break :brk handle;
|
||||
},
|
||||
else => return err,
|
||||
}
|
||||
};
|
||||
} else {
|
||||
file_handle = try std.fs.openFileAbsolute(path, .{ .read = true });
|
||||
}
|
||||
}
|
||||
|
||||
defer {
|
||||
if (rfs.needToCloseFiles() and _file_handle == null) {
|
||||
file_handle.close();
|
||||
}
|
||||
}
|
||||
|
||||
// If the file's modification key hasn't changed since it was cached, assume
|
||||
// the contents of the file are also the same and skip reading the file.
|
||||
var mod_key: ?fs.FileSystem.Implementation.ModKey = rfs.modKeyWithFile(path, file_handle) catch |err| handler: {
|
||||
switch (err) {
|
||||
error.FileNotFound, error.AccessDenied => {
|
||||
return err;
|
||||
},
|
||||
else => {
|
||||
if (isDebug) {
|
||||
Output.printError("modkey error: {s}", .{@errorName(err)});
|
||||
}
|
||||
break :handler null;
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
var file: fs.File = undefined;
|
||||
if (mod_key) |modk| {
|
||||
file = rfs.readFileWithHandle(path, modk.size, file_handle, use_shared_buffer, &c.shared_buffer) catch |err| {
|
||||
if (isDebug) {
|
||||
Output.printError("{s}: readFile error -- {s}", .{ path, @errorName(err) });
|
||||
}
|
||||
return err;
|
||||
};
|
||||
} else {
|
||||
file = rfs.readFileWithHandle(path, null, file_handle, use_shared_buffer, &c.shared_buffer) catch |err| {
|
||||
if (isDebug) {
|
||||
Output.printError("{s}: readFile error -- {s}", .{ path, @errorName(err) });
|
||||
}
|
||||
return err;
|
||||
};
|
||||
}
|
||||
|
||||
const entry = Entry{
|
||||
.contents = file.contents,
|
||||
.mod_key = mod_key,
|
||||
.fd = if (FeatureFlags.store_file_descriptors) file_handle.handle else 0,
|
||||
};
|
||||
|
||||
if (comptime cache_files) {
|
||||
c.mutex.lock();
|
||||
defer c.mutex.unlock();
|
||||
var res = c.entries.getOrPut(path) catch unreachable;
|
||||
|
||||
if (res.found_existing) {
|
||||
res.value_ptr.*.deinit(c.entries.allocator);
|
||||
}
|
||||
res.value_ptr.* = entry;
|
||||
return res.value_ptr.*;
|
||||
} else {
|
||||
return entry;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
pub const Css = struct {
|
||||
pub const Entry = struct {};
|
||||
pub const Result = struct {
|
||||
ok: bool,
|
||||
value: void,
|
||||
};
|
||||
pub fn parse(cache: *@This(), log: *logger.Log, source: logger.Source) !Result {
|
||||
Global.notimpl();
|
||||
}
|
||||
};
|
||||
|
||||
pub const JavaScript = struct {
|
||||
mutex: Mutex,
|
||||
entries: std.StringHashMap(Result),
|
||||
|
||||
pub const Result = js_ast.Result;
|
||||
|
||||
pub fn init(allocator: *std.mem.Allocator) JavaScript {
|
||||
return JavaScript{ .mutex = Mutex.init(), .entries = std.StringHashMap(Result).init(allocator) };
|
||||
}
|
||||
// For now, we're not going to cache JavaScript ASTs.
|
||||
// It's probably only relevant when bundling for production.
|
||||
pub fn parse(
|
||||
cache: *@This(),
|
||||
allocator: *std.mem.Allocator,
|
||||
opts: js_parser.Parser.Options,
|
||||
defines: *Define,
|
||||
log: *logger.Log,
|
||||
source: *const logger.Source,
|
||||
) anyerror!?js_ast.Ast {
|
||||
var temp_log = logger.Log.init(allocator);
|
||||
defer temp_log.appendToMaybeRecycled(log, source) catch {};
|
||||
var parser = js_parser.Parser.init(opts, &temp_log, source, defines, allocator) catch |err| {
|
||||
return null;
|
||||
};
|
||||
|
||||
const result = try parser.parse();
|
||||
|
||||
return if (result.ok) result.ast else null;
|
||||
}
|
||||
|
||||
pub fn scan(
|
||||
cache: *@This(),
|
||||
allocator: *std.mem.Allocator,
|
||||
scan_pass_result: *js_parser.ScanPassResult,
|
||||
opts: js_parser.Parser.Options,
|
||||
defines: *Define,
|
||||
log: *logger.Log,
|
||||
source: *const logger.Source,
|
||||
) anyerror!void {
|
||||
var temp_log = logger.Log.init(allocator);
|
||||
defer temp_log.appendToMaybeRecycled(log, source) catch {};
|
||||
|
||||
var parser = js_parser.Parser.init(opts, &temp_log, source, defines, allocator) catch |err| {
|
||||
return;
|
||||
};
|
||||
|
||||
return try parser.scanImports(scan_pass_result);
|
||||
}
|
||||
};
|
||||
|
||||
pub const Json = struct {
|
||||
pub const Entry = struct {
|
||||
is_tsconfig: bool = false,
|
||||
source: logger.Source,
|
||||
expr: ?js_ast.Expr = null,
|
||||
ok: bool = false,
|
||||
// msgs: []logger.Msg,
|
||||
};
|
||||
mutex: Mutex,
|
||||
entries: std.StringHashMap(*Entry),
|
||||
pub fn init(allocator: *std.mem.Allocator) Json {
|
||||
return Json{
|
||||
.mutex = Mutex.init(),
|
||||
.entries = std.StringHashMap(Entry).init(allocator),
|
||||
};
|
||||
}
|
||||
fn parse(cache: *@This(), log: *logger.Log, source: logger.Source, allocator: *std.mem.Allocator, is_tsconfig: bool, func: anytype) anyerror!?js_ast.Expr {
|
||||
var temp_log = logger.Log.init(allocator);
|
||||
defer {
|
||||
temp_log.appendTo(log) catch {};
|
||||
}
|
||||
return func(&source, &temp_log, allocator) catch handler: {
|
||||
break :handler null;
|
||||
};
|
||||
}
|
||||
pub fn parseJSON(cache: *@This(), log: *logger.Log, source: logger.Source, allocator: *std.mem.Allocator) anyerror!?js_ast.Expr {
|
||||
return try parse(cache, log, source, allocator, false, json_parser.ParseJSON);
|
||||
}
|
||||
|
||||
pub fn parseTSConfig(cache: *@This(), log: *logger.Log, source: logger.Source, allocator: *std.mem.Allocator) anyerror!?js_ast.Expr {
|
||||
return try parse(cache, log, source, allocator, true, json_parser.ParseTSConfig);
|
||||
},
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
pub const Cache = NewCache(true);
|
||||
pub const ServeCache = NewCache(false);
|
||||
var file: fs.File = undefined;
|
||||
if (mod_key) |modk| {
|
||||
file = rfs.readFileWithHandle(path, modk.size, file_handle, true, shared) catch |err| {
|
||||
if (isDebug) {
|
||||
Output.printError("{s}: readFile error -- {s}", .{ path, @errorName(err) });
|
||||
}
|
||||
return err;
|
||||
};
|
||||
} else {
|
||||
file = rfs.readFileWithHandle(path, null, file_handle, true, shared) catch |err| {
|
||||
if (isDebug) {
|
||||
Output.printError("{s}: readFile error -- {s}", .{ path, @errorName(err) });
|
||||
}
|
||||
return err;
|
||||
};
|
||||
}
|
||||
|
||||
return Entry{
|
||||
.contents = file.contents,
|
||||
.mod_key = mod_key,
|
||||
.fd = if (FeatureFlags.store_file_descriptors) file_handle.handle else 0,
|
||||
};
|
||||
}
|
||||
|
||||
pub fn readFile(
|
||||
c: *Fs,
|
||||
_fs: *fs.FileSystem,
|
||||
path: string,
|
||||
dirname_fd: StoredFileDescriptorType,
|
||||
comptime use_shared_buffer: bool,
|
||||
_file_handle: ?StoredFileDescriptorType,
|
||||
) !Entry {
|
||||
var rfs = _fs.fs;
|
||||
|
||||
var file_handle: std.fs.File = if (_file_handle) |__file| std.fs.File{ .handle = __file } else undefined;
|
||||
|
||||
if (_file_handle == null) {
|
||||
if (FeatureFlags.store_file_descriptors and dirname_fd > 0) {
|
||||
file_handle = std.fs.Dir.openFile(std.fs.Dir{ .fd = dirname_fd }, std.fs.path.basename(path), .{ .read = true }) catch |err| brk: {
|
||||
switch (err) {
|
||||
error.FileNotFound => {
|
||||
const handle = try std.fs.openFileAbsolute(path, .{ .read = true });
|
||||
Output.prettyErrorln(
|
||||
"<r><d>Internal error: directory mismatch for directory \"{s}\", fd {d}<r>. You don't need to do anything, but this indicates a bug.",
|
||||
.{ path, dirname_fd },
|
||||
);
|
||||
break :brk handle;
|
||||
},
|
||||
else => return err,
|
||||
}
|
||||
};
|
||||
} else {
|
||||
file_handle = try std.fs.openFileAbsolute(path, .{ .read = true });
|
||||
}
|
||||
}
|
||||
|
||||
defer {
|
||||
if (rfs.needToCloseFiles() and _file_handle == null) {
|
||||
file_handle.close();
|
||||
}
|
||||
}
|
||||
|
||||
// If the file's modification key hasn't changed since it was cached, assume
|
||||
// the contents of the file are also the same and skip reading the file.
|
||||
var mod_key: ?fs.FileSystem.Implementation.ModKey = rfs.modKeyWithFile(path, file_handle) catch |err| handler: {
|
||||
switch (err) {
|
||||
error.FileNotFound, error.AccessDenied => {
|
||||
return err;
|
||||
},
|
||||
else => {
|
||||
if (isDebug) {
|
||||
Output.printError("modkey error: {s}", .{@errorName(err)});
|
||||
}
|
||||
break :handler null;
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
var file: fs.File = undefined;
|
||||
if (mod_key) |modk| {
|
||||
file = rfs.readFileWithHandle(path, modk.size, file_handle, use_shared_buffer, &c.shared_buffer) catch |err| {
|
||||
if (isDebug) {
|
||||
Output.printError("{s}: readFile error -- {s}", .{ path, @errorName(err) });
|
||||
}
|
||||
return err;
|
||||
};
|
||||
} else {
|
||||
file = rfs.readFileWithHandle(path, null, file_handle, use_shared_buffer, &c.shared_buffer) catch |err| {
|
||||
if (isDebug) {
|
||||
Output.printError("{s}: readFile error -- {s}", .{ path, @errorName(err) });
|
||||
}
|
||||
return err;
|
||||
};
|
||||
}
|
||||
|
||||
return Entry{
|
||||
.contents = file.contents,
|
||||
.mod_key = mod_key,
|
||||
.fd = if (FeatureFlags.store_file_descriptors) file_handle.handle else 0,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
pub const Css = struct {
|
||||
pub const Entry = struct {};
|
||||
pub const Result = struct {
|
||||
ok: bool,
|
||||
value: void,
|
||||
};
|
||||
pub fn parse(cache: *@This(), log: *logger.Log, source: logger.Source) !Result {
|
||||
Global.notimpl();
|
||||
}
|
||||
};
|
||||
|
||||
pub const JavaScript = struct {
|
||||
pub const Result = js_ast.Result;
|
||||
|
||||
pub fn init(allocator: *std.mem.Allocator) JavaScript {
|
||||
return JavaScript{};
|
||||
}
|
||||
// For now, we're not going to cache JavaScript ASTs.
|
||||
// It's probably only relevant when bundling for production.
|
||||
pub fn parse(
|
||||
cache: *@This(),
|
||||
allocator: *std.mem.Allocator,
|
||||
opts: js_parser.Parser.Options,
|
||||
defines: *Define,
|
||||
log: *logger.Log,
|
||||
source: *const logger.Source,
|
||||
) anyerror!?js_ast.Ast {
|
||||
var temp_log = logger.Log.init(allocator);
|
||||
defer temp_log.appendToMaybeRecycled(log, source) catch {};
|
||||
var parser = js_parser.Parser.init(opts, &temp_log, source, defines, allocator) catch |err| {
|
||||
return null;
|
||||
};
|
||||
|
||||
const result = try parser.parse();
|
||||
|
||||
return if (result.ok) result.ast else null;
|
||||
}
|
||||
|
||||
pub fn scan(
|
||||
cache: *@This(),
|
||||
allocator: *std.mem.Allocator,
|
||||
scan_pass_result: *js_parser.ScanPassResult,
|
||||
opts: js_parser.Parser.Options,
|
||||
defines: *Define,
|
||||
log: *logger.Log,
|
||||
source: *const logger.Source,
|
||||
) anyerror!void {
|
||||
var temp_log = logger.Log.init(allocator);
|
||||
defer temp_log.appendToMaybeRecycled(log, source) catch {};
|
||||
|
||||
var parser = js_parser.Parser.init(opts, &temp_log, source, defines, allocator) catch |err| {
|
||||
return;
|
||||
};
|
||||
|
||||
return try parser.scanImports(scan_pass_result);
|
||||
}
|
||||
};
|
||||
|
||||
pub const Json = struct {
|
||||
pub fn init(allocator: *std.mem.Allocator) Json {
|
||||
return Json{};
|
||||
}
|
||||
fn parse(cache: *@This(), log: *logger.Log, source: logger.Source, allocator: *std.mem.Allocator, is_tsconfig: bool, func: anytype) anyerror!?js_ast.Expr {
|
||||
var temp_log = logger.Log.init(allocator);
|
||||
defer {
|
||||
temp_log.appendTo(log) catch {};
|
||||
}
|
||||
return func(&source, &temp_log, allocator) catch handler: {
|
||||
break :handler null;
|
||||
};
|
||||
}
|
||||
pub fn parseJSON(cache: *@This(), log: *logger.Log, source: logger.Source, allocator: *std.mem.Allocator) anyerror!?js_ast.Expr {
|
||||
return try parse(cache, log, source, allocator, false, json_parser.ParseJSON);
|
||||
}
|
||||
|
||||
pub fn parseTSConfig(cache: *@This(), log: *logger.Log, source: logger.Source, allocator: *std.mem.Allocator) anyerror!?js_ast.Expr {
|
||||
return try parse(cache, log, source, allocator, true, json_parser.ParseTSConfig);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -33,7 +33,7 @@ pub const BuildCommand = struct {
|
||||
);
|
||||
},
|
||||
.lazy => {
|
||||
result = try bundler.ServeBundler.bundle(
|
||||
result = try bundler.Bundler.bundle(
|
||||
ctx.allocator,
|
||||
ctx.log,
|
||||
ctx.args,
|
||||
|
||||
@@ -26,6 +26,7 @@ const fs = @import("../fs.zig");
|
||||
const Router = @import("../router.zig");
|
||||
|
||||
var wait_group: sync.WaitGroup = undefined;
|
||||
var estimated_input_lines_of_code_: usize = undefined;
|
||||
const ServerBundleGeneratorThread = struct {
|
||||
inline fn _generate(
|
||||
logs: *logger.Log,
|
||||
@@ -37,7 +38,7 @@ const ServerBundleGeneratorThread = struct {
|
||||
route_conf_: ?Api.LoadedRouteConfig,
|
||||
router: ?Router,
|
||||
) !void {
|
||||
var server_bundler = try bundler.ServeBundler.init(
|
||||
var server_bundler = try bundler.Bundler.init(
|
||||
allocator_,
|
||||
logs,
|
||||
try configureTransformOptionsForBun(allocator_, transform_args),
|
||||
@@ -47,13 +48,18 @@ const ServerBundleGeneratorThread = struct {
|
||||
server_bundler.options.jsx.supports_fast_refresh = false;
|
||||
server_bundler.configureLinker();
|
||||
server_bundler.router = router;
|
||||
try server_bundler.configureDefines();
|
||||
_ = try bundler.ServeBundler.GenerateNodeModuleBundle.generate(
|
||||
server_bundler.configureDefines() catch |err| {
|
||||
Output.prettyErrorln("<r><red>{s}<r> loading --define or .env values for node_modules.server.bun\n", .{@errorName(err)});
|
||||
return err;
|
||||
};
|
||||
var estimated_input_lines_of_code: usize = 0;
|
||||
_ = try bundler.Bundler.GenerateNodeModuleBundle.generate(
|
||||
&server_bundler,
|
||||
allocator_,
|
||||
server_conf,
|
||||
route_conf_,
|
||||
_filepath,
|
||||
&estimated_input_lines_of_code,
|
||||
);
|
||||
std.mem.doNotOptimizeAway(&server_bundler);
|
||||
}
|
||||
@@ -91,8 +97,9 @@ pub const BunCommand = struct {
|
||||
) !void {
|
||||
var allocator = ctx.allocator;
|
||||
var log = ctx.log;
|
||||
estimated_input_lines_of_code_ = 0;
|
||||
|
||||
var this_bundler = try bundler.ServeBundler.init(allocator, log, ctx.args, null, null);
|
||||
var this_bundler = try bundler.Bundler.init(allocator, log, ctx.args, null, null);
|
||||
this_bundler.configureLinker();
|
||||
var filepath: [*:0]const u8 = "node_modules.bun";
|
||||
var server_bundle_filepath: [*:0]const u8 = "node_modules.server.bun";
|
||||
@@ -143,6 +150,12 @@ pub const BunCommand = struct {
|
||||
this_bundler.router,
|
||||
);
|
||||
generated_server = true;
|
||||
|
||||
if (log.msgs.items.len > 0) {
|
||||
try log.printForLogLevel(Output.errorWriter());
|
||||
log.* = logger.Log.init(allocator);
|
||||
Output.flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -154,16 +167,19 @@ pub const BunCommand = struct {
|
||||
}
|
||||
|
||||
{
|
||||
|
||||
// Always generate the client-only bundle
|
||||
// we can revisit this decision if people ask
|
||||
var node_modules_ = try bundler.ServeBundler.GenerateNodeModuleBundle.generate(
|
||||
var node_modules_ = try bundler.Bundler.GenerateNodeModuleBundle.generate(
|
||||
&this_bundler,
|
||||
allocator,
|
||||
loaded_framework,
|
||||
loaded_route_config,
|
||||
filepath,
|
||||
&estimated_input_lines_of_code_,
|
||||
);
|
||||
|
||||
const estimated_input_lines_of_code = estimated_input_lines_of_code_;
|
||||
if (server_bundler_generator_thread) |thread| {
|
||||
wait_group.wait();
|
||||
}
|
||||
@@ -179,6 +195,27 @@ pub const BunCommand = struct {
|
||||
bundle.printSummary();
|
||||
}
|
||||
const indent = comptime " ";
|
||||
|
||||
switch (estimated_input_lines_of_code) {
|
||||
0...99999 => {
|
||||
if (generated_server) {
|
||||
Output.prettyln(indent ++ "<d>{d:<5} LOC parsed x2", .{estimated_input_lines_of_code});
|
||||
} else {
|
||||
Output.prettyln(indent ++ "<d>{d:<5} LOC parsed", .{estimated_input_lines_of_code});
|
||||
}
|
||||
},
|
||||
else => {
|
||||
const formatted_loc: f32 = @floatCast(f32, @intToFloat(f128, estimated_input_lines_of_code) / 1000);
|
||||
if (generated_server) {
|
||||
Output.prettyln(indent ++ "<d>{d:<5.2}k LOC parsed x2", .{formatted_loc});
|
||||
} else {
|
||||
Output.prettyln(indent ++ "<d>{d:<5.2}k LOC parsed", .{
|
||||
formatted_loc,
|
||||
});
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
Output.prettyln(indent ++ "<d>{d:6}ms elapsed", .{@intCast(u32, elapsed)});
|
||||
|
||||
if (generated_server) {
|
||||
@@ -187,6 +224,8 @@ pub const BunCommand = struct {
|
||||
Output.prettyln(indent ++ "<r>Saved to ./{s}", .{filepath});
|
||||
}
|
||||
|
||||
Output.flush();
|
||||
|
||||
try log.printForLogLevel(Output.errorWriter());
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -120,10 +120,9 @@ pub const DefineData = struct {
|
||||
var source = logger.Source{
|
||||
.contents = entry.value_ptr.*,
|
||||
.path = defines_path,
|
||||
.identifier_name = "defines",
|
||||
.key_path = fs.Path.initWithNamespace("defines", "internal"),
|
||||
};
|
||||
var expr = try json_parser.ParseJSON(&source, _log, allocator);
|
||||
var expr = try json_parser.ParseEnvJSON(&source, _log, allocator);
|
||||
var data: js_ast.Expr.Data = undefined;
|
||||
switch (expr.data) {
|
||||
.e_missing => {
|
||||
@@ -269,10 +268,10 @@ pub const Define = struct {
|
||||
// Step 2. Swap in certain literal values because those can be constant folded
|
||||
define.identifiers.putAssumeCapacity("undefined", value_define);
|
||||
define.identifiers.putAssumeCapacity("NaN", DefineData{
|
||||
.value = js_ast.Expr.Data{ .e_number = &nan_val },
|
||||
.value = js_ast.Expr.Data{ .e_number = nan_val },
|
||||
});
|
||||
define.identifiers.putAssumeCapacity("Infinity", DefineData{
|
||||
.value = js_ast.Expr.Data{ .e_number = &inf_val },
|
||||
.value = js_ast.Expr.Data{ .e_number = inf_val },
|
||||
});
|
||||
|
||||
// Step 3. Load user data into hash tables
|
||||
|
||||
@@ -67,3 +67,5 @@ pub const CSSInJSImportBehavior = enum {
|
||||
// having issues compiling WebKit with this enabled
|
||||
pub const remote_inspector = false;
|
||||
pub const auto_import_buffer = false;
|
||||
|
||||
pub const is_macro_enabled = env.isDebug;
|
||||
|
||||
19
src/fs.zig
19
src/fs.zig
@@ -152,7 +152,7 @@ pub const FileSystem = struct {
|
||||
}
|
||||
|
||||
pub const DirEntry = struct {
|
||||
pub const EntryMap = hash_map.StringHashMap(allocators.IndexType);
|
||||
pub const EntryMap = hash_map.StringHashMap(*Entry);
|
||||
pub const EntryStore = allocators.BSSList(Entry, Preallocate.Counts.files);
|
||||
dir: string,
|
||||
fd: StoredFileDescriptorType = 0,
|
||||
@@ -191,7 +191,7 @@ pub const FileSystem = struct {
|
||||
else
|
||||
strings.StringOrTinyString.initLowerCase(entry.name);
|
||||
|
||||
const stored = try EntryStore.instance.appendGet(
|
||||
var stored = try EntryStore.instance.append(
|
||||
Entry{
|
||||
.base_ = name,
|
||||
.base_lowercase_ = name_lowercased,
|
||||
@@ -208,9 +208,9 @@ pub const FileSystem = struct {
|
||||
},
|
||||
);
|
||||
|
||||
const stored_name = stored.value.base();
|
||||
const stored_name = stored.base();
|
||||
|
||||
try dir.data.put(stored.value.base_lowercase(), stored.index);
|
||||
try dir.data.put(stored.base_lowercase(), stored);
|
||||
if (comptime FeatureFlags.verbose_fs) {
|
||||
if (_kind == .dir) {
|
||||
Output.prettyln(" + {s}/", .{stored_name});
|
||||
@@ -250,7 +250,7 @@ pub const FileSystem = struct {
|
||||
|
||||
var iter = d.data.iterator();
|
||||
while (iter.next()) |file_entry| {
|
||||
EntryStore.instance.at(file_entry.value).?.deinit(d.data.allocator);
|
||||
// EntryStore.instance.at(file_entry.value).?.deinit(d.data.allocator);
|
||||
}
|
||||
|
||||
d.data.deinit();
|
||||
@@ -262,8 +262,7 @@ pub const FileSystem = struct {
|
||||
std.debug.assert(scratch_lookup_buffer.len >= _query.len);
|
||||
|
||||
const query = strings.copyLowercase(_query, &scratch_lookup_buffer);
|
||||
const result_index = entry.data.get(query) orelse return null;
|
||||
const result = EntryStore.instance.at(result_index) orelse return null;
|
||||
const result = entry.data.get(query) orelse return null;
|
||||
const basename = result.base();
|
||||
if (!strings.eql(basename, _query)) {
|
||||
return Entry.Lookup{ .entry = result, .diff_case = Entry.Lookup.DifferentCase{
|
||||
@@ -284,8 +283,7 @@ pub const FileSystem = struct {
|
||||
|
||||
const query_hashed = comptime DirEntry.EntryMap.getHash(&query);
|
||||
|
||||
const result_index = entry.data.getWithHash(&query, query_hashed) orelse return null;
|
||||
const result = EntryStore.instance.at(result_index) orelse return null;
|
||||
const result = entry.data.getWithHash(&query, query_hashed) orelse return null;
|
||||
const basename = result.base();
|
||||
|
||||
if (!strings.eqlComptime(basename, comptime query[0..query_str.len])) {
|
||||
@@ -310,8 +308,7 @@ pub const FileSystem = struct {
|
||||
|
||||
const query_hashed = comptime DirEntry.EntryMap.getHash(&query);
|
||||
|
||||
const result_index = entry.data.getWithHash(&query, query_hashed) orelse return false;
|
||||
return result_index.index != allocators.NotFound.index and result_index.index != allocators.Unassigned.index;
|
||||
return entry.data.getWithHash(&query, query_hashed) != null;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user