Skip to content

Commit

Permalink
updates imports
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Del Core committed Oct 20, 2022
1 parent 75f67b6 commit bb6c14d
Showing 1 changed file with 8 additions and 19 deletions.
27 changes: 8 additions & 19 deletions packages/extract-react-types/src/file-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
};

0 comments on commit bb6c14d

Please sign in to comment.