mirror of
https://github.com/tailwindlabs/tailwindcss.git
synced 2025-12-08 21:36:08 +00:00
Improve bundle size by replacing detective-typescript (#10825)
* replace `detective-typescript` with our own implementation
We are not parsing the code but just trying to pluck out the
dependencies used via `import` and `require`.
* drop `detective-typescript`
* return a `Set` instead of an `Array`
* resolve rebuilds, but log errors in case they occur
This won't be the prettiest if it happens, but at least we are not
swallowing errors which should make bugs be easier to discover.
See previous commit for an example... 😅
Co-authored-by: Adam Wathan <4323180+adamwathan@users.noreply.github.com>
Co-authored-by: Jordan Pittman <jordan@cryptica.me>
This commit is contained in:
parent
6a2c58acf8
commit
e046a37dbc
681
package-lock.json
generated
681
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -12,7 +12,6 @@
|
||||
"arg": "^5.0.2",
|
||||
"chokidar": "^3.5.3",
|
||||
"color-name": "^1.1.4",
|
||||
"detective-typescript": "^9.0.0",
|
||||
"didyoumean": "^1.2.2",
|
||||
"dlv": "^1.1.3",
|
||||
"fast-glob": "^3.2.12",
|
||||
@ -454,6 +453,7 @@
|
||||
},
|
||||
"node_modules/@babel/parser": {
|
||||
"version": "7.18.9",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
"parser": "bin/babel-parser.js"
|
||||
@ -2048,74 +2048,6 @@
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@typescript-eslint/types": {
|
||||
"version": "5.55.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.55.0.tgz",
|
||||
"integrity": "sha512-M4iRh4AG1ChrOL6Y+mETEKGeDnT7Sparn6fhZ5LtVJF1909D5O4uqK+C5NPbLmpfZ0XIIxCdwzKiijpZUOvOug==",
|
||||
"engines": {
|
||||
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/typescript-eslint"
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/typescript-estree": {
|
||||
"version": "5.55.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.55.0.tgz",
|
||||
"integrity": "sha512-I7X4A9ovA8gdpWMpr7b1BN9eEbvlEtWhQvpxp/yogt48fy9Lj3iE3ild/1H3jKBBIYj5YYJmS2+9ystVhC7eaQ==",
|
||||
"dependencies": {
|
||||
"@typescript-eslint/types": "5.55.0",
|
||||
"@typescript-eslint/visitor-keys": "5.55.0",
|
||||
"debug": "^4.3.4",
|
||||
"globby": "^11.1.0",
|
||||
"is-glob": "^4.0.3",
|
||||
"semver": "^7.3.7",
|
||||
"tsutils": "^3.21.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/typescript-eslint"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"typescript": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/typescript-estree/node_modules/semver": {
|
||||
"version": "7.3.8",
|
||||
"resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz",
|
||||
"integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==",
|
||||
"dependencies": {
|
||||
"lru-cache": "^6.0.0"
|
||||
},
|
||||
"bin": {
|
||||
"semver": "bin/semver.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/visitor-keys": {
|
||||
"version": "5.55.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.55.0.tgz",
|
||||
"integrity": "sha512-q2dlHHwWgirKh1D3acnuApXG+VNXpEY5/AwRxDVuEQpxWaB0jCDe0jFMVMALJ3ebSfuOVE8/rMS+9ZOYGg1GWw==",
|
||||
"dependencies": {
|
||||
"@typescript-eslint/types": "5.55.0",
|
||||
"eslint-visitor-keys": "^3.3.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/typescript-eslint"
|
||||
}
|
||||
},
|
||||
"node_modules/acorn": {
|
||||
"version": "7.4.1",
|
||||
"dev": true,
|
||||
@ -2265,22 +2197,6 @@
|
||||
"sprintf-js": "~1.0.2"
|
||||
}
|
||||
},
|
||||
"node_modules/array-union": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz",
|
||||
"integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==",
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/ast-module-types": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/ast-module-types/-/ast-module-types-3.0.0.tgz",
|
||||
"integrity": "sha512-CMxMCOCS+4D+DkOQfuZf+vLrSEmY/7xtORwdxs4wtcC1wVgvk2MqFFTwQCFhvWsI4KPU9lcWXPI8DgRiz+xetQ==",
|
||||
"engines": {
|
||||
"node": ">=6.0"
|
||||
}
|
||||
},
|
||||
"node_modules/autoprefixer": {
|
||||
"version": "10.4.13",
|
||||
"dev": true,
|
||||
@ -3375,6 +3291,7 @@
|
||||
"version": "4.3.4",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz",
|
||||
"integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"ms": "2.1.2"
|
||||
},
|
||||
@ -3604,20 +3521,6 @@
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/detective-typescript": {
|
||||
"version": "9.0.0",
|
||||
"resolved": "https://registry.npmjs.org/detective-typescript/-/detective-typescript-9.0.0.tgz",
|
||||
"integrity": "sha512-lR78AugfUSBojwlSRZBeEqQ1l8LI7rbxOl1qTUnGLcjZQDjZmrZCb7R46rK8U8B5WzFvJrxa7fEBA8FoD/n5fA==",
|
||||
"dependencies": {
|
||||
"@typescript-eslint/typescript-estree": "^5.13.0",
|
||||
"ast-module-types": "^3.0.0",
|
||||
"node-source-walk": "^5.0.0",
|
||||
"typescript": "^4.5.5"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^12.20.0 || ^14.14.0 || >=16.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/didyoumean": {
|
||||
"version": "1.2.2",
|
||||
"license": "Apache-2.0"
|
||||
@ -3630,17 +3533,6 @@
|
||||
"node": "^12.13.0 || ^14.15.0 || ^16.10.0 || >=17.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/dir-glob": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz",
|
||||
"integrity": "sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==",
|
||||
"dependencies": {
|
||||
"path-type": "^4.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/dlv": {
|
||||
"version": "1.1.3",
|
||||
"license": "MIT"
|
||||
@ -4007,6 +3899,7 @@
|
||||
"version": "3.3.0",
|
||||
"resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz",
|
||||
"integrity": "sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
|
||||
}
|
||||
@ -4515,25 +4408,6 @@
|
||||
"node": ">=4"
|
||||
}
|
||||
},
|
||||
"node_modules/globby": {
|
||||
"version": "11.1.0",
|
||||
"resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz",
|
||||
"integrity": "sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==",
|
||||
"dependencies": {
|
||||
"array-union": "^2.1.0",
|
||||
"dir-glob": "^3.0.1",
|
||||
"fast-glob": "^3.2.9",
|
||||
"ignore": "^5.2.0",
|
||||
"merge2": "^1.4.1",
|
||||
"slash": "^3.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/got": {
|
||||
"version": "8.3.2",
|
||||
"dev": true,
|
||||
@ -4663,6 +4537,7 @@
|
||||
},
|
||||
"node_modules/ignore": {
|
||||
"version": "5.2.4",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 4"
|
||||
@ -6228,6 +6103,7 @@
|
||||
},
|
||||
"node_modules/lru-cache": {
|
||||
"version": "6.0.0",
|
||||
"dev": true,
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"yallist": "^4.0.0"
|
||||
@ -6359,6 +6235,7 @@
|
||||
},
|
||||
"node_modules/ms": {
|
||||
"version": "2.1.2",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/mz": {
|
||||
@ -6401,17 +6278,6 @@
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/node-source-walk": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/node-source-walk/-/node-source-walk-5.0.0.tgz",
|
||||
"integrity": "sha512-58APXoMXpmmU+oVBJFajhTCoD8d/OGtngnVAWzIo2A8yn0IXwBzvIVIsTzoie/SrA37u+1hnpNz2HMWx/VIqlw==",
|
||||
"dependencies": {
|
||||
"@babel/parser": "^7.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/normalize-path": {
|
||||
"version": "3.0.0",
|
||||
"license": "MIT",
|
||||
@ -6709,14 +6575,6 @@
|
||||
"version": "1.0.7",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/path-type": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz",
|
||||
"integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==",
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/pend": {
|
||||
"version": "1.2.0",
|
||||
"dev": true,
|
||||
@ -7667,6 +7525,7 @@
|
||||
},
|
||||
"node_modules/slash": {
|
||||
"version": "3.0.0",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
@ -8100,25 +7959,6 @@
|
||||
"dev": true,
|
||||
"license": "0BSD"
|
||||
},
|
||||
"node_modules/tsutils": {
|
||||
"version": "3.21.0",
|
||||
"resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.21.0.tgz",
|
||||
"integrity": "sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==",
|
||||
"dependencies": {
|
||||
"tslib": "^1.8.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 6"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"typescript": ">=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta"
|
||||
}
|
||||
},
|
||||
"node_modules/tsutils/node_modules/tslib": {
|
||||
"version": "1.14.1",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",
|
||||
"integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg=="
|
||||
},
|
||||
"node_modules/tunnel-agent": {
|
||||
"version": "0.6.0",
|
||||
"dev": true,
|
||||
@ -8245,18 +8085,6 @@
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/typescript": {
|
||||
"version": "4.9.5",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz",
|
||||
"integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==",
|
||||
"bin": {
|
||||
"tsc": "bin/tsc",
|
||||
"tsserver": "bin/tsserver"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4.2.0"
|
||||
}
|
||||
},
|
||||
"node_modules/unbzip2-stream": {
|
||||
"version": "1.4.3",
|
||||
"dev": true,
|
||||
@ -8415,6 +8243,7 @@
|
||||
},
|
||||
"node_modules/yallist": {
|
||||
"version": "4.0.0",
|
||||
"dev": true,
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/yaml": {
|
||||
@ -8707,7 +8536,8 @@
|
||||
}
|
||||
},
|
||||
"@babel/parser": {
|
||||
"version": "7.18.9"
|
||||
"version": "7.18.9",
|
||||
"dev": true
|
||||
},
|
||||
"@babel/plugin-syntax-async-generators": {
|
||||
"version": "7.8.4",
|
||||
@ -9710,44 +9540,6 @@
|
||||
"version": "20.2.1",
|
||||
"dev": true
|
||||
},
|
||||
"@typescript-eslint/types": {
|
||||
"version": "5.55.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.55.0.tgz",
|
||||
"integrity": "sha512-M4iRh4AG1ChrOL6Y+mETEKGeDnT7Sparn6fhZ5LtVJF1909D5O4uqK+C5NPbLmpfZ0XIIxCdwzKiijpZUOvOug=="
|
||||
},
|
||||
"@typescript-eslint/typescript-estree": {
|
||||
"version": "5.55.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.55.0.tgz",
|
||||
"integrity": "sha512-I7X4A9ovA8gdpWMpr7b1BN9eEbvlEtWhQvpxp/yogt48fy9Lj3iE3ild/1H3jKBBIYj5YYJmS2+9ystVhC7eaQ==",
|
||||
"requires": {
|
||||
"@typescript-eslint/types": "5.55.0",
|
||||
"@typescript-eslint/visitor-keys": "5.55.0",
|
||||
"debug": "^4.3.4",
|
||||
"globby": "^11.1.0",
|
||||
"is-glob": "^4.0.3",
|
||||
"semver": "^7.3.7",
|
||||
"tsutils": "^3.21.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"semver": {
|
||||
"version": "7.3.8",
|
||||
"resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz",
|
||||
"integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==",
|
||||
"requires": {
|
||||
"lru-cache": "^6.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"@typescript-eslint/visitor-keys": {
|
||||
"version": "5.55.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.55.0.tgz",
|
||||
"integrity": "sha512-q2dlHHwWgirKh1D3acnuApXG+VNXpEY5/AwRxDVuEQpxWaB0jCDe0jFMVMALJ3ebSfuOVE8/rMS+9ZOYGg1GWw==",
|
||||
"requires": {
|
||||
"@typescript-eslint/types": "5.55.0",
|
||||
"eslint-visitor-keys": "^3.3.0"
|
||||
}
|
||||
},
|
||||
"acorn": {
|
||||
"version": "7.4.1",
|
||||
"dev": true,
|
||||
@ -9833,16 +9625,6 @@
|
||||
"sprintf-js": "~1.0.2"
|
||||
}
|
||||
},
|
||||
"array-union": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz",
|
||||
"integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw=="
|
||||
},
|
||||
"ast-module-types": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/ast-module-types/-/ast-module-types-3.0.0.tgz",
|
||||
"integrity": "sha512-CMxMCOCS+4D+DkOQfuZf+vLrSEmY/7xtORwdxs4wtcC1wVgvk2MqFFTwQCFhvWsI4KPU9lcWXPI8DgRiz+xetQ=="
|
||||
},
|
||||
"autoprefixer": {
|
||||
"version": "10.4.13",
|
||||
"dev": true,
|
||||
@ -10528,6 +10310,7 @@
|
||||
"version": "4.3.4",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz",
|
||||
"integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"ms": "2.1.2"
|
||||
}
|
||||
@ -10677,17 +10460,6 @@
|
||||
"version": "3.1.0",
|
||||
"dev": true
|
||||
},
|
||||
"detective-typescript": {
|
||||
"version": "9.0.0",
|
||||
"resolved": "https://registry.npmjs.org/detective-typescript/-/detective-typescript-9.0.0.tgz",
|
||||
"integrity": "sha512-lR78AugfUSBojwlSRZBeEqQ1l8LI7rbxOl1qTUnGLcjZQDjZmrZCb7R46rK8U8B5WzFvJrxa7fEBA8FoD/n5fA==",
|
||||
"requires": {
|
||||
"@typescript-eslint/typescript-estree": "^5.13.0",
|
||||
"ast-module-types": "^3.0.0",
|
||||
"node-source-walk": "^5.0.0",
|
||||
"typescript": "^4.5.5"
|
||||
}
|
||||
},
|
||||
"didyoumean": {
|
||||
"version": "1.2.2"
|
||||
},
|
||||
@ -10695,14 +10467,6 @@
|
||||
"version": "28.1.1",
|
||||
"dev": true
|
||||
},
|
||||
"dir-glob": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz",
|
||||
"integrity": "sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==",
|
||||
"requires": {
|
||||
"path-type": "^4.0.0"
|
||||
}
|
||||
},
|
||||
"dlv": {
|
||||
"version": "1.1.3"
|
||||
},
|
||||
@ -10983,7 +10747,8 @@
|
||||
"eslint-visitor-keys": {
|
||||
"version": "3.3.0",
|
||||
"resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz",
|
||||
"integrity": "sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA=="
|
||||
"integrity": "sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA==",
|
||||
"dev": true
|
||||
},
|
||||
"espree": {
|
||||
"version": "9.4.1",
|
||||
@ -11257,19 +11022,6 @@
|
||||
"version": "11.12.0",
|
||||
"dev": true
|
||||
},
|
||||
"globby": {
|
||||
"version": "11.1.0",
|
||||
"resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz",
|
||||
"integrity": "sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==",
|
||||
"requires": {
|
||||
"array-union": "^2.1.0",
|
||||
"dir-glob": "^3.0.1",
|
||||
"fast-glob": "^3.2.9",
|
||||
"ignore": "^5.2.0",
|
||||
"merge2": "^1.4.1",
|
||||
"slash": "^3.0.0"
|
||||
}
|
||||
},
|
||||
"got": {
|
||||
"version": "8.3.2",
|
||||
"dev": true,
|
||||
@ -11349,7 +11101,8 @@
|
||||
"dev": true
|
||||
},
|
||||
"ignore": {
|
||||
"version": "5.2.4"
|
||||
"version": "5.2.4",
|
||||
"dev": true
|
||||
},
|
||||
"import-fresh": {
|
||||
"version": "3.3.0",
|
||||
@ -12412,6 +12165,7 @@
|
||||
},
|
||||
"lru-cache": {
|
||||
"version": "6.0.0",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"yallist": "^4.0.0"
|
||||
}
|
||||
@ -12490,7 +12244,8 @@
|
||||
}
|
||||
},
|
||||
"ms": {
|
||||
"version": "2.1.2"
|
||||
"version": "2.1.2",
|
||||
"dev": true
|
||||
},
|
||||
"mz": {
|
||||
"version": "2.7.0",
|
||||
@ -12521,14 +12276,6 @@
|
||||
"version": "2.0.6",
|
||||
"dev": true
|
||||
},
|
||||
"node-source-walk": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/node-source-walk/-/node-source-walk-5.0.0.tgz",
|
||||
"integrity": "sha512-58APXoMXpmmU+oVBJFajhTCoD8d/OGtngnVAWzIo2A8yn0IXwBzvIVIsTzoie/SrA37u+1hnpNz2HMWx/VIqlw==",
|
||||
"requires": {
|
||||
"@babel/parser": "^7.0.0"
|
||||
}
|
||||
},
|
||||
"normalize-path": {
|
||||
"version": "3.0.0"
|
||||
},
|
||||
@ -12703,11 +12450,6 @@
|
||||
"path-parse": {
|
||||
"version": "1.0.7"
|
||||
},
|
||||
"path-type": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz",
|
||||
"integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw=="
|
||||
},
|
||||
"pend": {
|
||||
"version": "1.2.0",
|
||||
"dev": true
|
||||
@ -13216,7 +12958,8 @@
|
||||
"dev": true
|
||||
},
|
||||
"slash": {
|
||||
"version": "3.0.0"
|
||||
"version": "3.0.0",
|
||||
"dev": true
|
||||
},
|
||||
"sort-keys": {
|
||||
"version": "1.1.2",
|
||||
@ -13500,21 +13243,6 @@
|
||||
"version": "2.4.1",
|
||||
"dev": true
|
||||
},
|
||||
"tsutils": {
|
||||
"version": "3.21.0",
|
||||
"resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.21.0.tgz",
|
||||
"integrity": "sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==",
|
||||
"requires": {
|
||||
"tslib": "^1.8.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"tslib": {
|
||||
"version": "1.14.1",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",
|
||||
"integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg=="
|
||||
}
|
||||
}
|
||||
},
|
||||
"tunnel-agent": {
|
||||
"version": "0.6.0",
|
||||
"dev": true,
|
||||
@ -13586,11 +13314,6 @@
|
||||
"version": "0.20.2",
|
||||
"dev": true
|
||||
},
|
||||
"typescript": {
|
||||
"version": "4.9.5",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz",
|
||||
"integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g=="
|
||||
},
|
||||
"unbzip2-stream": {
|
||||
"version": "1.4.3",
|
||||
"dev": true,
|
||||
@ -13684,7 +13407,8 @@
|
||||
"dev": true
|
||||
},
|
||||
"yallist": {
|
||||
"version": "4.0.0"
|
||||
"version": "4.0.0",
|
||||
"dev": true
|
||||
},
|
||||
"yaml": {
|
||||
"version": "1.10.2"
|
||||
|
||||
@ -75,7 +75,6 @@
|
||||
"browserslist": "^4.21.5",
|
||||
"chokidar": "^3.5.3",
|
||||
"color-name": "^1.1.4",
|
||||
"detective-typescript": "^9.0.0",
|
||||
"didyoumean": "^1.2.2",
|
||||
"dlv": "^1.1.3",
|
||||
"fast-glob": "^3.2.12",
|
||||
|
||||
@ -73,7 +73,6 @@
|
||||
"arg": "^5.0.2",
|
||||
"chokidar": "^3.5.3",
|
||||
"color-name": "^1.1.4",
|
||||
"detective-typescript": "^9.0.0",
|
||||
"didyoumean": "^1.2.2",
|
||||
"dlv": "^1.1.3",
|
||||
"fast-glob": "^3.2.12",
|
||||
@ -96,17 +95,26 @@
|
||||
"resolve": "^1.22.1",
|
||||
"sucrase": "^3.29.0"
|
||||
},
|
||||
"browserslist": ["> 1%", "not edge <= 18", "not ie 11", "not op_mini all"],
|
||||
"browserslist": [
|
||||
"> 1%",
|
||||
"not edge <= 18",
|
||||
"not ie 11",
|
||||
"not op_mini all"
|
||||
],
|
||||
"jest": {
|
||||
"testTimeout": 30000,
|
||||
"setupFilesAfterEnv": ["<rootDir>/jest/customMatchers.js"],
|
||||
"setupFilesAfterEnv": [
|
||||
"<rootDir>/jest/customMatchers.js"
|
||||
],
|
||||
"testPathIgnorePatterns": [
|
||||
"/node_modules/",
|
||||
"/integrations/",
|
||||
"/standalone-cli/",
|
||||
"\\.test\\.skip\\.js$"
|
||||
],
|
||||
"transformIgnorePatterns": ["node_modules/(?!lightningcss)"],
|
||||
"transformIgnorePatterns": [
|
||||
"node_modules/(?!lightningcss)"
|
||||
],
|
||||
"transform": {
|
||||
"\\.js$": "@swc/jest",
|
||||
"\\.ts$": "@swc/jest"
|
||||
|
||||
@ -89,7 +89,9 @@ export function createWatcher(args, { state, rebuild }) {
|
||||
// Resolve the promise even when the rebuild fails
|
||||
return rebuild(changes).then(
|
||||
() => {},
|
||||
() => {}
|
||||
(e) => {
|
||||
console.error(e.toString())
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@ -1,40 +1,79 @@
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import resolve from 'resolve'
|
||||
import detective from 'detective-typescript'
|
||||
|
||||
function createModule(file) {
|
||||
let source = fs.readFileSync(file, 'utf-8')
|
||||
return { file, requires: detective(source, { mixedImports: true }) }
|
||||
let jsExtensions = ['.js', '.cjs', '.mjs']
|
||||
|
||||
// Given the current file `a.ts`, we want to make sure that when importing `b` that we resolve
|
||||
// `b.ts` before `b.js`
|
||||
//
|
||||
// E.g.:
|
||||
//
|
||||
// a.ts
|
||||
// b // .ts
|
||||
// c // .ts
|
||||
// a.js
|
||||
// b // .js or .ts
|
||||
|
||||
let jsResolutionOrder = ['', '.js', '.cjs', '.mjs', '.ts', '.cts', '.mts', '.jsx', '.tsx']
|
||||
let tsResolutionOrder = ['', '.ts', '.cts', '.mts', '.tsx', '.js', '.cjs', '.mjs', '.jsx']
|
||||
|
||||
function resolveWithExtension(file, extensions) {
|
||||
// Try to find `./a.ts`, `./a.ts`, ... from `./a`
|
||||
for (let ext of extensions) {
|
||||
let full = `${file}${ext}`
|
||||
if (fs.existsSync(full) && fs.statSync(full).isFile()) {
|
||||
return full
|
||||
}
|
||||
}
|
||||
|
||||
// Try to find `./a/index.js` from `./a`
|
||||
for (let ext of extensions) {
|
||||
let full = `${file}/index${ext}`
|
||||
if (fs.existsSync(full)) {
|
||||
return full
|
||||
}
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
function* _getModuleDependencies(entryFile) {
|
||||
yield entryFile
|
||||
function* _getModuleDependencies(filename, base, seen) {
|
||||
let ext = path.extname(filename)
|
||||
|
||||
let mod = createModule(entryFile)
|
||||
// Try to find the file
|
||||
let absoluteFile = resolveWithExtension(
|
||||
path.resolve(base, filename),
|
||||
jsExtensions.includes(ext) ? jsResolutionOrder : tsResolutionOrder
|
||||
)
|
||||
if (absoluteFile === null) return // File doesn't exist
|
||||
|
||||
let ext = path.extname(entryFile)
|
||||
let isTypeScript = ext === '.ts' || ext === '.cts' || ext === '.mts'
|
||||
let extensions = [...(isTypeScript ? ['.ts', '.cts', '.mts'] : []), '.js', '.cjs', '.mjs']
|
||||
// Prevent infinite loops when there are circular dependencies
|
||||
if (seen.has(absoluteFile)) return // Already seen
|
||||
seen.add(absoluteFile)
|
||||
|
||||
// Iterate over the modules, even when new
|
||||
// ones are being added
|
||||
for (let dep of mod.requires) {
|
||||
// Only track local modules, not node_modules
|
||||
if (!dep.startsWith('./') && !dep.startsWith('../')) {
|
||||
continue
|
||||
}
|
||||
// Mark the file as a dependency
|
||||
yield absoluteFile
|
||||
|
||||
try {
|
||||
let basedir = path.dirname(mod.file)
|
||||
let depPath = resolve.sync(dep, { basedir, extensions })
|
||||
yield* _getModuleDependencies(depPath)
|
||||
} catch (_err) {
|
||||
// eslint-disable-next-line no-empty
|
||||
}
|
||||
// Resolve new base for new imports/requires
|
||||
base = path.dirname(absoluteFile)
|
||||
|
||||
let contents = fs.readFileSync(absoluteFile, 'utf-8')
|
||||
|
||||
// Find imports/requires
|
||||
for (let match of [
|
||||
...contents.matchAll(/import[\s\S]*?['"](.{3,}?)['"]/gi),
|
||||
...contents.matchAll(/import[\s\S]*from[\s\S]*?['"](.{3,}?)['"]/gi),
|
||||
...contents.matchAll(/require\(['"`](.{3,})['"`]\)/gi),
|
||||
]) {
|
||||
// Bail out if it's not a relative file
|
||||
if (!match[1].startsWith('.')) continue
|
||||
|
||||
yield* _getModuleDependencies(match[1], base, seen)
|
||||
}
|
||||
}
|
||||
|
||||
export default function getModuleDependencies(entryFile) {
|
||||
return new Set(_getModuleDependencies(entryFile))
|
||||
export default function getModuleDependencies(absoluteFilePath) {
|
||||
return new Set(
|
||||
_getModuleDependencies(absoluteFilePath, path.dirname(absoluteFilePath), new Set())
|
||||
)
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user