Skip to content

Commit

Permalink
Add cjs build
Browse files Browse the repository at this point in the history
  • Loading branch information
puzrin committed Dec 1, 2023
1 parent efedccd commit 9381d6e
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules/
coverage/
build/
*.log
1 change: 0 additions & 1 deletion index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ import Cf from './categories/Cf/regex.mjs';
import P from './categories/P/regex.mjs';
import Z from './categories/Z/regex.mjs';

export default { Any, Cc, Cf, P, Z };
export { Any, Cc, Cf, P, Z };
23 changes: 19 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,34 @@
"description": "Micro subset of unicode data files for markdown-it projects.",
"repository": "markdown-it/uc.micro",
"license": "MIT",
"exports": "./index.mjs",
"main": "build/index.cjs.js",
"module": "index.mjs",
"exports": {
".": {
"require": "./build/index.cjs.js",
"import": "./index.mjs"
},
"./*": {
"require": "./*",
"import": "./*"
}
},
"files": [
"index.mjs",
"categories/",
"properties/",
"index.mjs"
"build/"
],
"scripts": {
"test": "mocha",
"update": "node update.mjs && npm test"
"test": "npm run build && mocha",
"build": "rollup -c",
"update": "node update.mjs && npm test",
"prepublishOnly": "npm run build"
},
"devDependencies": {
"@unicode/unicode-15.1.0": "^1.5.2",
"mocha": "^10.2.0",
"rollup": "^4.6.1",
"shelljs": "^0.8.5"
}
}
9 changes: 9 additions & 0 deletions rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export default [
{
input: 'index.mjs',
output: {
file: 'build/index.cjs.js',
format: 'cjs'
}
}
]
15 changes: 15 additions & 0 deletions test/cjs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
'use strict'
/* eslint-env mocha */

const ucm = require('../')
const assert = require('assert')

describe('CJS', () => {
it('require', () => {
assert.ok(ucm.Any)
assert.ok(ucm.Cc)
assert.ok(ucm.Cf)
assert.ok(ucm.P)
assert.ok(ucm.Z)
})
})
2 changes: 1 addition & 1 deletion test.mjs → test/test.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import assert from 'node:assert'
import ucm from './index.mjs'
import * as ucm from '../index.mjs'

describe('Unicode classes', () => {
it('Any', () => {
Expand Down

0 comments on commit 9381d6e

Please sign in to comment.