Skip to content

Commit

Permalink
Fix CJS output and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
surma committed Feb 3, 2023
1 parent d8d0c23 commit 3101675
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 19 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "wasm-feature-detect",
"version": "1.4.0",
"description": "A small library to detect which features of WebAssembly are supported in your current browser.",
"main": "dist/cjs/index.js",
"main": "dist/cjs/index.cjs",
"module": "dist/esm/index.js",
"types": "dist/index.d.ts",
"type": "module",
Expand All @@ -18,7 +18,7 @@
"prepublishOnly": "npm run build",
"fmt": "prettier --write ./{,{src,rollup-plugins}/**/}*.{mjs,js,md}",
"fmt_test": "prettier --check ./{,{src,rollup-plugins}/**/}*.{mjs,js,md}",
"test": "npm run fmt_test && npm run build && node --no-warnings test/index.js"
"test": "npm run fmt_test && npm run build && node --no-warnings test/index.cjs"
},
"repository": "GoogleChromeLabs/wasm-feature-detect",
"keywords": [],
Expand Down
4 changes: 2 additions & 2 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ import sizePrinter from "./rollup-plugins/size-printer.js";
import exportInPlace from "./rollup-plugins/export-in-place.js";

export default ["esm", "cjs", "umd"].map(format => ({
input: "./src/index.js",
input: `./src/index.js`,
output: {
dir: `dist/${format}`,
file: `dist/${format}/index.${format === "cjs" ? "cjs" : "js"}`,
format,
name: "wasmFeatureDetect",
esModule: false,
Expand Down
19 changes: 4 additions & 15 deletions test/index.js → test/index.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ process.on("unhandledRejection", err => {
});

// We try to import the generated module
const features = require(__dirname+'/../dist/cjs');
const features = require(__dirname+'/../dist/cjs/index.cjs');

const isBoolean = function (value) {
return typeof value === 'boolean';
Expand All @@ -35,20 +35,9 @@ const checkFeature = async function (featureName) {
}

async function run() {
await checkFeature("bulkMemory");
await checkFeature("exceptions");
await checkFeature("multiValue");
await checkFeature("mutableGlobals");
await checkFeature("referenceTypes");
await checkFeature("saturatedFloatToInt");
await checkFeature("signExtensions");
await checkFeature("simd");
await checkFeature("tailCall");
await checkFeature("threads");
await checkFeature("bigInt");
await checkFeature("streamingCompilation")
await checkFeature("extendedConst");
await checkFeature("relaxedSimd");
for(const feature of Object.keys(features)) {
await checkFeature(feature);
}
}

run();

0 comments on commit 3101675

Please sign in to comment.