fix(npm): conditional exports with wildcards (#15652)

This commit is contained in:
Bartek Iwańczuk 2022-08-29 19:15:20 +02:00 committed by GitHub
parent ea838d27a2
commit 2851a98072
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 59 additions and 2 deletions

View file

@ -68,6 +68,13 @@ itest!(compare_globals {
http_server: true,
});
itest!(conditional_exports {
args: "run --allow-read --unstable npm/conditional_exports/main.js",
output: "npm/conditional_exports/main.out",
envs: env_vars(),
http_server: true,
});
itest!(dynamic_import {
args: "run --allow-read --allow-env --unstable npm/dynamic_import/main.ts",
output: "npm/dynamic_import/main.out",

View file

@ -0,0 +1,9 @@
import mod from "npm:@denotest/conditional-exports";
import client from "npm:@denotest/conditional-exports/client";
import clientFoo from "npm:@denotest/conditional-exports/client/foo";
import clientBar from "npm:@denotest/conditional-exports/client/bar";
console.log(mod);
console.log(client);
console.log(clientFoo);
console.log(clientBar);

View file

@ -0,0 +1,6 @@
Download http://localhost:4545/npm/registry/@denotest/conditional-exports
Download http://localhost:4545/npm/registry/@denotest/conditional-exports/1.0.0.tgz
{ hello: "from esm" }
{ hello: "from esm client" }
{ hello: "from esm client foo" }
{ hello: "from esm client bar" }

View file

@ -0,0 +1,3 @@
module.exports = {
hello: "from cjs"
};

View file

@ -0,0 +1,3 @@
export default {
hello: "from esm client bar",
}

View file

@ -0,0 +1,3 @@
export default {
hello: "from esm client foo",
}

View file

@ -0,0 +1,3 @@
export default {
hello: "from esm client",
}

View file

@ -0,0 +1,3 @@
export default {
hello: "from esm",
}

View file

@ -0,0 +1,20 @@
{
"name": "@denotest/conditional-exports",
"version": "1.0.0",
"type": "module",
"exports": {
".": {
"types": "./types/src/index.d.ts",
"require": "./cjs/index.cjs",
"import": "./esm/index.js"
},
"./client": {
"types": "./types/src/client/index.d.ts",
"import": "./esm/client/index.js"
},
"./client/*": {
"types": "./types/src/client/*.d.ts",
"import": "./esm/client/*.js"
}
}
}