Skip to content

Commit

Permalink
added: commonjs interop tests
Browse files Browse the repository at this point in the history
  • Loading branch information
GianlucaGuarini committed Aug 26, 2023
1 parent cf0b910 commit 3cc1527
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
3 changes: 2 additions & 1 deletion build/rollup.node.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default {
// bundle only the json files
json(),
nodeResolve({
extensions: ['.js', '.js', '.json'],
extensions: ['.js', '.json'],
// globals.json is the only file that we don't want to import
resolveOnly: ['globals'],
}),
Expand All @@ -20,6 +20,7 @@ export default {
file: './dist/index.cjs',
name: 'compiler',
format: 'cjs',
interop: 'auto',
...defaultConfig.output,
},
{
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
"postest": "npm run cov-html",
"test-types": "tsc -p test",
"test-runtime": "karma start test/karma.conf.cjs",
"test": "c8 mocha test/*.spec.js test/**/*.spec.js && npm run test-types",
"debug": "mocha --inspect --inspect-brk test/*.spec.js test/**/*.spec.js",
"test": "c8 mocha 'test/**/*.spec.{js,cjs}' && npm run test-types",
"debug": "mocha --inspect --inspect-brk 'test/**/*.spec.{js,cjs}'",
"prepublishOnly": "npm run build && npm run lint && npm run test && npm run test-runtime"
},
"repository": {
Expand Down
10 changes: 10 additions & 0 deletions test/commonjs.spec.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const { expect } = require('chai')

describe('commonjs bundle', () => {
it('commonjs imports work properly', () => {
const {compile} = require('../dist/index.cjs')

expect(() => compile('<test></test>')).to.not.throw()
})
})

0 comments on commit 3cc1527

Please sign in to comment.