Temporarily restore glob-base to fix importFn

This commit is contained in:
Michael Shilman 2021-09-10 13:26:22 +08:00
parent 18ed032164
commit b76e744af4
3 changed files with 52 additions and 4 deletions

View File

@ -63,6 +63,7 @@
"@babel/register": "^7.12.1",
"@storybook/node-logger": "6.4.0-alpha.34",
"@storybook/semver": "^7.3.2",
"@types/glob-base": "^0.3.0",
"@types/micromatch": "^4.0.1",
"@types/node": "^14.0.10",
"@types/pretty-hrtime": "^1.0.0",
@ -77,6 +78,7 @@
"fork-ts-checker-webpack-plugin": "^6.0.4",
"fs-extra": "^9.0.1",
"glob": "^7.1.6",
"glob-base": "^0.3.0",
"handlebars": "^4.7.7",
"interpret": "^2.2.0",
"json5": "^2.1.3",

View File

@ -1,19 +1,21 @@
import globBase from 'glob-base';
import { makeRe } from 'micromatch';
import dedent from 'ts-dedent';
import type { NormalizedStoriesEntry } from '../types';
import { toRequireContext } from './to-require-context';
export function toImportFnPart(entry: NormalizedStoriesEntry) {
const { path: base, match } = toRequireContext(entry.glob);
const { base } = globBase(entry.glob);
const regex = makeRe(entry.glob, { fastpaths: false, noglobstar: false, bash: false });
const webpackIncludeRegex = new RegExp(match.substring(1));
const webpackIncludeRegex = new RegExp(regex.source.substring(1));
// NOTE: `base` looks like './src' but `path`, (and what micromatch expects)
// is something that starts with `src/`. So to strip off base from path, we
// need to drop `base.length - 1` chars.
return dedent`
async (path) => {
if (!/${match}/.exec(path)) {
if (!${regex}.exec(path)) {
return;
}
const remainder = path.substring(${base.length - 1});

View File

@ -7991,6 +7991,7 @@ __metadata:
"@storybook/node-logger": 6.4.0-alpha.34
"@storybook/react-docgen-typescript-plugin": 1.0.2-canary.253f8c1.0
"@storybook/semver": ^7.3.2
"@types/glob-base": ^0.3.0
"@types/interpret": ^1.1.1
"@types/micromatch": ^4.0.1
"@types/mock-fs": ^4.13.0
@ -8007,6 +8008,7 @@ __metadata:
fork-ts-checker-webpack-plugin: ^6.0.4
fs-extra: ^9.0.1
glob: ^7.1.6
glob-base: ^0.3.0
handlebars: ^4.7.7
interpret: ^2.2.0
json5: ^2.1.3
@ -9922,6 +9924,13 @@ __metadata:
languageName: node
linkType: hard
"@types/glob-base@npm:^0.3.0":
version: 0.3.0
resolution: "@types/glob-base@npm:0.3.0"
checksum: 2c0cb3b7bb7c8661b9421194c0fd90a36e1c786a4124375749df9dc1dd8ade536c8eb2ac93b217db24ed3a427755def9a54bc86c2b6bf64a81fb82e7e6f44cc7
languageName: node
linkType: hard
"@types/glob@npm:*, @types/glob@npm:^7.1.1, @types/glob@npm:^7.1.3":
version: 7.1.3
resolution: "@types/glob@npm:7.1.3"
@ -24220,6 +24229,25 @@ fsevents@^1.2.7:
languageName: node
linkType: hard
"glob-base@npm:^0.3.0":
version: 0.3.0
resolution: "glob-base@npm:0.3.0"
dependencies:
glob-parent: ^2.0.0
is-glob: ^2.0.0
checksum: 4ce785c1dac2ff1e4660c010fa43ed2f1b38993dfd004023a3e7080b20bc61f29fbfe5d265b7e64cc84096ecf44e8ca876c7c1aad8f1f995d4c0f33034f3ae8c
languageName: node
linkType: hard
"glob-parent@npm:^2.0.0":
version: 2.0.0
resolution: "glob-parent@npm:2.0.0"
dependencies:
is-glob: ^2.0.0
checksum: b9d59dc532d47aaaa4841046ff631b325a707f738445300b83b7a1ee603dd060c041a378e8a195c887d479bb703685cee4725c8f54b8dacef65355375f57d32a
languageName: node
linkType: hard
"glob-parent@npm:^3.1.0":
version: 3.1.0
resolution: "glob-parent@npm:3.1.0"
@ -26693,6 +26721,13 @@ fsevents@^1.2.7:
languageName: node
linkType: hard
"is-extglob@npm:^1.0.0":
version: 1.0.0
resolution: "is-extglob@npm:1.0.0"
checksum: 1ce5366d19958f36069a45ca996c1e51ab607f42a01eb0505f0ccffe8f9c91f5bcba6e971605efd8b4d4dfd0111afa3c8df3e1746db5b85b9a8f933f5e7286b7
languageName: node
linkType: hard
"is-extglob@npm:^2.1.0, is-extglob@npm:^2.1.1":
version: 2.1.1
resolution: "is-extglob@npm:2.1.1"
@ -26751,6 +26786,15 @@ fsevents@^1.2.7:
languageName: node
linkType: hard
"is-glob@npm:^2.0.0":
version: 2.0.1
resolution: "is-glob@npm:2.0.1"
dependencies:
is-extglob: ^1.0.0
checksum: ef156806af0924983325c9218a8b8a838fa50e1a104ed2a11fe94829a5b27c1b05a4c8cf98d96cb3a7fea539c21f14ae2081e1a248f3d5a9eea62f2d4e9f8b0c
languageName: node
linkType: hard
"is-glob@npm:^3.0.0, is-glob@npm:^3.1.0":
version: 3.1.0
resolution: "is-glob@npm:3.1.0"