Skip to content
Permalink
Browse files
Enable esm named exports (#2382)
* Enable esm named exports

* Lint cjs files
  • Loading branch information
perrin4869 committed Nov 3, 2021
1 parent b0cf544 commit eba42cc38dbaf5417178a12cec11e35014e335ea
Showing with 21 additions and 4 deletions.
  1. +8 −2 build.js → build.cjs
  2. +3 −0 lib/package.json
  3. +7 −2 package.json
  4. +3 −0 test/package.json
@@ -18,6 +18,11 @@ try {
// We seem to have it already
}

/**
* @param entryPoint

Check warning on line 22 in build.cjs

GitHub Actions / lint

build.cjs#L22

Missing JSDoc @param "entryPoint" type
* @param config

Check warning on line 23 in build.cjs

GitHub Actions / lint

build.cjs#L23

Missing JSDoc @param "config" type    
* @param done

Check warning on line 24 in build.cjs

GitHub Actions / lint

build.cjs#L24

Missing JSDoc @param "done" type      
*/
function makeBundle(entryPoint, config, done) {
browserify(entryPoint, config).bundle(function (err, buffer) {
if (err) {
@@ -39,7 +44,8 @@ makeBundle(
},
function (bundle) {
var script = preamble + bundle;
fs.writeFileSync("pkg/sinon.js", script);
fs.writeFileSync("pkg/sinon.cjs", script);
fs.writeFileSync("pkg/sinon.js", script); // WebWorker can only load js files
}
);

@@ -53,7 +59,7 @@ makeBundle(
},
function (bundle) {
var script = preamble + bundle;
fs.writeFileSync("pkg/sinon-no-sourcemaps.js", script);
fs.writeFileSync("pkg/sinon-no-sourcemaps.cjs", script);
}
);

@@ -0,0 +1,3 @@
{
"type": "commonjs"
}
@@ -43,10 +43,10 @@
"test-runnable-examples": "docs/release-source/release/examples/run-test.sh",
"test": "npm run test-node && npm run test-headless && npm run test-webworker && npm run test-esm",
"check-dependencies": "dependency-check package.json --no-dev --ignore-module esm",
"build": "node ./build.js",
"build": "node ./build.cjs",
"build-docs": "cd docs; bundle exec jekyll build",
"serve-docs": "cd docs; bundle exec jekyll serve --incremental --verbose",
"lint": "eslint '**/*.{js,mjs}'",
"lint": "eslint '**/*.{js,cjs,mjs}'",
"pretest-webworker": "npm run build",
"prebuild": "rimraf pkg && npm run check-dependencies",
"postbuild": "npm run test-esm-bundle",
@@ -117,6 +117,11 @@
"browser": "./lib/sinon.js",
"main": "./lib/sinon.js",
"module": "./pkg/sinon-esm.js",
"exports": {
"require": "./pkg/sinon.cjs",
"import": "./pkg/sinon-esm.js"
},
"type": "module",
"cdn": "./pkg/sinon.js",
"jsdelivr": "./pkg/sinon.js",
"esm": {
@@ -0,0 +1,3 @@
{
"type": "commonjs"
}

0 comments on commit eba42cc

Please sign in to comment.