Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test for storing empty assets with LMDB #7995

Merged
merged 4 commits into from
Apr 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 89 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"devDependencies": {
"@babel/core": "^7.12.0",
"@khanacademy/flow-to-ts": "^0.5.2",
"@napi-rs/cli": "1.0.4",
"@napi-rs/cli": "^2.6.2",
"@parcel/babel-register": "2.5.0",
"@types/node": "^15.12.4",
"cross-env": "^7.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/cache/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"@parcel/fs": "2.5.0",
"@parcel/logger": "2.5.0",
"@parcel/utils": "2.5.0",
"lmdb": "2.3.5"
"lmdb": "2.3.7"
},
"peerDependencies": {
"@parcel/core": "^2.5.0"
Expand Down
20 changes: 20 additions & 0 deletions packages/core/integration-tests/test/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
distDir,
getParcelOptions,
assertNoFilePathInCache,
findAsset,
} from '@parcel/test-utils';
import {md} from '@parcel/diagnostic';
import fs from 'fs';
Expand Down Expand Up @@ -5908,4 +5909,23 @@ describe('cache', function () {

assert.equal(await run(b.bundleGraph), 6);
});

it('supports multiple empty JS assets', async function () {
// Try to store multiple empty assets using LMDB
let build = await runBundle(
path.join(__dirname, 'integration/multiple-empty-js-assets/index.js'),
{
inputFS,
outputFS: inputFS,
},
);

let a = nullthrows(findAsset(build.bundleGraph, 'a.js'));
let b = nullthrows(findAsset(build.bundleGraph, 'a.js'));
assert.strictEqual((await a.getBuffer()).length, 0);
assert.strictEqual((await b.getBuffer()).length, 0);

let res = await run(build.bundleGraph);
assert.deepEqual(res, {default: 'foo'});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import "./a.js";
import "./b.js";

export default "foo";
4 changes: 2 additions & 2 deletions packages/optimizers/image/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ version = "0.1.0"
crate-type = ["cdylib"]

[dependencies]
napi = "1"
napi-derive = "1"
napi = {version = "2.3.3", default-features = false, features = ["napi4", "compat-mode"]}
napi-derive = "2"
oxipng = "5.0.0"
mozjpeg-sys = "1.0.0"
libc = "0.2"
Expand Down
2 changes: 1 addition & 1 deletion packages/optimizers/image/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"detect-libc": "^1.0.3"
},
"devDependencies": {
"@napi-rs/cli": "1.0.4",
"@napi-rs/cli": "^2.6.2",
"tiny-benchy": "^1.0.2"
}
}
4 changes: 2 additions & 2 deletions packages/transformers/js/napi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ edition = "2018"
crate-type = ["cdylib"]

[dependencies]
napi = { version = "1", features = ["serde-json"] }
napi-derive = "1"
napi = {version = "2.3.3", default-features = false, features = ["napi4", "compat-mode", "serde-json"]}
napi-derive = "2"
parcel-js-swc-core = { path = "../core" }

[target.'cfg(target_os = "macos")'.dependencies]
Expand Down
2 changes: 1 addition & 1 deletion packages/transformers/js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"semver": "^5.7.1"
},
"devDependencies": {
"@napi-rs/cli": "1.0.4"
"@napi-rs/cli": "^2.6.2"
},
"peerDependencies": {
"@parcel/core": "^2.5.0"
Expand Down
4 changes: 2 additions & 2 deletions packages/utils/fs-search/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ version = "0.1.0"
crate-type = ["cdylib"]

[dependencies]
napi = "1"
napi-derive = "1"
napi = "2.3.3"
napi-derive = "2"

[build-dependencies]
napi-build = "1"
2 changes: 1 addition & 1 deletion packages/utils/fs-search/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@
"detect-libc": "^1.0.3"
},
"devDependencies": {
"@napi-rs/cli": "1.0.4"
"@napi-rs/cli": "^2.6.2"
}
}
4 changes: 2 additions & 2 deletions packages/utils/hash/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ version = "0.1.0"
crate-type = ["cdylib"]

[dependencies]
napi = "1"
napi-derive = "1"
napi = "2.3.3"
napi-derive = "2"
xxhash-rust = { version = "0.8.2", features = ["xxh3"] }

[build-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/hash/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"xxhash-wasm": "^0.4.2"
},
"devDependencies": {
"@napi-rs/cli": "1.0.4",
"@napi-rs/cli": "^2.6.2",
"tiny-benchy": "^1.0.2"
}
}
6 changes: 3 additions & 3 deletions packages/utils/hash/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ fn init(mut exports: JsObject, env: Env) -> Result<()> {
exports.create_named_method("hashString", hash_string)?;
exports.create_named_method("hashBuffer", hash_buffer)?;

let write_string_method = Property::new(&env, "writeString")?.with_method(write_string);
let write_buffer_method = Property::new(&env, "writeBuffer")?.with_method(write_buffer);
let finish_method = Property::new(&env, "finish")?.with_method(finish);
let write_string_method = Property::new("writeString")?.with_method(write_string);
let write_buffer_method = Property::new("writeBuffer")?.with_method(write_buffer);
let finish_method = Property::new("finish")?.with_method(finish);
let hash_class = env.define_class(
"Hash",
constructor,
Expand Down
Loading