@modern-js/babel-compiler 2.41.0 → 2.42.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
1
  import type { IFinaleCompilerOptions, BabelOptions, ICompilerResult } from './type';
2
- export declare const build: (option: IFinaleCompilerOptions, babelConfig?: BabelOptions) => Promise<ICompilerResult>;
2
+ export declare const build: (option: IFinaleCompilerOptions, babelConfig?: BabelOptions) => Promise<ICompilerResult>;
@@ -3,14 +3,14 @@ import * as Event from 'events';
3
3
  import { FSWatcher } from '@modern-js/utils';
4
4
  import type { IFinaleCompilerOptions, BabelOptions } from './type';
5
5
  export declare const BuildWatchEvent: {
6
- firstCompiler: string;
7
- compiling: string;
8
- watchingCompiler: string;
6
+ firstCompiler: string;
7
+ compiling: string;
8
+ watchingCompiler: string;
9
9
  };
10
10
  export declare class BuildWatchEmitter extends Event.EventEmitter {
11
- private _initFn;
12
- setInitFn(fn: (emitter: BuildWatchEmitter) => Promise<any> | any): void;
13
- watch(): Promise<FSWatcher | null>;
11
+ private _initFn;
12
+ setInitFn(fn: (emitter: BuildWatchEmitter) => Promise<any> | any): void;
13
+ watch(): Promise<FSWatcher | null>;
14
14
  }
15
15
  export declare const runBuildWatch: (option: IFinaleCompilerOptions, babelConfig: import("@babel/core").TransformOptions | undefined, emitter: BuildWatchEmitter) => Promise<FSWatcher>;
16
- export declare const buildWatch: (option: IFinaleCompilerOptions, babelConfig?: BabelOptions) => BuildWatchEmitter;
16
+ export declare const buildWatch: (option: IFinaleCompilerOptions, babelConfig?: BabelOptions) => BuildWatchEmitter;
@@ -1,29 +1,29 @@
1
1
  import * as babel from '@babel/core';
2
2
  import { BabelOptions, IVirtualDist } from './type';
3
3
  export interface ISingleFileCompilerOption {
4
- filepath: string;
5
- rootDir: string;
6
- enableVirtualDist?: boolean;
7
- distDir?: string;
8
- verbose?: boolean;
9
- quiet?: boolean;
10
- babelConfig?: BabelOptions;
11
- distFileExtMap?: Record<string, string>;
4
+ filepath: string;
5
+ rootDir: string;
6
+ enableVirtualDist?: boolean;
7
+ distDir?: string;
8
+ verbose?: boolean;
9
+ quiet?: boolean;
10
+ babelConfig?: BabelOptions;
11
+ distFileExtMap?: Record<string, string>;
12
12
  }
13
13
  export declare const isRes: (r: babel.BabelFileResult | null) => r is babel.BabelFileResult;
14
14
  export declare const getDistFilePath: (option: {
15
- filepath: string;
16
- rootDir: string;
17
- distDir: string;
18
- extMap: Record<string, string>;
15
+ filepath: string;
16
+ rootDir: string;
17
+ distDir: string;
18
+ extMap: Record<string, string>;
19
19
  }) => string;
20
20
  export declare const resolveSourceMap: (option: {
21
- babelRes: babel.BabelFileResult;
22
- sourceFilePath: string;
23
- distFilePath: string;
24
- enableVirtualDist?: boolean;
21
+ babelRes: babel.BabelFileResult;
22
+ sourceFilePath: string;
23
+ distFilePath: string;
24
+ enableVirtualDist?: boolean;
25
25
  }) => {
26
- sourcemap: string;
27
- sourceMapPath: string;
26
+ sourcemap: string;
27
+ sourceMapPath: string;
28
28
  };
29
- export declare const compiler: (option: ISingleFileCompilerOption) => IVirtualDist | null;
29
+ export declare const compiler: (option: ISingleFileCompilerOption) => IVirtualDist | null;
@@ -1,10 +1,10 @@
1
1
  import { ICompilerResult, ICompilerMessageDetail } from './type';
2
2
  export declare class CompilerErrorResult {
3
- _messageDetails: ICompilerMessageDetail[];
4
- constructor(initErrorResult?: ICompilerResult);
5
- init(initErrorResult?: ICompilerResult): void;
6
- update(messageDetails: ICompilerMessageDetail[]): void;
7
- removeByFileName(filename: string): void;
8
- get value(): ICompilerResult;
9
- checkExistError(): boolean;
10
- }
3
+ _messageDetails: ICompilerMessageDetail[];
4
+ constructor(initErrorResult?: ICompilerResult);
5
+ init(initErrorResult?: ICompilerResult): void;
6
+ update(messageDetails: ICompilerMessageDetail[]): void;
7
+ removeByFileName(filename: string): void;
8
+ get value(): ICompilerResult;
9
+ checkExistError(): boolean;
10
+ }
@@ -1,6 +1,6 @@
1
1
  export declare const defaultDistFileExtMap: {
2
- '.js': string;
3
- '.jsx': string;
4
- '.ts': string;
5
- '.tsx': string;
6
- };
2
+ '.js': string;
3
+ '.jsx': string;
4
+ '.ts': string;
5
+ '.tsx': string;
6
+ };
@@ -1,2 +1,2 @@
1
1
  import { ICompilerOptions, ICompilerOptionsWithDefault } from './type';
2
- export declare const mergeDefaultOption: (compilerOptions: ICompilerOptions) => ICompilerOptionsWithDefault;
2
+ export declare const mergeDefaultOption: (compilerOptions: ICompilerOptions) => ICompilerOptionsWithDefault;
@@ -2,13 +2,9 @@ import { GlobOptions } from '@modern-js/utils';
2
2
  import { Extensions, ExtensionsFunc, ICompilerOptions, IFinaleCompilerOptions } from './type';
3
3
  export declare const getGlobPattern: (dir: string, extensions: Extensions) => string;
4
4
  export declare const getFinalExtensions: (extensions: Extensions | ExtensionsFunc | undefined) => string[];
5
- export declare const getFilesFromDir: ({
6
- dir,
7
- finalExt,
8
- ignore
9
- }: {
10
- dir: string;
11
- finalExt?: string[] | undefined;
12
- ignore?: GlobOptions['ignore'];
5
+ export declare const getFilesFromDir: ({ dir, finalExt, ignore, }: {
6
+ dir: string;
7
+ finalExt?: string[] | undefined;
8
+ ignore?: GlobOptions['ignore'];
13
9
  }) => string[];
14
- export declare const getFinalCompilerOption: (option: ICompilerOptions) => IFinaleCompilerOptions;
10
+ export declare const getFinalCompilerOption: (option: ICompilerOptions) => IFinaleCompilerOptions;
@@ -1,10 +1,10 @@
1
1
  import { ICompilerOptions, ICompilerResult, BabelOptions } from './type';
2
2
  import { BuildWatchEmitter } from './buildWatch';
3
3
  export declare function compiler(compilerOptions: ICompilerOptions & {
4
- enableWatch: true;
4
+ enableWatch: true;
5
5
  }, babelOptions?: BabelOptions): Promise<BuildWatchEmitter>;
6
6
  export declare function compiler(compilerOptions: ICompilerOptions & {
7
- enableWatch?: false;
7
+ enableWatch?: false;
8
8
  }, babelOptions?: BabelOptions): Promise<ICompilerResult>;
9
9
  export * from './buildWatch';
10
- export * from './type';
10
+ export * from './type';
@@ -4,65 +4,65 @@ export type BabelOptions = TransformOptions;
4
4
  export type Extensions = string[];
5
5
  export type ExtensionsFunc = (defaultExtensions: Extensions) => Extensions;
6
6
  export interface ICompilerOptions {
7
- rootDir: string;
8
- distDir: string;
9
- sourceDir?: string;
10
- watchDir?: string;
11
- enableWatch?: boolean;
12
- enableVirtualDist?: boolean;
13
- extensions?: Extensions | ExtensionsFunc;
14
- filenames?: string[];
15
- distFileExtMap?: Record<string, string>;
16
- ignore?: GlobOptions['ignore'];
17
- quiet?: boolean;
18
- verbose?: boolean;
19
- clean?: boolean;
7
+ rootDir: string;
8
+ distDir: string;
9
+ sourceDir?: string;
10
+ watchDir?: string;
11
+ enableWatch?: boolean;
12
+ enableVirtualDist?: boolean;
13
+ extensions?: Extensions | ExtensionsFunc;
14
+ filenames?: string[];
15
+ distFileExtMap?: Record<string, string>;
16
+ ignore?: GlobOptions['ignore'];
17
+ quiet?: boolean;
18
+ verbose?: boolean;
19
+ clean?: boolean;
20
20
  }
21
21
  export interface ICompilerOptionsWithDefault {
22
- rootDir: string;
23
- enableVirtualDist?: boolean;
24
- sourceDir?: string;
25
- watchDir?: string;
26
- enableWatch?: boolean;
27
- distDir: string;
28
- extensions: Extensions | ExtensionsFunc;
29
- filenames: string[];
30
- distFileExtMap?: Record<string, string>;
31
- ignore: GlobOptions['ignore'];
32
- quiet?: boolean;
33
- verbose?: boolean;
34
- clean?: boolean;
22
+ rootDir: string;
23
+ enableVirtualDist?: boolean;
24
+ sourceDir?: string;
25
+ watchDir?: string;
26
+ enableWatch?: boolean;
27
+ distDir: string;
28
+ extensions: Extensions | ExtensionsFunc;
29
+ filenames: string[];
30
+ distFileExtMap?: Record<string, string>;
31
+ ignore: GlobOptions['ignore'];
32
+ quiet?: boolean;
33
+ verbose?: boolean;
34
+ clean?: boolean;
35
35
  }
36
36
  export interface IFinaleCompilerOptions {
37
- rootDir: string;
38
- filenames: string[];
39
- ignore?: GlobOptions['ignore'];
40
- enableVirtualDist?: boolean;
41
- distDir: string;
42
- watchDir?: string;
43
- enableWatch?: boolean;
44
- distFileExtMap?: Record<string, string>;
45
- quiet?: boolean;
46
- verbose?: boolean;
47
- clean?: boolean;
37
+ rootDir: string;
38
+ filenames: string[];
39
+ ignore?: GlobOptions['ignore'];
40
+ enableVirtualDist?: boolean;
41
+ distDir: string;
42
+ watchDir?: string;
43
+ enableWatch?: boolean;
44
+ distFileExtMap?: Record<string, string>;
45
+ quiet?: boolean;
46
+ verbose?: boolean;
47
+ clean?: boolean;
48
48
  }
49
49
  export interface BuildOptions {
50
- babelOptions: BabelOptions;
50
+ babelOptions: BabelOptions;
51
51
  }
52
52
  export interface IVirtualDist {
53
- distPath: string;
54
- sourceMapPath: string;
55
- code: string;
56
- sourcemap: string;
53
+ distPath: string;
54
+ sourceMapPath: string;
55
+ code: string;
56
+ sourcemap: string;
57
57
  }
58
58
  export interface ICompilerMessageDetail {
59
- filename: string;
60
- content: string;
59
+ filename: string;
60
+ content: string;
61
61
  }
62
62
  export interface ICompilerResult {
63
- code: number;
64
- message: string;
65
- messageDetails?: ICompilerMessageDetail[];
66
- virtualDists?: IVirtualDist[];
67
- removeFiles?: string[];
68
- }
63
+ code: number;
64
+ message: string;
65
+ messageDetails?: ICompilerMessageDetail[];
66
+ virtualDists?: IVirtualDist[];
67
+ removeFiles?: string[];
68
+ }
@@ -1 +1 @@
1
- export declare function addSourceMappingUrl(code: string, loc: string): string;
1
+ export declare function addSourceMappingUrl(code: string, loc: string): string;
@@ -3,4 +3,4 @@ export declare const sourceDirAndFileNamesValidMessage = "At least one of the so
3
3
  export declare const watchDirValidMessage = "should set watchDir when enableWatch is true";
4
4
  export declare const validateSourceDirAndFileNames: (compilerOptions: ICompilerOptions) => ICompilerResult | null;
5
5
  export declare const validateWatchDir: (compilerOptions: ICompilerOptions) => ICompilerResult | null;
6
- export declare const validate: (compilerOptions: ICompilerOptions) => ICompilerResult | null;
6
+ export declare const validate: (compilerOptions: ICompilerOptions) => ICompilerResult | null;
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "2.41.0",
18
+ "version": "2.42.1",
19
19
  "jsnext:source": "./src/index.ts",
20
20
  "types": "./dist/types/index.d.ts",
21
21
  "main": "./dist/cjs/index.js",
@@ -33,7 +33,7 @@
33
33
  "dependencies": {
34
34
  "@babel/core": "^7.23.2",
35
35
  "@swc/helpers": "0.5.3",
36
- "@modern-js/utils": "2.41.0"
36
+ "@modern-js/utils": "2.42.1"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@babel/plugin-transform-classes": "^7.22.15",
@@ -44,8 +44,8 @@
44
44
  "@types/node": "^14",
45
45
  "typescript": "^5",
46
46
  "jest": "^29",
47
- "@scripts/build": "2.41.0",
48
- "@scripts/jest-config": "2.41.0"
47
+ "@scripts/build": "2.42.1",
48
+ "@scripts/jest-config": "2.42.1"
49
49
  },
50
50
  "sideEffects": false,
51
51
  "publishConfig": {