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

Add package.json exports field #773

Merged
merged 3 commits into from Mar 14, 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
2 changes: 2 additions & 0 deletions .github/workflows/usage.yml
Expand Up @@ -64,9 +64,11 @@ jobs:
export UNPACK_DESTINATION=$(mktemp -d)
mv mustache.tgz $UNPACK_DESTINATION
cp test/module-systems/esm-test.mjs $UNPACK_DESTINATION
cp test/module-systems/esm-test-exports.mjs $UNPACK_DESTINATION
cd $UNPACK_DESTINATION
npm install mustache.tgz
node esm-test.mjs
node esm-test-exports.mjs

browser-usage:
runs-on: ubuntu-latest
Expand Down
7 changes: 7 additions & 0 deletions package.json
Expand Up @@ -24,6 +24,13 @@
"mustache.min.js",
"wrappers/"
],
"exports": {
".": {
"import": "./mustache.mjs",
"require": "./mustache.js"
},
"./*": "./*"
},
"volo": {
"url": "https://raw.github.com/janl/mustache.js/{version}/mustache.js"
},
Expand Down
12 changes: 12 additions & 0 deletions test/module-systems/esm-test-exports.mjs
@@ -0,0 +1,12 @@
import assert from 'assert';
import mustache from 'mustache';

const view = {
title: 'Joe',
calc: () => 2 + 4
};

assert.strictEqual(
mustache.render('{{title}} spends {{calc}}', view),
'Joe spends 6'
);