Skip to content

Commit

Permalink
fix: "types" in package.json exports (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
Menci committed Dec 10, 2023
1 parent 3e2f8ae commit bbb9c0c
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 15 deletions.
12 changes: 6 additions & 6 deletions e2e/e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@ const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
type VitePackages =
| {
vite: typeof import("./vite2/node_modules/vite");
vitePluginLegacy: typeof import("./vite2/node_modules/@vitejs/plugin-legacy")["default"];
vitePluginTopLevelAwait: typeof import("./vite2/node_modules/vite-plugin-top-level-await")["default"];
vitePluginLegacy: (typeof import("./vite2/node_modules/@vitejs/plugin-legacy"))["default"];
vitePluginTopLevelAwait: (typeof import("./vite2/node_modules/vite-plugin-top-level-await"))["default"];
}
| {
vite: typeof import("./vite3/node_modules/vite");
vitePluginLegacy: typeof import("./vite3/node_modules/@vitejs/plugin-legacy")["default"];
vitePluginTopLevelAwait: typeof import("./vite3/node_modules/vite-plugin-top-level-await")["default"];
vitePluginLegacy: (typeof import("./vite3/node_modules/@vitejs/plugin-legacy"))["default"];
vitePluginTopLevelAwait: (typeof import("./vite3/node_modules/vite-plugin-top-level-await"))["default"];
}
| {
vite: typeof import("./vite4/node_modules/vite");
vitePluginLegacy: typeof import("./vite4/node_modules/@vitejs/plugin-legacy")["default"];
vitePluginTopLevelAwait: typeof import("./vite4/node_modules/vite-plugin-top-level-await")["default"];
vitePluginLegacy: (typeof import("./vite4/node_modules/@vitejs/plugin-legacy"))["default"];
vitePluginTopLevelAwait: (typeof import("./vite4/node_modules/vite-plugin-top-level-await"))["default"];
};

async function buildAndStartProdServer(
Expand Down
3 changes: 2 additions & 1 deletion exports/require.cjs
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
module.exports = require("../dist/index");
module.exports = require("../dist/index").default;
module.exports.default = require("../dist/index").default;
3 changes: 3 additions & 0 deletions exports/require.d.cts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import type _default from "../dist/index.d.ts";
declare const _export: typeof _default & { default: typeof _default };
export = _export;
2 changes: 0 additions & 2 deletions exports/types.d.ts

This file was deleted.

17 changes: 11 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@
"name": "vite-plugin-wasm",
"version": "3.2.2",
"description": "Add WebAssembly ESM integration (aka. Webpack's `asyncWebAssembly`) to Vite and support `wasm-pack` generated modules.",
"types": "./dist/index.d.ts",
"main": "./dist/index.js",
"types": "./exports/require.d.cts",
"main": "./exports/require.cjs",
"exports": {
"types": "./exports/types.d.ts",
"import": "./exports/import.mjs",
"require": "./exports/require.cjs"
"import": {
"types": "./dist/index.d.ts",
"default": "./exports/import.mjs"
},
"require": {
"types": "./exports/require.d.cts",
"default": "./exports/require.cjs"
}
},
"repository": "https://github.com/Menci/vite-plugin-wasm",
"author": "Menci <[email protected]>",
Expand All @@ -24,7 +29,7 @@
"scripts": {
"build": "tsc",
"test": "cross-env NODE_NO_WARNINGS=1 NODE_OPTIONS=--experimental-vm-modules jest --verbose --coverage --forceExit",
"format": "prettier --write '**/*.{mjs,cjs,js,ts}'",
"format": "prettier --write '**/*.{mjs,cjs,js,mts,cts,ts}'",
"pretest": "yarn --cwd e2e && playwright install firefox"
},
"devDependencies": {
Expand Down

0 comments on commit bbb9c0c

Please sign in to comment.