refactor: split node entry
This commit is contained in:
parent
93078f2dd6
commit
eaff2ef5da
|
|
@ -12,6 +12,11 @@
|
|||
"import": "./dist/index.js",
|
||||
"require": "./dist/index.cjs"
|
||||
},
|
||||
"./node": {
|
||||
"types": "./dist/node.d.ts",
|
||||
"import": "./dist/node.js",
|
||||
"require": "./dist/node.cjs"
|
||||
},
|
||||
"./esbuild": {
|
||||
"types": "./dist/plugins/esbuild.d.ts",
|
||||
"import": "./dist/plugins/esbuild.js",
|
||||
|
|
|
|||
|
|
@ -0,0 +1,25 @@
|
|||
/**
|
||||
* Yarn Spinner Loader - Core API
|
||||
*
|
||||
* Pure functions and types for working with Yarn Spinner.
|
||||
* This module does NOT depend on Node.js modules.
|
||||
*/
|
||||
|
||||
// Re-export yarn-spinner parser
|
||||
export { parseYarn } from './yarn-spinner/parse/parser';
|
||||
export { compile } from './yarn-spinner/compile/compiler';
|
||||
export { YarnRunner } from './yarn-spinner/runtime/runner';
|
||||
|
||||
// Re-export types
|
||||
export type {
|
||||
LoadOptions,
|
||||
LoadResult,
|
||||
LoadedYarnFile,
|
||||
YarnProject,
|
||||
SchemaValidationError,
|
||||
RunnerOptions,
|
||||
TextResult,
|
||||
OptionsResult,
|
||||
CommandResult,
|
||||
RuntimeResult,
|
||||
} from './types';
|
||||
43
src/index.ts
43
src/index.ts
|
|
@ -1,31 +1,26 @@
|
|||
/**
|
||||
* Yarn Spinner Loader - Main Entry Point
|
||||
*
|
||||
* Load and compile Yarn Spinner project files (.yarnproject)
|
||||
* and their associated .yarn dialogue files.
|
||||
*
|
||||
* Pure API for working with Yarn Spinner documents.
|
||||
* This module does NOT depend on Node.js modules.
|
||||
* For filesystem operations, use the 'yarn-spinner-loader/node' entry point.
|
||||
*/
|
||||
|
||||
export {
|
||||
loadYarnProject,
|
||||
loadYarnProjectSync,
|
||||
type LoadOptions,
|
||||
type LoadResult,
|
||||
type LoadedYarnFile,
|
||||
LoadError,
|
||||
ValidationError as LoaderValidationError,
|
||||
} from './loader/index';
|
||||
|
||||
export {
|
||||
validateYarnProject,
|
||||
isYarnProject,
|
||||
type SchemaValidationError,
|
||||
} from './loader/validator';
|
||||
|
||||
export type { YarnProject } from './loader/types';
|
||||
|
||||
// Re-export yarn-spinner parser
|
||||
// Re-export yarn-spinner parser and runtime
|
||||
export { parseYarn } from './yarn-spinner/parse/parser';
|
||||
export { compile } from './yarn-spinner/compile/compiler';
|
||||
export { YarnRunner } from './yarn-spinner/runtime/runner';
|
||||
export type { RunnerOptions } from './yarn-spinner/runtime/runner';
|
||||
export type { TextResult, OptionsResult, CommandResult, RuntimeResult } from './yarn-spinner/runtime/results';
|
||||
|
||||
// Re-export types
|
||||
export type {
|
||||
LoadOptions,
|
||||
LoadResult,
|
||||
LoadedYarnFile,
|
||||
YarnProject,
|
||||
SchemaValidationError,
|
||||
RunnerOptions,
|
||||
TextResult,
|
||||
OptionsResult,
|
||||
CommandResult,
|
||||
RuntimeResult,
|
||||
} from './types';
|
||||
|
|
|
|||
|
|
@ -0,0 +1,24 @@
|
|||
/**
|
||||
* Yarn Spinner Loader - Node.js API
|
||||
*
|
||||
* Functions that depend on Node.js modules (fs, path, fast-glob).
|
||||
* Use this entry point when you need to load .yarnproject files from the filesystem.
|
||||
*/
|
||||
|
||||
export {
|
||||
loadYarnProject,
|
||||
loadYarnProjectSync,
|
||||
type LoadOptions,
|
||||
type LoadResult,
|
||||
type LoadedYarnFile,
|
||||
LoadError,
|
||||
ValidationError as LoaderValidationError,
|
||||
} from './loader/index';
|
||||
|
||||
export {
|
||||
validateYarnProject,
|
||||
isYarnProject,
|
||||
type SchemaValidationError,
|
||||
} from './loader/validator';
|
||||
|
||||
export type { YarnProject } from './loader/types';
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
/**
|
||||
* Yarn Spinner Loader - Type Definitions
|
||||
*
|
||||
* Pure type definitions that don't depend on Node.js modules.
|
||||
*/
|
||||
|
||||
import type { YarnProject } from './loader/types';
|
||||
import type { SchemaValidationError } from './loader/validator';
|
||||
import type { YarnDocument } from './yarn-spinner/model/ast';
|
||||
import type { RunnerOptions } from './yarn-spinner/runtime/runner';
|
||||
import type {
|
||||
TextResult,
|
||||
OptionsResult,
|
||||
CommandResult,
|
||||
RuntimeResult,
|
||||
} from './yarn-spinner/runtime/results';
|
||||
|
||||
export type {
|
||||
YarnProject,
|
||||
SchemaValidationError,
|
||||
YarnDocument,
|
||||
RunnerOptions,
|
||||
TextResult,
|
||||
OptionsResult,
|
||||
CommandResult,
|
||||
RuntimeResult,
|
||||
};
|
||||
|
||||
/**
|
||||
* Options for loading a Yarn project
|
||||
*/
|
||||
export interface LoadOptions {
|
||||
/** Base directory for resolving glob patterns (default: directory of .yarnproject file) */
|
||||
baseDir?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loaded Yarn document with metadata
|
||||
*/
|
||||
export interface LoadedYarnFile {
|
||||
/** File path relative to base directory */
|
||||
relativePath: string;
|
||||
/** Absolute file path */
|
||||
absolutePath: string;
|
||||
/** Parsed Yarn document */
|
||||
document: YarnDocument;
|
||||
}
|
||||
|
||||
/**
|
||||
* Result of loading a Yarn project
|
||||
*/
|
||||
export interface LoadResult {
|
||||
/** Parsed .yarnproject configuration */
|
||||
project: YarnProject;
|
||||
/** Directory containing the .yarnproject file */
|
||||
baseDir: string;
|
||||
/** All loaded and parsed .yarn files */
|
||||
yarnFiles: LoadedYarnFile[];
|
||||
}
|
||||
|
|
@ -9,6 +9,13 @@ export default defineConfig([
|
|||
clean: true,
|
||||
outDir: 'dist',
|
||||
},
|
||||
{
|
||||
entry: ['src/node.ts'],
|
||||
format: ['esm', 'cjs'],
|
||||
dts: true,
|
||||
sourcemap: true,
|
||||
outDir: 'dist',
|
||||
},
|
||||
{
|
||||
entry: ['src/plugins/esbuild.ts'],
|
||||
format: ['esm', 'cjs'],
|
||||
|
|
|
|||
Loading…
Reference in New Issue