locter 0.7.0 → 0.8.0

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,3 +1,17 @@
1
1
  import { LocatorInfo } from '../locator';
2
- export declare function loadFile(input: LocatorInfo | string): Promise<unknown>;
3
- export declare function loadFileSync(input: LocatorInfo | string): unknown;
2
+ import { Loader, Rule } from './type';
3
+ export declare class LoaderManager {
4
+ protected loaders: Record<string, Loader>;
5
+ protected rules: Rule[];
6
+ constructor();
7
+ register(rule: Rule): void;
8
+ execute(info: LocatorInfo): Promise<any>;
9
+ executeSync(info: LocatorInfo): any;
10
+ findRule(info: LocatorInfo): Rule | undefined;
11
+ /**
12
+ * Resolve loader by id.
13
+ *
14
+ * @param id
15
+ */
16
+ resolve(id: string | Loader): Loader;
17
+ }
@@ -0,0 +1,2 @@
1
+ import { LoaderManager } from './module';
2
+ export declare function useLoaderManager(): LoaderManager;
@@ -0,0 +1,9 @@
1
+ import { LocatorInfo } from '../locator';
2
+ export type Loader = {
3
+ execute: (info: LocatorInfo) => Promise<any>;
4
+ executeSync: (info: LocatorInfo) => any;
5
+ };
6
+ export type Rule = {
7
+ test: RegExp | string[];
8
+ loader: Loader | string;
9
+ };
@@ -1,3 +1,6 @@
1
1
  import { LocatorInfo, LocatorOptions } from './type';
2
2
  export declare function locateFiles(pattern: string | string[], options?: Partial<LocatorOptions>): Promise<LocatorInfo[]>;
3
+ export declare function locateFile(pattern: string | string[], options: Partial<LocatorOptions> & {
4
+ soft: false;
5
+ }): Promise<LocatorInfo>;
3
6
  export declare function locateFile(pattern: string | string[], options?: Partial<LocatorOptions>): Promise<LocatorInfo | undefined>;
@@ -6,4 +6,5 @@ export type LocatorInfo = {
6
6
  export type LocatorOptions = {
7
7
  path: string | string[];
8
8
  ignore: string | string[];
9
+ soft: boolean;
9
10
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "locter",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "description": "A library to locate a file by criteria and load it",
5
5
  "author": {
6
6
  "name": "Peter Placzek",
@@ -39,53 +39,51 @@
39
39
  "keywords": [
40
40
  "file",
41
41
  "loader",
42
+ "transpiling",
43
+ "compiler",
44
+ "loading",
45
+ "on-demand-transpiling",
42
46
  "locator",
43
47
  "file-extension"
44
48
  ],
45
49
  "license": "MIT",
46
50
  "devDependencies": {
47
- "@babel/core": "^7.20.12",
48
- "@babel/preset-env": "^7.20.2",
49
- "@babel/preset-typescript": "^7.18.6",
50
51
  "@commitlint/cli": "^17.4.2",
51
- "@commitlint/config-angular": "^17.4.0",
52
+ "@commitlint/config-angular": "^17.4.2",
52
53
  "@commitlint/config-conventional": "^17.4.2",
53
54
  "@commitlint/cz-commitlint": "^17.4.2",
54
- "@rollup/plugin-babel": "^6.0.3",
55
55
  "@rollup/plugin-node-resolve": "^15.0.0",
56
- "@rollup/plugin-terser": "^0.3.0",
57
56
  "@semantic-release/changelog": "^6.0.2",
58
57
  "@semantic-release/commit-analyzer": "^9.0.2",
59
58
  "@semantic-release/git": "^10.0.1",
60
59
  "@semantic-release/github": "^8.0.7",
61
60
  "@semantic-release/npm": "^9.0.1",
62
61
  "@semantic-release/release-notes-generator": "^10.0.3",
63
- "@tada5hi/eslint-config-typescript": "^1.1.0",
64
- "@tada5hi/tsconfig": "^0.1.0",
65
- "@types/glob": "^8.0.0",
66
- "@types/is-file-esm": "^1.0.0",
67
- "@types/jest": "^27.5.0",
62
+ "@swc/core": "^1.3.30",
63
+ "@swc/jest": "^0.2.24",
64
+ "@tada5hi/eslint-config-typescript": "^1.1.1",
65
+ "@tada5hi/tsconfig": "^0.4.0",
66
+ "@types/glob": "^8.0.1",
67
+ "@types/jest": "^27.5.2",
68
68
  "@types/node": "^18.11.18",
69
- "@types/yargs": "^17.0.19",
70
- "babel-plugin-dynamic-import-node": "^2.3.3",
69
+ "@types/yargs": "^17.0.20",
71
70
  "coveralls": "^3.1.0",
72
71
  "cross-env": "^7.0.3",
73
- "eslint": "^8.31.0",
72
+ "eslint": "^8.32.0",
74
73
  "husky": "^8.0.3",
75
74
  "jest": "^27.5.1",
76
75
  "magic-string": "^0.27.0",
77
76
  "mlly": "^1.1.0",
78
- "rimraf": "^3.0.2",
79
- "rollup": "^3.10.0",
77
+ "rimraf": "^4.1.2",
78
+ "rollup": "^3.12.0",
80
79
  "semantic-release": "^19.0.5",
81
80
  "sourcemap-codec": "^1.4.8",
82
- "ts-jest": "^27.1.4",
83
- "ts-node": "^10.9.1",
84
81
  "typescript": "^4.9.4"
85
82
  },
86
83
  "dependencies": {
87
- "ebec": "^0.1.0",
88
- "glob": "^8.0.3"
84
+ "ebec": "^0.2.1",
85
+ "glob": "^8.1.0",
86
+ "jiti": "^1.16.2"
89
87
  },
90
88
  "config": {
91
89
  "commitizen": {
@@ -1,3 +0,0 @@
1
- import { LocatorInfo } from '../../locator';
2
- export declare function loadJsonFile(input: LocatorInfo | string): Promise<unknown>;
3
- export declare function loadJsonFileSync(input: LocatorInfo | string): unknown;
@@ -1,4 +0,0 @@
1
- import { LocatorInfo } from '../../../locator';
2
- import { LoaderFilterFn, ScriptFileExportItem, ScriptFileLoadOptions } from './type';
3
- export declare function loadScriptFile(data: LocatorInfo | string, options?: ScriptFileLoadOptions): Promise<unknown>;
4
- export declare function loadScriptFileExport(data: LocatorInfo | string, filterFn?: LoaderFilterFn): Promise<ScriptFileExportItem>;
@@ -1,4 +0,0 @@
1
- import { LoaderFilterFn, ScriptFileExportItem, ScriptFileLoadOptions } from './type';
2
- import { LocatorInfo } from '../../../locator';
3
- export declare function loadScriptFileSync(data: LocatorInfo | string, options?: ScriptFileLoadOptions): unknown;
4
- export declare function loadScriptFileExportSync(data: LocatorInfo | string, filterFn?: LoaderFilterFn): ScriptFileExportItem;