From bb6c14d0193bc091c1c58ba06667ea4a20f13f07 Mon Sep 17 00:00:00 2001 From: Daniel Del Core Date: Thu, 20 Oct 2022 11:40:43 +1100 Subject: [PATCH] updates imports --- .../extract-react-types/src/file-loader.js | 27 ++++++------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/packages/extract-react-types/src/file-loader.js b/packages/extract-react-types/src/file-loader.js index 3a004604..94cb4c94 100644 --- a/packages/extract-react-types/src/file-loader.js +++ b/packages/extract-react-types/src/file-loader.js @@ -17,61 +17,50 @@ function toResolveOptions(fromPath, resolveOpts) { return Object.assign({}, resolveOpts, { basedir: dirname(fromPath) }); } -function resolveFilePathAsync(path, filePath, resolveOpts) { +export function resolveFilePathAsync(path, filePath, resolveOpts) { let fromPath = getPathFileName(path); let opts = toResolveOptions(fromPath, resolveOpts); return resolveAsync(filePath, opts); } -function resolveFilePathSync(path, filePath, resolveOpts) { +export function resolveFilePathSync(path, filePath, resolveOpts) { let fromPath = getPathFileName(path); let opts = toResolveOptions(fromPath, resolveOpts); return resolveSync(filePath, opts); } -function resolveImportFilePathAsync(importDeclaration, resolveOpts) { +export function resolveImportFilePathAsync(importDeclaration, resolveOpts) { let fromPath = getPathFileName(importDeclaration); let toPath = getImportSource(importDeclaration); let opts = toResolveOptions(fromPath, resolveOpts); return resolveAsync(toPath, opts); } -function resolveImportFilePathSync(importDeclaration, resolveOpts) { +export function resolveImportFilePathSync(importDeclaration, resolveOpts) { let fromPath = getPathFileName(importDeclaration); let toPath = getImportSource(importDeclaration); let opts = toResolveOptions(fromPath, resolveOpts); return resolveSync(toPath, opts); } -function loadFileAsync(filePath, parserOpts) { +export function loadFileAsync(filePath, parserOpts) { return readFileAsync(filePath).then(buffer => createFile(buffer.toString(), { filename: filePath, parserOpts }) ); } -function loadFileSync(filePath, parserOpts) { +export function loadFileSync(filePath, parserOpts) { let buffer = readFileSync(filePath); return createFile(buffer.toString(), { filename: filePath, parserOpts }); } -function loadImportAsync(importDeclaration, resolveOpts, parserOpts) { +export function loadImportAsync(importDeclaration, resolveOpts, parserOpts) { return resolveImportFilePathAsync(importDeclaration, resolveOpts).then(resolved => loadFileAsync(resolved, parserOpts) ); } -function loadImportSync(importDeclaration, resolveOpts, parserOpts) { +export function loadImportSync(importDeclaration, resolveOpts, parserOpts) { const resolved = resolveImportFilePathSync(importDeclaration, resolveOpts); return loadFileSync(resolved, parserOpts); } - -module.exports = { - resolveFilePathAsync, - resolveFilePathSync, - resolveImportFilePathAsync, - resolveImportFilePathSync, - loadFileAsync, - loadFileSync, - loadImportAsync, - loadImportSync -};