@modern-js/utils 1.7.3 → 1.7.4

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # @modern-js/utils
2
2
 
3
+ ## 1.7.4
4
+
5
+ ### Patch Changes
6
+
7
+ - b8cfc42cd: feat: prebundle tsconfig-paths and nanoid
8
+ - 804a5bb8a: fix(utils): isPnpmWorkspaces not work
9
+
3
10
  ## 1.7.3
4
11
 
5
12
  ### Patch Changes
@@ -0,0 +1,91 @@
1
+ /**
2
+ * Generate secure URL-friendly unique ID.
3
+ *
4
+ * By default, the ID will have 21 symbols to have a collision probability
5
+ * similar to UUID v4.
6
+ *
7
+ * ```js
8
+ * import { nanoid } from './nanoid'
9
+ * model.id = nanoid() //=> "Uakgb_J5m9g-0JDMbcJqL"
10
+ * ```
11
+ *
12
+ * @param size Size of the ID. The default size is 21.
13
+ * @returns A random string.
14
+ */
15
+ export function nanoid(size?: number): string
16
+
17
+ /**
18
+ * Generate secure unique ID with custom alphabet.
19
+ *
20
+ * Alphabet must contain 256 symbols or less. Otherwise, the generator
21
+ * will not be secure.
22
+ *
23
+ * @param alphabet Alphabet used to generate the ID.
24
+ * @param defaultSize Size of the ID. The default size is 21.
25
+ * @returns A random string generator.
26
+ *
27
+ * ```js
28
+ * const { customAlphabet } = require('nanoid')
29
+ * const nanoid = customAlphabet('0123456789абвгдеё', 5)
30
+ * nanoid() //=> "8ё56а"
31
+ * ```
32
+ */
33
+ export function customAlphabet(
34
+ alphabet: string,
35
+ defaultSize?: number
36
+ ): (size?: number) => string
37
+
38
+ /**
39
+ * Generate unique ID with custom random generator and alphabet.
40
+ *
41
+ * Alphabet must contain 256 symbols or less. Otherwise, the generator
42
+ * will not be secure.
43
+ *
44
+ * ```js
45
+ * import { customRandom } from './nanoid/format'
46
+ *
47
+ * const nanoid = customRandom('abcdef', 5, size => {
48
+ * const random = []
49
+ * for (let i = 0; i < size; i++) {
50
+ * random.push(randomByte())
51
+ * }
52
+ * return random
53
+ * })
54
+ *
55
+ * nanoid() //=> "fbaef"
56
+ * ```
57
+ *
58
+ * @param alphabet Alphabet used to generate a random string.
59
+ * @param size Size of the random string.
60
+ * @param random A random bytes generator.
61
+ * @returns A random string generator.
62
+ */
63
+ export function customRandom(
64
+ alphabet: string,
65
+ size: number,
66
+ random: (bytes: number) => Uint8Array
67
+ ): () => string
68
+
69
+ /**
70
+ * URL safe symbols.
71
+ *
72
+ * ```js
73
+ * import { urlAlphabet } from './nanoid'
74
+ * const nanoid = customAlphabet(urlAlphabet, 10)
75
+ * nanoid() //=> "Uakgb_J5m9"
76
+ * ```
77
+ */
78
+ export const urlAlphabet: string
79
+
80
+ /**
81
+ * Generate an array of random bytes collected from hardware noise.
82
+ *
83
+ * ```js
84
+ * import { customRandom, random } from './nanoid'
85
+ * const nanoid = customRandom("abcdef", 5, random)
86
+ * ```
87
+ *
88
+ * @param bytes Size of the array.
89
+ * @returns An array of random bytes.
90
+ */
91
+ export function random(bytes: number): Uint8Array
@@ -0,0 +1 @@
1
+ (()=>{var e={113:e=>{"use strict";e.exports=require("crypto")},495:(e,r,t)=>{let l=t(113);let{urlAlphabet:a}=t(240);const n=128;let _,u;let fillPool=e=>{if(!_||_.length<e){_=Buffer.allocUnsafe(e*n);l.randomFillSync(_);u=0}else if(u+e>_.length){l.randomFillSync(_);u=0}u+=e};let random=e=>{fillPool(e-=0);return _.subarray(u-e,u)};let customRandom=(e,r,t)=>{let l=(2<<31-Math.clz32(e.length-1|1))-1;let a=Math.ceil(1.6*l*r/e.length);return(n=r)=>{let _="";while(true){let r=t(a);let u=a;while(u--){_+=e[r[u]&l]||"";if(_.length===n)return _}}}};let customAlphabet=(e,r=21)=>customRandom(e,r,random);let nanoid=(e=21)=>{fillPool(e-=0);let r="";for(let t=u-e;t<u;t++){r+=a[_[t]&63]}return r};e.exports={nanoid:nanoid,customAlphabet:customAlphabet,customRandom:customRandom,urlAlphabet:a,random:random}},240:e=>{let r="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";e.exports={urlAlphabet:r}}};var r={};function __nccwpck_require__(t){var l=r[t];if(l!==undefined){return l.exports}var a=r[t]={exports:{}};var n=true;try{e[t](a,a.exports,__nccwpck_require__);n=false}finally{if(n)delete r[t]}return a.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var t=__nccwpck_require__(495);module.exports=t})();
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright 2017 Andrey Sitnik <andrey@sitnik.ru>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1 @@
1
+ {"name":"nanoid","author":"Andrey Sitnik <andrey@sitnik.ru>","version":"3.3.4","license":"MIT","types":"./index.d.ts"}
@@ -0,0 +1 @@
1
+ (()=>{"use strict";var e={308:e=>{e.exports=e=>{if(typeof e!=="string"){throw new TypeError("Expected a string, got "+typeof e)}if(e.charCodeAt(0)===65279){return e.slice(1)}return e}},57:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:true});t.configLoader=t.loadConfig=void 0;var n=r(429);var i=r(17);var a=r(175);function loadConfig(e){if(e===void 0){e=a.options.cwd}return configLoader({cwd:e})}t.loadConfig=loadConfig;function configLoader(e){var t=e.cwd,r=e.explicitParams,a=e.tsConfigLoader,o=a===void 0?n.tsConfigLoader:a;if(r){var s=i.isAbsolute(r.baseUrl)?r.baseUrl:i.join(t,r.baseUrl);return{resultType:"success",configFileAbsolutePath:"",baseUrl:r.baseUrl,absoluteBaseUrl:s,paths:r.paths,mainFields:r.mainFields,addMatchAll:r.addMatchAll}}var u=o({cwd:t,getEnv:function(e){return process.env[e]}});if(!u.tsConfigPath){return{resultType:"failed",message:"Couldn't find tsconfig.json"}}if(!u.baseUrl){return{resultType:"failed",message:"Missing baseUrl in compilerOptions"}}var f=i.dirname(u.tsConfigPath);var c=i.join(f,u.baseUrl);return{resultType:"success",configFileAbsolutePath:u.tsConfigPath,baseUrl:u.baseUrl,absoluteBaseUrl:c,paths:u.paths||{}}}t.configLoader=configLoader},182:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:true});t.removeExtension=t.fileExistsAsync=t.readJsonFromDiskAsync=t.readJsonFromDiskSync=t.fileExistsSync=void 0;var n=r(147);function fileExistsSync(e){try{var t=n.statSync(e);return t.isFile()}catch(e){return false}}t.fileExistsSync=fileExistsSync;function readJsonFromDiskSync(e){if(!n.existsSync(e)){return undefined}return require(e)}t.readJsonFromDiskSync=readJsonFromDiskSync;function readJsonFromDiskAsync(e,t){n.readFile(e,"utf8",(function(e,r){if(e||!r){return t()}var n=JSON.parse(r);return t(undefined,n)}))}t.readJsonFromDiskAsync=readJsonFromDiskAsync;function fileExistsAsync(e,t){n.stat(e,(function(e,r){if(e){return t(undefined,false)}t(undefined,r?r.isFile():false)}))}t.fileExistsAsync=fileExistsAsync;function removeExtension(e){return e.substring(0,e.lastIndexOf("."))||e}t.removeExtension=removeExtension},462:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:true});t.getAbsoluteMappingEntries=void 0;var n=r(17);function getAbsoluteMappingEntries(e,t,r){var i=sortByLongestPrefix(Object.keys(t));var a=[];for(var o=0,s=i;o<s.length;o++){var u=s[o];a.push({pattern:u,paths:t[u].map((function(t){return n.join(e,t)}))})}if(!t["*"]&&r){a.push({pattern:"*",paths:["".concat(e.replace(/\/$/,""),"/*")]})}return a}t.getAbsoluteMappingEntries=getAbsoluteMappingEntries;function sortByLongestPrefix(e){return e.concat().sort((function(e,t){return getPrefixLength(t)-getPrefixLength(e)}))}function getPrefixLength(e){var t=e.indexOf("*");return e.substr(0,t).length}},29:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:true});t.matchFromAbsolutePathsAsync=t.createMatchPathAsync=void 0;var n=r(17);var i=r(306);var a=r(462);var o=r(182);function createMatchPathAsync(e,t,r,n){if(r===void 0){r=["main"]}if(n===void 0){n=true}var i=a.getAbsoluteMappingEntries(e,t,n);return function(e,t,n,a,o){return matchFromAbsolutePathsAsync(i,e,t,n,a,o,r)}}t.createMatchPathAsync=createMatchPathAsync;function matchFromAbsolutePathsAsync(e,t,r,n,a,s,u){if(r===void 0){r=o.readJsonFromDiskAsync}if(n===void 0){n=o.fileExistsAsync}if(a===void 0){a=Object.keys(require.extensions)}if(u===void 0){u=["main"]}var f=i.getPathsToTry(a,e,t);if(!f){return s()}findFirstExistingPath(f,r,n,s,0,u)}t.matchFromAbsolutePathsAsync=matchFromAbsolutePathsAsync;function findFirstExistingMainFieldMappedFile(e,t,r,i,a,o){if(o===void 0){o=0}if(o>=t.length){return a(undefined,undefined)}var tryNext=function(){return findFirstExistingMainFieldMappedFile(e,t,r,i,a,o+1)};var s=e[t[o]];if(typeof s!=="string"){return tryNext()}var u=n.join(n.dirname(r),s);i(u,(function(e,t){if(e){return a(e)}if(t){return a(undefined,u)}return tryNext()}))}function findFirstExistingPath(e,t,r,n,a,o){if(a===void 0){a=0}if(o===void 0){o=["main"]}var s=e[a];if(s.type==="file"||s.type==="extension"||s.type==="index"){r(s.path,(function(u,f){if(u){return n(u)}if(f){return n(undefined,i.getStrippedPath(s))}if(a===e.length-1){return n()}return findFirstExistingPath(e,t,r,n,a+1,o)}))}else if(s.type==="package"){t(s.path,(function(i,u){if(i){return n(i)}if(u){return findFirstExistingMainFieldMappedFile(u,o,s.path,r,(function(i,s){if(i){return n(i)}if(s){return n(undefined,s)}return findFirstExistingPath(e,t,r,n,a+1,o)}))}return findFirstExistingPath(e,t,r,n,a+1,o)}))}else{i.exhaustiveTypeException(s.type)}}},920:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:true});t.matchFromAbsolutePaths=t.createMatchPath=void 0;var n=r(17);var i=r(182);var a=r(462);var o=r(306);function createMatchPath(e,t,r,n){if(r===void 0){r=["main"]}if(n===void 0){n=true}var i=a.getAbsoluteMappingEntries(e,t,n);return function(e,t,n,a){return matchFromAbsolutePaths(i,e,t,n,a,r)}}t.createMatchPath=createMatchPath;function matchFromAbsolutePaths(e,t,r,n,a,s){if(r===void 0){r=i.readJsonFromDiskSync}if(n===void 0){n=i.fileExistsSync}if(a===void 0){a=Object.keys(require.extensions)}if(s===void 0){s=["main"]}var u=o.getPathsToTry(a,e,t);if(!u){return undefined}return findFirstExistingPath(u,r,n,s)}t.matchFromAbsolutePaths=matchFromAbsolutePaths;function findFirstExistingMainFieldMappedFile(e,t,r,i){for(var a=0;a<t.length;a++){var o=t[a];var s=e[o];if(s&&typeof s==="string"){var u=n.join(n.dirname(r),s);if(i(u)){return u}}}return undefined}function findFirstExistingPath(e,t,r,n){if(t===void 0){t=i.readJsonFromDiskSync}if(n===void 0){n=["main"]}for(var a=0,s=e;a<s.length;a++){var u=s[a];if(u.type==="file"||u.type==="extension"||u.type==="index"){if(r(u.path)){return o.getStrippedPath(u)}}else if(u.type==="package"){var f=t(u.path);if(f){var c=findFirstExistingMainFieldMappedFile(f,n,u.path,r);if(c){return c}}}else{o.exhaustiveTypeException(u.type)}}return undefined}},175:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:true});t.options=void 0;var n=r(227);var i=n(process.argv.slice(2),{string:["project"],alias:{project:["P"]}});var a=i&&i.project;t.options={cwd:a||process.cwd()}},41:function(e,t,r){var n=this&&this.__spreadArray||function(e,t,r){if(r||arguments.length===2)for(var n=0,i=t.length,a;n<i;n++){if(a||!(n in t)){if(!a)a=Array.prototype.slice.call(t,0,n);a[n]=t[n]}}return e.concat(a||Array.prototype.slice.call(t))};Object.defineProperty(t,"__esModule",{value:true});t.register=void 0;var i=r(920);var a=r(57);var o=r(175);var noOp=function(){return void 0};function getCoreModules(e){e=e||["assert","buffer","child_process","cluster","crypto","dgram","dns","domain","events","fs","http","https","net","os","path","punycode","querystring","readline","stream","string_decoder","tls","tty","url","util","v8","vm","zlib"];var t={};for(var r=0,n=e;r<n.length;r++){var i=n[r];t[i]=true}return t}function register(e){var t=(0,a.configLoader)({cwd:o.options.cwd,explicitParams:e});if(t.resultType==="failed"){console.warn("".concat(t.message,". tsconfig-paths will be skipped"));return noOp}var s=(0,i.createMatchPath)(t.absoluteBaseUrl,t.paths,t.mainFields,t.addMatchAll);var u=r(188);var f=u._resolveFilename;var c=getCoreModules(u.builtinModules);u._resolveFilename=function(e,t){var r=c.hasOwnProperty(e);if(!r){var i=s(e);if(i){var a=n([i],[].slice.call(arguments,1),true);return f.apply(this,a)}}return f.apply(this,arguments)};return function(){u._resolveFilename=f}}t.register=register},306:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:true});t.exhaustiveTypeException=t.getStrippedPath=t.getPathsToTry=void 0;var n=r(17);var i=r(17);var a=r(182);function getPathsToTry(e,t,r){if(!t||!r||r[0]==="."){return undefined}var i=[];for(var a=0,o=t;a<o.length;a++){var s=o[a];var u=s.pattern===r?"":matchStar(s.pattern,r);if(u!==undefined){var _loop_1=function(t){var r=t.replace("*",u);i.push({type:"file",path:r});i.push.apply(i,e.map((function(e){return{type:"extension",path:r+e}})));i.push({type:"package",path:n.join(r,"/package.json")});var a=n.join(r,"/index");i.push.apply(i,e.map((function(e){return{type:"index",path:a+e}})))};for(var f=0,c=s.paths;f<c.length;f++){var d=c[f];_loop_1(d)}}}return i.length===0?undefined:i}t.getPathsToTry=getPathsToTry;function getStrippedPath(e){return e.type==="index"?(0,i.dirname)(e.path):e.type==="file"?e.path:e.type==="extension"?(0,a.removeExtension)(e.path):e.type==="package"?e.path:exhaustiveTypeException(e.type)}t.getStrippedPath=getStrippedPath;function exhaustiveTypeException(e){throw new Error("Unknown type ".concat(e))}t.exhaustiveTypeException=exhaustiveTypeException;function matchStar(e,t){if(t.length<e.length){return undefined}if(e==="*"){return t}var r=e.indexOf("*");if(r===-1){return undefined}var n=e.substring(0,r);var i=e.substring(r+1);if(t.substr(0,r)!==n){return undefined}if(t.substr(t.length-i.length)!==i){return undefined}return t.substr(r,t.length-i.length)}},429:function(e,t,r){var n=this&&this.__assign||function(){n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++){t=arguments[r];for(var i in t)if(Object.prototype.hasOwnProperty.call(t,i))e[i]=t[i]}return e};return n.apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:true});t.loadTsconfig=t.walkForTsConfig=t.tsConfigLoader=void 0;var i=r(17);var a=r(147);var o=r(278);var s=r(308);function tsConfigLoader(e){var t=e.getEnv,r=e.cwd,n=e.loadSync,i=n===void 0?loadSyncDefault:n;var a=t("TS_NODE_PROJECT");var o=t("TS_NODE_BASEURL");var s=i(r,a,o);return s}t.tsConfigLoader=tsConfigLoader;function loadSyncDefault(e,t,r){var n=resolveConfigPath(e,t);if(!n){return{tsConfigPath:undefined,baseUrl:undefined,paths:undefined}}var i=loadTsconfig(n);return{tsConfigPath:n,baseUrl:r||i&&i.compilerOptions&&i.compilerOptions.baseUrl,paths:i&&i.compilerOptions&&i.compilerOptions.paths}}function resolveConfigPath(e,t){if(t){var r=a.lstatSync(t).isDirectory()?i.resolve(t,"./tsconfig.json"):i.resolve(e,t);return r}if(a.statSync(e).isFile()){return i.resolve(e)}var n=walkForTsConfig(e);return n?i.resolve(n):undefined}function walkForTsConfig(e,t){if(t===void 0){t=a.existsSync}var r=i.join(e,"./tsconfig.json");if(t(r)){return r}var n=i.join(e,"../");if(e===n){return undefined}return walkForTsConfig(n,t)}t.walkForTsConfig=walkForTsConfig;function loadTsconfig(e,t,r){if(t===void 0){t=a.existsSync}if(r===void 0){r=function(e){return a.readFileSync(e,"utf8")}}if(!t(e)){return undefined}var u=r(e);var f=s(u);var c=o.parse(f);var d=c.extends;if(d){if(typeof d==="string"&&d.indexOf(".json")===-1){d+=".json"}var l=i.dirname(e);var p=i.join(l,d);if(d.indexOf("/")!==-1&&d.indexOf(".")!==-1&&!t(p)){p=i.join(l,"node_modules",d)}var v=loadTsconfig(p,t,r)||{};if(v.compilerOptions&&v.compilerOptions.baseUrl){var h=i.dirname(d);v.compilerOptions.baseUrl=i.join(h,v.compilerOptions.baseUrl)}return n(n(n({},v),c),{compilerOptions:n(n({},v.compilerOptions),c.compilerOptions)})}return c}t.loadTsconfig=loadTsconfig},278:e=>{e.exports=require("../json5")},227:e=>{e.exports=require("../minimist")},147:e=>{e.exports=require("fs")},188:e=>{e.exports=require("module")},17:e=>{e.exports=require("path")}};var t={};function __nccwpck_require__(r){var n=t[r];if(n!==undefined){return n.exports}var i=t[r]={exports:{}};var a=true;try{e[r].call(i.exports,i,i.exports,__nccwpck_require__);a=false}finally{if(a)delete t[r]}return i.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var r={};(()=>{var e=r;Object.defineProperty(e,"__esModule",{value:true});e.loadConfig=e.register=e.matchFromAbsolutePathsAsync=e.createMatchPathAsync=e.matchFromAbsolutePaths=e.createMatchPath=void 0;var t=__nccwpck_require__(920);Object.defineProperty(e,"createMatchPath",{enumerable:true,get:function(){return t.createMatchPath}});Object.defineProperty(e,"matchFromAbsolutePaths",{enumerable:true,get:function(){return t.matchFromAbsolutePaths}});var n=__nccwpck_require__(29);Object.defineProperty(e,"createMatchPathAsync",{enumerable:true,get:function(){return n.createMatchPathAsync}});Object.defineProperty(e,"matchFromAbsolutePathsAsync",{enumerable:true,get:function(){return n.matchFromAbsolutePathsAsync}});var i=__nccwpck_require__(41);Object.defineProperty(e,"register",{enumerable:true,get:function(){return i.register}});var a=__nccwpck_require__(57);Object.defineProperty(e,"loadConfig",{enumerable:true,get:function(){return a.loadConfig}})})();module.exports=r})();
@@ -0,0 +1,33 @@
1
+ import * as TsConfigLoader2 from "./tsconfig-loader";
2
+ export interface ExplicitParams {
3
+ baseUrl: string;
4
+ paths: {
5
+ [key: string]: Array<string>;
6
+ };
7
+ mainFields?: Array<string>;
8
+ addMatchAll?: boolean;
9
+ }
10
+ export declare type TsConfigLoader = (params: TsConfigLoader2.TsConfigLoaderParams) => TsConfigLoader2.TsConfigLoaderResult;
11
+ export interface ConfigLoaderParams {
12
+ cwd: string;
13
+ explicitParams?: ExplicitParams;
14
+ tsConfigLoader?: TsConfigLoader;
15
+ }
16
+ export interface ConfigLoaderSuccessResult {
17
+ resultType: "success";
18
+ configFileAbsolutePath: string;
19
+ baseUrl: string;
20
+ absoluteBaseUrl: string;
21
+ paths: {
22
+ [key: string]: Array<string>;
23
+ };
24
+ mainFields?: Array<string>;
25
+ addMatchAll?: boolean;
26
+ }
27
+ export interface ConfigLoaderFailResult {
28
+ resultType: "failed";
29
+ message: string;
30
+ }
31
+ export declare type ConfigLoaderResult = ConfigLoaderSuccessResult | ConfigLoaderFailResult;
32
+ export declare function loadConfig(cwd?: string): ConfigLoaderResult;
33
+ export declare function configLoader({ cwd, explicitParams, tsConfigLoader, }: ConfigLoaderParams): ConfigLoaderResult;
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Typing for the fields of package.json we care about
3
+ */
4
+ export interface PackageJson {
5
+ [key: string]: string;
6
+ }
7
+ /**
8
+ * A function that json from a file
9
+ */
10
+ export interface ReadJsonSync {
11
+ (packageJsonPath: string): any | undefined;
12
+ }
13
+ export interface FileExistsSync {
14
+ (name: string): boolean;
15
+ }
16
+ export interface FileExistsAsync {
17
+ (path: string, callback: (err?: Error, exists?: boolean) => void): void;
18
+ }
19
+ export interface ReadJsonAsyncCallback {
20
+ (err?: Error, content?: any): void;
21
+ }
22
+ export interface ReadJsonAsync {
23
+ (path: string, callback: ReadJsonAsyncCallback): void;
24
+ }
25
+ export declare function fileExistsSync(path: string): boolean;
26
+ /**
27
+ * Reads package.json from disk
28
+ * @param file Path to package.json
29
+ */
30
+ export declare function readJsonFromDiskSync(packageJsonPath: string): any | undefined;
31
+ export declare function readJsonFromDiskAsync(path: string, callback: (err?: Error, content?: any) => void): void;
32
+ export declare function fileExistsAsync(path2: string, callback2: (err?: Error, exists?: boolean) => void): void;
33
+ export declare function removeExtension(path: string): string;
@@ -0,0 +1,5 @@
1
+ export { createMatchPath, matchFromAbsolutePaths, MatchPath, } from "./match-path-sync";
2
+ export { createMatchPathAsync, matchFromAbsolutePathsAsync, MatchPathAsync, } from "./match-path-async";
3
+ export { register } from "./register";
4
+ export { loadConfig, ConfigLoaderResult, ConfigLoaderSuccessResult, ConfigLoaderFailResult, } from "./config-loader";
5
+ export { ReadJsonSync, ReadJsonAsync, FileExistsSync, FileExistsAsync, } from "./filesystem";
@@ -0,0 +1,17 @@
1
+ export interface MappingEntry {
2
+ readonly pattern: string;
3
+ readonly paths: ReadonlyArray<string>;
4
+ }
5
+ export interface Paths {
6
+ readonly [key: string]: ReadonlyArray<string>;
7
+ }
8
+ /**
9
+ * Converts an absolute baseUrl and paths to an array of absolute mapping entries.
10
+ * The array is sorted by longest prefix.
11
+ * Having an array with entries allows us to keep a sorting order rather than
12
+ * sort by keys each time we use the mappings.
13
+ * @param absoluteBaseUrl
14
+ * @param paths
15
+ * @param addMatchAll
16
+ */
17
+ export declare function getAbsoluteMappingEntries(absoluteBaseUrl: string, paths: Paths, addMatchAll: boolean): ReadonlyArray<MappingEntry>;
@@ -0,0 +1,21 @@
1
+ import * as MappingEntry from "./mapping-entry";
2
+ import * as Filesystem from "./filesystem";
3
+ /**
4
+ * Function that can match a path async
5
+ */
6
+ export interface MatchPathAsync {
7
+ (requestedModule: string, readJson: Filesystem.ReadJsonAsync | undefined, fileExists: Filesystem.FileExistsAsync | undefined, extensions: ReadonlyArray<string> | undefined, callback: MatchPathAsyncCallback): void;
8
+ }
9
+ export interface MatchPathAsyncCallback {
10
+ (err?: Error, path?: string): void;
11
+ }
12
+ /**
13
+ * See the sync version for docs.
14
+ */
15
+ export declare function createMatchPathAsync(absoluteBaseUrl: string, paths: {
16
+ [key: string]: Array<string>;
17
+ }, mainFields?: string[], addMatchAll?: boolean): MatchPathAsync;
18
+ /**
19
+ * See the sync version for docs.
20
+ */
21
+ export declare function matchFromAbsolutePathsAsync(absolutePathMappings: ReadonlyArray<MappingEntry.MappingEntry>, requestedModule: string, readJson: Filesystem.ReadJsonAsync | undefined, fileExists: Filesystem.FileExistsAsync | undefined, extensions: readonly string[] | undefined, callback: MatchPathAsyncCallback, mainFields?: string[]): void;
@@ -0,0 +1,30 @@
1
+ import * as Filesystem from "./filesystem";
2
+ import * as MappingEntry from "./mapping-entry";
3
+ /**
4
+ * Function that can match a path
5
+ */
6
+ export interface MatchPath {
7
+ (requestedModule: string, readJson?: Filesystem.ReadJsonSync, fileExists?: (name: string) => boolean, extensions?: ReadonlyArray<string>): string | undefined;
8
+ }
9
+ /**
10
+ * Creates a function that can resolve paths according to tsconfig paths property.
11
+ * @param absoluteBaseUrl Absolute version of baseUrl as specified in tsconfig.
12
+ * @param paths The paths as specified in tsconfig.
13
+ * @param mainFields A list of package.json field names to try when resolving module files.
14
+ * @param addMatchAll Add a match-all "*" rule if none is present
15
+ * @returns a function that can resolve paths.
16
+ */
17
+ export declare function createMatchPath(absoluteBaseUrl: string, paths: {
18
+ [key: string]: Array<string>;
19
+ }, mainFields?: string[], addMatchAll?: boolean): MatchPath;
20
+ /**
21
+ * Finds a path from tsconfig that matches a module load request.
22
+ * @param absolutePathMappings The paths to try as specified in tsconfig but resolved to absolute form.
23
+ * @param requestedModule The required module name.
24
+ * @param readJson Function that can read json from a path (useful for testing).
25
+ * @param fileExists Function that checks for existence of a file at a path (useful for testing).
26
+ * @param extensions File extensions to probe for (useful for testing).
27
+ * @param mainFields A list of package.json field names to try when resolving module files.
28
+ * @returns the found path, or undefined if no path was found.
29
+ */
30
+ export declare function matchFromAbsolutePaths(absolutePathMappings: ReadonlyArray<MappingEntry.MappingEntry>, requestedModule: string, readJson?: Filesystem.ReadJsonSync, fileExists?: Filesystem.FileExistsSync, extensions?: Array<string>, mainFields?: string[]): string | undefined;
@@ -0,0 +1,4 @@
1
+ export interface Options {
2
+ cwd: string;
3
+ }
4
+ export declare const options: Options;
@@ -0,0 +1,6 @@
1
+ import { ExplicitParams } from "./config-loader";
2
+ /**
3
+ * Installs a custom module load function that can adhere to paths in tsconfig.
4
+ * Returns a function to undo paths registration.
5
+ */
6
+ export declare function register(explicitParams: ExplicitParams): () => void;
@@ -0,0 +1,15 @@
1
+ import { MappingEntry } from "./mapping-entry";
2
+ export interface TryPath {
3
+ readonly type: "file" | "extension" | "index" | "package";
4
+ readonly path: string;
5
+ }
6
+ /**
7
+ * Builds a list of all physical paths to try by:
8
+ * 1. Check for file named exactly as request.
9
+ * 2. Check for files named as request ending in any of the extensions.
10
+ * 3. Check for file specified in package.json's main property.
11
+ * 4. Check for files named as request ending in "index" with any of the extensions.
12
+ */
13
+ export declare function getPathsToTry(extensions: ReadonlyArray<string>, absolutePathMappings: ReadonlyArray<MappingEntry>, requestedModule: string): ReadonlyArray<TryPath> | undefined;
14
+ export declare function getStrippedPath(tryPath: TryPath): string;
15
+ export declare function exhaustiveTypeException(check: never): never;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Typing for the parts of tsconfig that we care about
3
+ */
4
+ export interface Tsconfig {
5
+ extends?: string;
6
+ compilerOptions?: {
7
+ baseUrl?: string;
8
+ paths?: {
9
+ [key: string]: Array<string>;
10
+ };
11
+ strict?: boolean;
12
+ };
13
+ }
14
+ export interface TsConfigLoaderResult {
15
+ tsConfigPath: string | undefined;
16
+ baseUrl: string | undefined;
17
+ paths: {
18
+ [key: string]: Array<string>;
19
+ } | undefined;
20
+ }
21
+ export interface TsConfigLoaderParams {
22
+ getEnv: (key: string) => string | undefined;
23
+ cwd: string;
24
+ loadSync?(cwd: string, filename?: string, baseUrl?: string): TsConfigLoaderResult;
25
+ }
26
+ export declare function tsConfigLoader({ getEnv, cwd, loadSync, }: TsConfigLoaderParams): TsConfigLoaderResult;
27
+ export declare function walkForTsConfig(directory: string, existsSync?: (path: string) => boolean): string | undefined;
28
+ export declare function loadTsconfig(configFilePath: string, existsSync?: (path: string) => boolean, readFileSync?: (filename: string) => string): Tsconfig | undefined;
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Jonas Kello
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ {"name":"tsconfig-paths","author":"Jonas Kello","version":"3.14.1","license":"MIT","types":"lib/index.d.ts"}
@@ -9,6 +9,7 @@ export { default as execa } from '../compiled/execa';
9
9
  export { default as json5 } from '../compiled/json5';
10
10
  export { default as upath } from '../compiled/upath';
11
11
  export { default as pkgUp } from '../compiled/pkg-up';
12
+ export { nanoid } from '../compiled/nanoid';
12
13
  export { default as semver } from '../compiled/semver';
13
14
  export { default as dotenv } from '../compiled/dotenv';
14
15
  export { default as lodash } from '../compiled/lodash';
package/dist/compiled.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.inquirer = exports.chokidar = exports.mime = exports.Signale = exports.Command = exports.program = exports.recursiveReaddir = exports.browserslist = exports.dotenvExpand = exports.stripAnsi = exports.gzipSize = exports.filesize = exports.fastGlob = exports.minimist = exports.urlJoin = exports.signale = exports.address = exports.globby = exports.lodash = exports.dotenv = exports.semver = exports.pkgUp = exports.upath = exports.json5 = exports.execa = exports.slash = exports.debug = exports.chalk = exports.yaml = exports.glob = exports.ora = exports.fs = void 0;
6
+ exports.inquirer = exports.chokidar = exports.mime = exports.Signale = exports.Command = exports.program = exports.recursiveReaddir = exports.browserslist = exports.dotenvExpand = exports.stripAnsi = exports.gzipSize = exports.filesize = exports.fastGlob = exports.minimist = exports.urlJoin = exports.signale = exports.address = exports.globby = exports.lodash = exports.dotenv = exports.semver = exports.nanoid = exports.pkgUp = exports.upath = exports.json5 = exports.execa = exports.slash = exports.debug = exports.chalk = exports.yaml = exports.glob = exports.ora = exports.fs = void 0;
7
7
  const import_1 = require("./import");
8
8
  var fs_extra_1 = require("../compiled/fs-extra");
9
9
  Object.defineProperty(exports, "fs", { enumerable: true, get: function () { return __importDefault(fs_extra_1).default; } });
@@ -27,6 +27,8 @@ var upath_1 = require("../compiled/upath");
27
27
  Object.defineProperty(exports, "upath", { enumerable: true, get: function () { return __importDefault(upath_1).default; } });
28
28
  var pkg_up_1 = require("../compiled/pkg-up");
29
29
  Object.defineProperty(exports, "pkgUp", { enumerable: true, get: function () { return __importDefault(pkg_up_1).default; } });
30
+ var nanoid_1 = require("../compiled/nanoid");
31
+ Object.defineProperty(exports, "nanoid", { enumerable: true, get: function () { return nanoid_1.nanoid; } });
30
32
  var semver_1 = require("../compiled/semver");
31
33
  Object.defineProperty(exports, "semver", { enumerable: true, get: function () { return __importDefault(semver_1).default; } });
32
34
  var dotenv_1 = require("../compiled/dotenv");
package/dist/monorepo.js CHANGED
@@ -8,16 +8,16 @@ const fs_1 = __importDefault(require("fs"));
8
8
  const path_1 = __importDefault(require("path"));
9
9
  const compiled_1 = require("./compiled");
10
10
  const PACKAGE_MAX_DEPTH = 5;
11
- const WORKSPACES_FILES = {
11
+ const WORKSPACE_FILES = {
12
12
  YARN: 'package.json',
13
- PNPM: 'pnpm-workspaces.yaml',
13
+ PNPM: 'pnpm-workspace.yaml',
14
14
  LERNA: 'lerna.json',
15
15
  };
16
- const isLerna = (root) => fs_1.default.existsSync(path_1.default.join(root, WORKSPACES_FILES.LERNA));
16
+ const isLerna = (root) => fs_1.default.existsSync(path_1.default.join(root, WORKSPACE_FILES.LERNA));
17
17
  exports.isLerna = isLerna;
18
18
  const isYarnWorkspaces = (root) => {
19
19
  var _a;
20
- const pkg = path_1.default.join(root, WORKSPACES_FILES.YARN);
20
+ const pkg = path_1.default.join(root, WORKSPACE_FILES.YARN);
21
21
  if (!fs_1.default.existsSync(pkg)) {
22
22
  return false;
23
23
  }
@@ -25,7 +25,7 @@ const isYarnWorkspaces = (root) => {
25
25
  return Boolean((_a = json.workspaces) === null || _a === void 0 ? void 0 : _a.packages);
26
26
  };
27
27
  exports.isYarnWorkspaces = isYarnWorkspaces;
28
- const isPnpmWorkspaces = (root) => fs_1.default.existsSync(path_1.default.join(root, WORKSPACES_FILES.PNPM));
28
+ const isPnpmWorkspaces = (root) => fs_1.default.existsSync(path_1.default.join(root, WORKSPACE_FILES.PNPM));
29
29
  exports.isPnpmWorkspaces = isPnpmWorkspaces;
30
30
  const isMonorepo = (root) => (0, exports.isLerna)(root) || (0, exports.isYarnWorkspaces)(root) || (0, exports.isPnpmWorkspaces)(root);
31
31
  exports.isMonorepo = isMonorepo;
@@ -62,7 +62,7 @@ const getMonorepoPackages = (root) => {
62
62
  ({ packages } = json);
63
63
  }
64
64
  else {
65
- ({ packages } = compiled_1.yaml.load(fs_1.default.readFileSync(path_1.default.join(root, WORKSPACES_FILES.PNPM), 'utf8')));
65
+ ({ packages } = compiled_1.yaml.load(fs_1.default.readFileSync(path_1.default.join(root, WORKSPACE_FILES.PNPM), 'utf8')));
66
66
  }
67
67
  if (packages) {
68
68
  return packages
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "1.7.3",
14
+ "version": "1.7.4",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/index.d.ts",
17
17
  "main": "./dist/index.js",
@@ -32,7 +32,8 @@
32
32
  "./gzip-size": "./compiled/gzip-size/index.js",
33
33
  "./mime-types": "./compiled/mime-types/index.js",
34
34
  "./strip-ansi": "./compiled/strip-ansi/index.js",
35
- "./browserslist": "./compiled/browserslist/index.js"
35
+ "./browserslist": "./compiled/browserslist/index.js",
36
+ "./tsconfig-paths": "./compiled/tsconfig-paths/index.js"
36
37
  },
37
38
  "publishConfig": {
38
39
  "registry": "https://registry.npmjs.org/",
@@ -78,6 +79,9 @@
78
79
  ],
79
80
  "browserslist": [
80
81
  "./compiled/browserslist/index.d.ts"
82
+ ],
83
+ "tsconfig-paths": [
84
+ "./compiled/tsconfig-paths/lib/index.d.ts"
81
85
  ]
82
86
  }
83
87
  },
@@ -101,7 +105,6 @@
101
105
  "command": "tsc",
102
106
  "files": [
103
107
  "src/**/*",
104
- "compiled/**/*.js",
105
108
  "tsconfig.json",
106
109
  "package.json"
107
110
  ],
@@ -113,9 +116,9 @@
113
116
  "command": "jest --passWithNoTests",
114
117
  "files": [
115
118
  "src/**/*",
116
- "compiled/**/*.js",
117
119
  "tsconfig.json",
118
- "package.json"
120
+ "package.json",
121
+ "tests/**/*"
119
122
  ],
120
123
  "output": []
121
124
  }