-
Notifications
You must be signed in to change notification settings - Fork 0
feat: npm-add #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: npm-add #17
Conversation
- npm 레지스트리에서 패키지 다운로드 기능 구현 - NpmResolver: npm 패키지 다운로드, 압축 해제, 캐시 관리 - NpmModuleLoader: npm: 프로토콜을 통한 패키지 로드 지원 - ES 모듈 import 문 실행 지원 (load_main_es_module_from_code 사용) - 패키지 다운로드 과정 추적을 위한 로그 추가 - 의존성 추가: reqwest, tar, flate2, serde, serde_json, dirs, futures
- ES 모듈 import 구문 감지 시 load_main_es_module_from_code 사용 - npm 패키지 다운로드 과정 상세 로그 추가 - 진입점 찾기, 파일 읽기, ModuleSource 생성 단계 로그 - NpmResolver::find_entry_point 상세 로그 - 모듈 로더 resolve/load 메서드 호출 추적 로그 추가
- npm: URL과 실제 파일 경로 매핑 구조 추가 - resolve 시 npm: referrer를 실제 file:// URL로 변환 - load 시 npm 패키지 진입점 경로를 매핑에 저장 - npm 패키지 내부 상대 경로(./add.js 등) import 정상 처리
- package.json의 types/typings 필드 확인 기능 추가 - @types 패키지 자동 검색 로그 추가 - 타입 정의 파일 경로 로깅 - 파일 확장자 기반 ModuleType 결정 (TypeScript 파일 감지) - find_type_definitions 메서드 추가
exports.import > module > exports.default > main 순서로 ESM 파일을 우선적으로 선택하도록 변경
immer 등 npm 패키지에서 사용하는 process.env.NODE_ENV 지원
- API 참조를 개발하기 섹션으로 이동 - 개발 가이드를 dev 폴더로 이동 - 가이드 섹션에 npm-modules 추가
- npm 모듈 사용하기 가이드 추가 - getting-started에 npm 모듈 예제 추가 - 홈페이지에 npm 모듈 지원 및 CommonJS 변환 기능 추가
개발하기 섹션으로 이동하여 파일 제거
개발하기 섹션에서 API 참조 문서로 연결
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds npm module support to ExecuteJS, allowing users to directly import and use packages from the npm registry using the npm: protocol. The implementation includes a custom module loader, package resolution, caching, and documentation for the new feature.
- Implements
NpmModuleLoaderandNpmResolverto handle npm package downloads and caching - Adds documentation for npm module usage in Korean
- Restructures documentation navigation to include development and API reference sections
Reviewed Changes
Copilot reviewed 12 out of 14 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/deno-runtime/src/npm_resolver.rs | New module implementing npm package resolution, download, and caching logic |
| crates/deno-runtime/src/lib.rs | Adds NpmModuleLoader that handles npm: protocol imports and integrates with Deno runtime |
| crates/deno-runtime/src/bootstrap.js | Adds Node.js compatibility shims (process object) for npm modules |
| crates/deno-runtime/Cargo.toml | Adds dependencies for HTTP client, tarball extraction, and JSON parsing |
| docs/docs/guide/npm-modules.mdx | New documentation page explaining npm module usage |
| docs/docs/guide/getting-started.mdx | Updates getting started guide with npm module examples |
| docs/docs/dev/development.mdx | Documents npm module loading architecture |
| docs/docs/dev/api/commands.mdx | New API reference documentation |
| docs/docs/*/_meta.json | Updates navigation structure |
| .cursorrules | Removes clippy from linting checklist |
Comments suppressed due to low confidence (2)
docs/docs/dev/development.mdx:177
- The description says 'CommonJS 패키지' (CommonJS packages) but the label is 'UMD 변환' (UMD conversion). This should be corrected to 'UMD 변환: UMD 패키지를 ES 모듈로 자동 변환(지원 예정)' for consistency.
docs/docs/dev/development.mdx:189 - Line 189 is missing '를' between 'UMD' and 'ES'. Should be '
swc를 통해 UMD를 ES 모듈로 변환(지원 예정)'.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Bori-github
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
전부다 제대로 읽은건 아닌데.. 그래도 여차저차 최선을 다해 코드 읽어봄...
- CommonJS 변환 미구현 상태에 맞게 문서 수정 - 작동 방식에서 CommonJS 변환 단계 제거 - 지원되는 패키지 형식 섹션으로 통합
@scope/package@version 형식에서 second_at_pos 기준 오류 수정 package_spec 기준으로 올바른 인덱스 계산
PR 요약: npm 모듈 지원 및 ESM 우선순위 개선
📋 개요
ExecuteJS에서 npm 레지스트리의 패키지를 직접 다운로드하고 사용할 수 있는 기능을 추가했습니다. 또한 ESM(ES Module) 형식의 패키지를 우선적으로 로드하도록 개선하고, npm 패키지 호환성을 높이기 위한 여러 기능을 구현했습니다.
✨ 주요 변경사항
1. npm 패키지 다운로드 및 import 지원
crates/deno-runtime/src/npm_resolver.rs,crates/deno-runtime/src/lib.rsnpm:프로토콜을 통한 패키지 import 지원2. ESM 우선순위로 진입점 찾기 개선
crates/deno-runtime/src/npm_resolver.rsexports.import→module→exports.default→main순서로 ESM 파일 우선 선택3. Node.js process 객체 추가
crates/deno-runtime/src/bootstrap.jsprocess.env.NODE_ENV지원4. TypeScript 타입 정의 파일 지원
crates/deno-runtime/src/npm_resolver.rs.d.ts파일 자동 감지 및 로드5. CommonJS to ES Module 변환 개선
crates/deno-runtime/src/lib.rs6. 문서 구조 개선 및 사용자 가이드 추가
docs/docs/guide/npm-modules.mdx,docs/docs/dev/🔧 기술적 세부사항
아키텍처
우선순위 로직
📦 지원되는 패키지 예제
🎯 사용 예제
📚 문서 변경사항
새로운 가이드 추가:
docs/docs/guide/npm-modules.mdx문서 구조 개선:
dev/섹션으로 통합홈페이지 업데이트:
🧪 테스트
🔄 관련 이슈
📝 커밋 내역
feat(deno-runtime): npm 패키지 다운로드 및 import 지원 추가refactor(deno-runtime): ES 모듈 실행 개선 및 디버깅 로그 추가fix(deno-runtime): npm 패키지 내부 상대 경로 import 지원feat(deno-runtime): npm 패키지 TypeScript 타입 정의 파일 지원feat: 에러 명확하게 수정fix(deno-runtime): ESM 우선순위로 npm 패키지 진입점 찾기 개선feat(deno-runtime): Node.js process 객체 추가로 npm 모듈 호환성 개선docs: 개발 문서 구조 재구성docs: npm 모듈 사용 가이드 추가 및 홈페이지 업데이트chore(docs): 사용하지 않는 API 문서 제거docs: 개발 가이드에 API 참조 링크 추가🚀 다음 단계 (향후 개선사항)