@storybook/docs-mdx
Advanced tools
Comparing version 0.0.1-canary.1.1f3265d.0 to 0.0.1-canary.1.4bea5cc.0
import * as t from '@babel/types'; | ||
import toBabel from 'estree-to-babel'; | ||
import traverse from '@babel/traverse'; | ||
import * as babelTraverse from '@babel/traverse'; | ||
import { compileSync } from '@mdx-js/mdx'; | ||
@@ -79,6 +79,42 @@ import { toEstree } from 'hast-util-to-estree'; | ||
}; | ||
/** | ||
* This is a hack to get around inconsistencies between | ||
* Babel's own weird interop code AND the typescript types (definitelyTyped) | ||
* and the fact that we're using `type: "module"` in this package | ||
* which has some weird behaviors | ||
*/ | ||
const getTraverse = input => { | ||
switch (true) { | ||
case typeof input === 'function': | ||
{ | ||
return input; | ||
} | ||
case typeof input.traverse === 'function': | ||
{ | ||
return input.traverse; | ||
} | ||
case typeof input.default === 'function': | ||
{ | ||
return input.default; | ||
} | ||
case typeof input.default.default === 'function': | ||
{ | ||
return input.default.default; | ||
} | ||
default: | ||
{ | ||
throw new Error(`Unable to get traverse function from ${input}`); | ||
} | ||
} | ||
}; | ||
export const extractImports = root => { | ||
const varToImport = {}; | ||
traverse(root, { | ||
getTraverse(babelTraverse)(root, { | ||
ImportDeclaration: { | ||
@@ -85,0 +121,0 @@ enter({ |
{ | ||
"name": "@storybook/docs-mdx", | ||
"version": "0.0.1-canary.1.1f3265d.0", | ||
"version": "0.0.1-canary.1.4bea5cc.0", | ||
"description": "Storybook Docs MDX analyzer", | ||
@@ -5,0 +5,0 @@ "repository": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12664
279