Skip to content

Commit e466fac

Browse files
committed
Update build to not include transitives of cjs modules
1 parent 9047d25 commit e466fac

File tree

5 files changed

+1220
-1957
lines changed

5 files changed

+1220
-1957
lines changed

.config/rollup.base.config.mjs

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,25 @@ const customResolver = nodeResolve({
5050
preferBuiltins: true
5151
})
5252

53+
function isAncestorsCjs(resolvedId, parentId) {
54+
let currNmIndex = resolvedId.indexOf(SLASH_NODE_MODULES_SLASH)
55+
while (currNmIndex !== -1) {
56+
const nextNmIndex = resolvedId.indexOf(
57+
SLASH_NODE_MODULES_SLASH,
58+
currNmIndex + 1
59+
)
60+
const currPkgName = resolvedId.slice(
61+
currNmIndex + SLASH_NODE_MODULES_SLASH.length,
62+
nextNmIndex === -1 ? resolvedId.length : nextNmIndex
63+
)
64+
if (isEsmId(currPkgName, parentId)) {
65+
return false
66+
}
67+
currNmIndex = nextNmIndex
68+
}
69+
return true
70+
}
71+
5372
export default (extendConfig = {}) => {
5473
const depStats = {
5574
dependencies: { __proto__: null },
@@ -79,22 +98,7 @@ export default (extendConfig = {}) => {
7998
const parentId = parentId_ ? resolveId(parentId_) : undefined
8099
const resolvedId = resolveId(id, parentId)
81100
if (resolvedId.endsWith('.json')) {
82-
let currNmIndex = resolvedId.indexOf(SLASH_NODE_MODULES_SLASH)
83-
while (currNmIndex !== -1) {
84-
const nextNmIndex = resolvedId.indexOf(
85-
SLASH_NODE_MODULES_SLASH,
86-
currNmIndex + 1
87-
)
88-
const currPkgName = resolvedId.slice(
89-
currNmIndex + SLASH_NODE_MODULES_SLASH.length,
90-
nextNmIndex === -1 ? resolvedId.length : nextNmIndex
91-
)
92-
if (isEsmId(currPkgName, parentId)) {
93-
return false
94-
}
95-
currNmIndex = nextNmIndex
96-
}
97-
return true
101+
return isAncestorsCjs(resolvedId, parentId)
98102
}
99103
if (!isPackageName(id)) {
100104
return false
@@ -115,8 +119,13 @@ export default (extendConfig = {}) => {
115119
''
116120
return false
117121
}
118-
const parentNodeModulesIndex = parentId.lastIndexOf('/node_modules/')
122+
const parentNodeModulesIndex = parentId.lastIndexOf(
123+
SLASH_NODE_MODULES_SLASH
124+
)
119125
if (parentNodeModulesIndex !== -1) {
126+
if (isAncestorsCjs(resolvedId, parentId)) {
127+
return true
128+
}
120129
const parentNameStart = parentNodeModulesIndex + 14
121130
const parentNameEnd = getPackageNameEnd(parentId, parentNameStart)
122131
const {

.dep-stats.json

Lines changed: 8 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,19 @@
77
"@npmcli/promise-spawn": "^8.0.2",
88
"@socketregistry/hyrious__bun.lockb": "1.0.4",
99
"@socketsecurity/config": "^2.1.3",
10-
"@socketsecurity/registry": "^1.0.13",
10+
"@socketsecurity/registry": "^1.0.14",
1111
"@socketsecurity/sdk": "^1.3.0",
1212
"blessed": "^0.1.81",
1313
"blessed-contrib": "^4.11.0",
1414
"browserslist": "4.24.2",
1515
"chalk-table": "^1.0.2",
1616
"hpagent": "^1.2.0",
17+
"ignore": "^6.0.2",
1718
"micromatch": "^4.0.8",
1819
"npm-package-arg": "^12.0.0",
1920
"pacote": "^20.0.0",
2021
"pony-cause": "^2.1.11",
22+
"semver": "^7.6.3",
2123
"synp": "^1.9.13",
2224
"tinyglobby": "^0.2.10",
2325
"which": "^5.0.0",
@@ -84,61 +86,29 @@
8486
"@npmcli/promise-spawn": "^8.0.2",
8587
"@socketregistry/hyrious__bun.lockb": "1.0.4",
8688
"@socketsecurity/config": "^2.1.3",
87-
"@socketsecurity/registry": "^1.0.13",
89+
"@socketsecurity/registry": "^1.0.14",
8890
"@socketsecurity/sdk": "^1.3.0",
89-
"ansi-align": "^3.0.1",
9091
"blessed": "^0.1.81",
9192
"blessed-contrib": "^4.11.0",
9293
"browserslist": "4.24.2",
9394
"chalk-table": "^1.0.2",
94-
"cli-boxes": "^4.0.1",
95-
"cli-spinners": "^3.2.0",
96-
"cross-spawn": "^7.0.3",
97-
"dot-prop": "^9.0.0",
98-
"eastasianwidth": "^0.3.0",
99-
"emoji-regex": "^10.4.0",
100-
"graceful-fs": "^4.2.11",
101-
"has-flag": "^5.0.1",
95+
"emoji-regex": "^10.3.0",
10296
"hpagent": "^1.2.0",
10397
"ignore": "^6.0.2",
104-
"ini": "5.0.0",
98+
"ini": "4.1.1",
10599
"micromatch": "^4.0.8",
106100
"npm-package-arg": "^12.0.0",
107-
"onetime": "^7.0.0",
108101
"pacote": "^20.0.0",
109102
"pony-cause": "^2.1.11",
110-
"rc": "1.2.8",
111-
"registry-auth-token": "^5.0.2",
112103
"semver": "^7.6.3",
113-
"signal-exit": "^4.1.0",
114-
"supports-color": "^9.4.0",
115-
"supports-hyperlinks": "^3.1.0",
116104
"synp": "^1.9.13",
117105
"tinyglobby": "^0.2.10",
118106
"which": "^5.0.0",
119-
"write-file-atomic": "^6.0.0",
120107
"yaml": "^2.6.0",
121108
"yargs-parser": "^21.1.1"
122109
},
123110
"transitives": {
124-
"ansi-align": "^3.0.1",
125-
"cli-boxes": "^4.0.1",
126-
"cli-spinners": "^3.2.0",
127-
"cross-spawn": "^7.0.3",
128-
"dot-prop": "^9.0.0",
129-
"eastasianwidth": "^0.3.0",
130-
"emoji-regex": "^10.4.0",
131-
"graceful-fs": "^4.2.11",
132-
"has-flag": "^5.0.1",
133-
"ignore": "^6.0.2",
134-
"ini": "5.0.0",
135-
"onetime": "^7.0.0",
136-
"rc": "1.2.8",
137-
"registry-auth-token": "^5.0.2",
138-
"semver": "^7.6.3",
139-
"signal-exit": "^4.1.0",
140-
"supports-color": "^9.4.0",
141-
"supports-hyperlinks": "^3.1.0",
142-
"write-file-atomic": "^6.0.0"
111+
"emoji-regex": "^10.3.0",
112+
"ini": "4.1.1"
143113
}
144114
}

eslint.config.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ const tsParser = require('@typescript-eslint/parser')
1313
const gitignorePath = path.resolve(__dirname, '.gitignore')
1414
const prettierignorePath = path.resolve(__dirname, '.prettierignore')
1515

16+
const {
17+
engines: { node: nodeRange }
18+
} = require('./package.json')
19+
1620
const sharedPlugins = {
1721
'sort-destructure-keys': sortDestructureKeysPlugin,
1822
unicorn: unicornPlugin
@@ -104,7 +108,13 @@ module.exports = [
104108
'n/no-unpublished-bin': ['error'],
105109
'n/no-unsupported-features/es-builtins': ['error'],
106110
'n/no-unsupported-features/es-syntax': ['error'],
107-
'n/no-unsupported-features/node-builtins': ['error'],
111+
'n/no-unsupported-features/node-builtins': [
112+
'error',
113+
{
114+
ignores: ['test.describe'],
115+
version: nodeRange
116+
}
117+
],
108118
'n/prefer-node-protocol': ['error'],
109119
'no-unused-vars': [
110120
'error',

0 commit comments

Comments
 (0)