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

Enable esm named exports #2382

Merged
merged 2 commits into from Nov 3, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 8 additions & 2 deletions build.js → build.cjs
Expand Up @@ -18,6 +18,11 @@ try {
// We seem to have it already
}

/**
* @param entryPoint
* @param config
* @param done
*/
function makeBundle(entryPoint, config, done) {
browserify(entryPoint, config).bundle(function (err, buffer) {
if (err) {
Expand All @@ -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
}
);

Expand All @@ -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);
}
);

Expand Down
3 changes: 3 additions & 0 deletions lib/package.json
@@ -0,0 +1,3 @@
{
"type": "commonjs"
}
9 changes: 7 additions & 2 deletions package.json
Expand Up @@ -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",
Expand Down Expand Up @@ -115,6 +115,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": {
Expand Down
3 changes: 3 additions & 0 deletions test/package.json
@@ -0,0 +1,3 @@
{
"type": "commonjs"
fatso83 marked this conversation as resolved.
Show resolved Hide resolved
}