Skip to content

Commit

Permalink
Remove dependency on glob (#435)
Browse files Browse the repository at this point in the history
* Remove dependency on glob

* Changelog
  • Loading branch information
tomdracz authored and ahangarha committed Mar 28, 2024
1 parent d0f505a commit d4cb0f6
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ Changes since the last non-beta release.
- Emit warnings instead of errors when compilation is success but stderr is not empty. [PR 416](https://github.com/shakacode/shakapacker/pull/416) by [n-rodriguez](https://github.com/n-rodriguez).
- Allow `webpack-dev-server` v5. [PR 418](https://github.com/shakacode/shakapacker/pull/418) by [G-Rath](https://github.com/g-rath)

### Removed
- Removes dependency on `glob` library. [PR 435](https://github.com/shakacode/shakapacker/pull/435) by [tomdracz](https://github.com/tomdracz).

## [v7.2.2] - January 19, 2024

### Added
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
"testRegex": "(/__tests__/.*|(\\.|/))\\.jsx?$"
},
"dependencies": {
"glob": "^7.2.0",
"js-yaml": "^4.1.0",
"path-complete-extname": "^1.0.0"
},
Expand Down
23 changes: 20 additions & 3 deletions package/environments/base.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,34 @@
/* eslint global-require: 0 */
/* eslint import/no-dynamic-require: 0 */

const { existsSync, readdirSync } = require('fs')
const { basename, dirname, join, relative, resolve } = require('path')
const extname = require('path-complete-extname')
const { sync: globSync } = require('glob')
const WebpackAssetsManifest = require('webpack-assets-manifest')
const webpack = require('webpack')
const rules = require('../rules')
const config = require('../config')
const { isProduction } = require('../env')
const { moduleExists } = require('../utils/helpers')

const getFilesInDirectory = (dir, includeNested) => {
if (!existsSync(dir)) {
return []
}

return readdirSync(dir, { withFileTypes: true }).flatMap((dirent) => {
const filePath = join(dir, dirent.name)

if (dirent.isDirectory() && includeNested) {
return getFilesInDirectory(filePath, includeNested)
}
if (dirent.isFile()) {
return filePath
}
return []
})
}

const getEntryObject = () => {
const entries = {}
const rootPath = join(config.source_path, config.source_entry_path)
Expand All @@ -20,9 +38,8 @@ const getEntryObject = () => {
"'true'. Doing this would result in packs for every one of your source files"
)
}
const nesting = config.nested_entries ? '**/' : ''

globSync(`${rootPath}/${nesting}*.*`).forEach((path) => {
getFilesInDirectory(rootPath, config.nested_entries).forEach((path) => {
const namespace = relative(join(rootPath), dirname(path))
const name = join(namespace, basename(path, extname(path)))
let assetPaths = resolve(path)
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2263,7 +2263,7 @@ glob-to-regexp@^0.4.1:
resolved "https://registry.yarnpkg.com/glob-to-regexp/-/glob-to-regexp-0.4.1.tgz#c75297087c851b9a578bd217dd59a92f59fe546e"
integrity sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw==

glob@^7.1.3, glob@^7.1.4, glob@^7.2.0:
glob@^7.1.3, glob@^7.1.4:
version "7.2.0"
resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.0.tgz#d15535af7732e02e948f4c41628bd910293f6023"
integrity sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==
Expand Down

0 comments on commit d4cb0f6

Please sign in to comment.