resolve dependencies
1.0.0
npm i resolve-dependencies
resolve-dependencies 원래 Nexe의 Bundler라는 이름입니다. 번들러를 건설하려는 우리의 의도는 아니지만 이것이 바로 이것이 바로 그 것입니다.
default: resolveSync(options: Options, ...opts: Options[]): Promise<Result>Options : 객체 | String- 시작할 항목 (IF String)entries : String [] - 트래버스에 대한 항목 목록, CWD에 대해 해결cwd : String- 해상도가 발생하는 기본 디렉토리loadContent : Boolean- 컨텐츠에 포함되어야 함을 나타냅니다.files : ({[key : string] : file | null}) [] - 이미 해결 된 파일의 캐시expand : '모두'| '없음'| '변수' - 추가 파일을 포함하도록 모듈 컨텍스트를 확장 해야하는 방법 모든 옵션이 심하게 병합되고 문자열 옵션이 entries 으로 추가됩니다.
결과 객체의 약속을 반환합니다.
Result : 물체entries : {[키 : 항목] : 파일} - resolve 메소드 및 연결된 files 의 트리에 제공된 모든 항목files : {[key : abspath] : file} - 모든 해결 된 파일은 절대 경로에 의해 키워집니다.warnings : String [] - files 처리 중에 생성 된 배열 경고 File 의 모양이 있습니다
File : 개체 - 파일을 나타내는 개체size : 번호 - 링크 또는 파일의 파일 크기absPath : 문자열 - 파일의 절대 경로moduleRoot : 문자열 | undefined- 모듈 패키지가 포함 된 디렉토리package : 모든 | 한정되지 않은deps : {[키 : 요청] : 파일 | null} - 파일에서 식별 된 종속성, 요청에 따라 키belongsTo : 파일 | undefined- 소유 모듈의 기본 파일입니다realSize : 숫자 | undefined- abspath가 Symlink 인 경우 RealFile 크기로 설정realPath : String | undefined- abspath가 Symlink 인 경우 RealPath로 설정contents : 문자열 | 널contextExpanded : 부울variableImports : 부울 import resolveDependencies from 'resolve-dependencies'
const { entries , files } = resolveDependencies ( './entry-file.js' )
console . log ( entries [ './entry-file.js' ] )
// {
// absPath: "/path/to/entry-file.js",
// contents: "console.log('hello world')",
// realSize: 26,
// realPath: "/path/to/entry/lib/file.js"
// size: 12
// variableImports: false,
// deps: {
// "./dependency": {
// absPath: "/path/to/dependency.js"
// ...
// },
// path: null, //node builtin does not resolve
// mkdirp: {
// absPath: "/path/to/node_modules/mkdirp/index.js",
// modulePath: "/path/to/node_modules/mkdirp",
// package: {
// name: "mkdirp"
// ...
// }
// }
// }
// }
// `files` is a similar structure to entries, but
// is flat and keyed by the file's absolute path.