Skip to content

Commit 7328e66

Browse files
committed
chore: add test step that makes sure no external/builtin dependencies
1 parent 09c69e2 commit 7328e66

File tree

4 files changed

+28
-1
lines changed

4 files changed

+28
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,4 @@
3333
!/SECURITY.md
3434
!/tap-snapshots/
3535
!/test/
36+
!/rollup.config.js

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
"description": "The semantic version parser used by npm.",
55
"main": "index.js",
66
"scripts": {
7-
"test": "tap",
7+
"test": "tap && npm run check-self-contained",
88
"snap": "tap",
9+
"check-self-contained": "rollup -c --silent > /dev/null",
910
"lint": "eslint \"**/*.js\"",
1011
"postlint": "template-oss-check",
1112
"lintfix": "npm run lint -- --fix",
@@ -15,6 +16,8 @@
1516
"devDependencies": {
1617
"@npmcli/eslint-config": "^4.0.0",
1718
"@npmcli/template-oss": "4.14.1",
19+
"@rollup/plugin-commonjs": "^24.1.0",
20+
"rollup": "^3.21.5",
1821
"tap": "^16.0.0"
1922
},
2023
"license": "ISC",

rollup.config.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
const fs = require('fs')
2+
const commonjs = require('@rollup/plugin-commonjs')
3+
4+
const pkgJson = JSON.parse(fs.readFileSync('./package.json', 'utf-8'))
5+
6+
module.exports = {
7+
input: pkgJson.main,
8+
plugins: [
9+
commonjs({
10+
strictRequires: true,
11+
ignoreTryCatch: true,
12+
}),
13+
],
14+
external: Object.keys(pkgJson.dependencies),
15+
onwarn: (e) => {
16+
if (e.code === 'CIRCULAR_DEPENDENCY') {
17+
return
18+
}
19+
20+
throw new Error(e)
21+
},
22+
}

test/map.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const ignore = [
1111
'tap-snapshots',
1212
'test',
1313
'fixtures',
14+
'rollup.config.js',
1415
]
1516

1617
const { statSync, readdirSync } = require('fs')

0 commit comments

Comments
 (0)