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

fix: broken CJS #12

Merged
merged 3 commits into from
May 2, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,10 @@ jobs:
node-version: ${{ matrix.node-version }}
- run: npm install --no-package-lock
- run: npm test
- name: Check importing in ESM & CJS works as expected
run: |
npm run build
cd test/test-app
npm install
node index.mjs
node index.cjs
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Lockfiles (not useful in a library)
/package-lock.json
/yarn.lock
/pnpm-lock.yaml
package-lock.json
yarn.lock
pnpm-lock.yaml

# Logs
logs
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{
"name": "@accountable/jsvat",
"version": "1.3.2",
"version": "1.3.3",
"description": "Check the validity of the format of a VAT number",
"exports": {
".": {
"import": {
"types": "./lib/esm/types/index.d.ts",
"default": "./lib/esm/index.js"
"default": "./lib/esm/index.mjs"
},
"require": {
"types": "./lib/cjs/types/index.d.ts",
"default": "./lib/cjs/index.js"
"default": "./lib/cjs/index.cjs"
}
}
},
Expand Down
2 changes: 2 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const rollupConfig = [
dir: "lib/esm",
preserveModules: true,
preserveModulesRoot: "src",
entryFileNames: "[name].mjs",
format: "esm",
},
},
Expand All @@ -36,6 +37,7 @@ const rollupConfig = [
dir: "lib/cjs",
preserveModules: true,
preserveModulesRoot: "src",
entryFileNames: "[name].cjs",
format: "cjs",
},
},
Expand Down
6 changes: 6 additions & 0 deletions test/test-app/index.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const { checkVAT, belgium, austria } = require("@accountable/jsvat");
const assert = require("assert");

assert.equal(checkVAT("BE0411905847", [belgium]).isValid, true);
assert.equal(checkVAT("BE0411905847", [belgium, austria]).isValid, true);
assert.equal(checkVAT("BE0411905847", [austria]).isValid, false);
6 changes: 6 additions & 0 deletions test/test-app/index.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { checkVAT, belgium, austria } from "@accountable/jsvat";
import assert from "assert";

assert.equal(checkVAT("BE0411905847", [belgium]).isValid, true);
assert.equal(checkVAT("BE0411905847", [belgium, austria]).isValid, true);
assert.equal(checkVAT("BE0411905847", [austria]).isValid, false);
5 changes: 5 additions & 0 deletions test/test-app/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"dependencies": {
"@accountable/jsvat": "../.."
}
}
Loading