Skip to content

Commit

Permalink
Ignore d.ts file in glob imports (redwoodjs#3188)
Browse files Browse the repository at this point in the history
* Replace glob with fast-glob, use same version.

* Skip d.ts file.
  • Loading branch information
peterp authored Aug 3, 2021
1 parent 71ad64d commit c367677
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 18 deletions.
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"core-js": "3.15.2",
"graphql": "15.5.1",
"graphql-tag": "2.12.5",
"glob": "7.1.7",
"fast-glob": "3.2.5",
"@babel/runtime-corejs3": "7.14.7",
"x----x----x": "^0 Bins",
"esbuild": "0.12.15",
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import path from 'path'

import type { PluginObj, types } from '@babel/core'
import glob from 'glob'
import fg from 'fast-glob'

/**
* This babel plugin will search for import statements that include star `**`
Expand Down Expand Up @@ -30,7 +30,6 @@ export default function ({ types: t }: { types: typeof types }): PluginObj {
}

const nodes = []

// import <node.specifiers[0].local.name> from <node.source.value>
// + let importName = {}
const importName = p.node.specifiers[0].local.name
Expand All @@ -44,12 +43,12 @@ export default function ({ types: t }: { types: typeof types }): PluginObj {
)

const importGlob = p.node.source.value

const cwd = path.dirname(state.file.opts.filename)
const dirFiles = glob
const dirFiles = fg
.sync(importGlob, { cwd })
.filter((n) => !n.includes('.test.')) // ignore `*.test.*` files.
.filter((n) => !n.includes('.scenarios.')) // ignore `*.scenarios.*` files.
.filter((n) => !n.includes('.d.ts'))

const staticGlob = importGlob.split('*')[0]
const filePathToVarName = (filePath: string) => {
Expand Down
2 changes: 1 addition & 1 deletion tasks/framework-tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"core-js": "3.15.2",
"cp-cli": "2.0.0",
"cross-env": "7.0.3",
"fast-glob": "3.2.6",
"fast-glob": "3.2.5",
"jest": "27.0.6",
"lerna": "4.0.0",
"msw": "0.32.2",
Expand Down
13 changes: 1 addition & 12 deletions tasks/framework-tools/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4807,18 +4807,7 @@ fast-diff@^1.1.2:
resolved "https://registry.yarnpkg.com/fast-diff/-/fast-diff-1.2.0.tgz#73ee11982d86caaf7959828d519cfe927fac5f03"
integrity sha512-xJuoT5+L99XlZ8twedaRf6Ax2TgQVxvgZOYoPKqZufmJib0tL2tegPBOZb1pVNgIhlqDlA0eO0c3wBvQcmzx4w==

[email protected]:
version "3.2.6"
resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.2.6.tgz#434dd9529845176ea049acc9343e8282765c6e1a"
integrity sha512-GnLuqj/pvQ7pX8/L4J84nijv6sAnlwvSDpMkJi9i7nPmPxGtRPkBSStfvDW5l6nMdX9VWe+pkKWFTgD+vF2QSQ==
dependencies:
"@nodelib/fs.stat" "^2.0.2"
"@nodelib/fs.walk" "^1.2.3"
glob-parent "^5.1.2"
merge2 "^1.3.0"
micromatch "^4.0.4"

fast-glob@^3.1.1:
[email protected], fast-glob@^3.1.1:
version "3.2.5"
resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.2.5.tgz#7939af2a656de79a4f1901903ee8adcaa7cb9661"
integrity sha512-2DtFcgT68wiTTiwZ2hNdJfcHNke9XOfnwmBRWXhmeKM8rF0TGwmC/Qto3S7RoZKp5cilZbxzO5iTNTQsJ+EeDg==
Expand Down

0 comments on commit c367677

Please sign in to comment.