Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- ERR_CERT_AUTHORITY_INVALID
- 무과금살아남기
- 나의야근
- 리엑트
- 야근은결국승리
- 선택했을까
- 코틀린
- react
- checkupdates
- ReactRouter6 다운그레이드
- 자바스크립트
- 모던디자인테마
- vscode 수동업데이트
- 해볼게
- 정규식
- 날이새도록
- 시플플은영원하구나
- ubuntu_rg_cpu_100%
- VSCode
- 리엑트라우터 구버전 살리기
- 복붙하기좋은
- 안할수가없네
- 편하게쓰자
- ReactRouter withRouter
- 신기술은
- HTML 자바스크립트 태그제거
- 반갑지는않아
- kotlinc
- ReactRouter 4
- 공부할시간이
Archives
- Today
- Total
필사(筆寫)
Nodejs ESM 모듈 동적 import 구문 몇가지 예시 본문
1. DISK IO 잡아먹으면서 들어가는 방법
import { promises as fs } from 'fs';
import { pathToFileURL } from 'url';
const tempFilePath = './temp-bundle.mjs';
await fs.writeFile(tempFilePath, bundledCode);
const { default: Example } = await import(pathToFileURL(tempFilePath).href);
await fs.unlink(tempFilePath);
2. 메모리에 담고 처리하는 방법
import { createRequire } from 'module';
const require = createRequire(import.meta.url);
const { default: Component } = await import('data:text/javascript;base64,' + Buffer.from(bundledCode).toString('base64'));
쓴다면 후자가 낫다. 피차 express 전달할 때 메모리로 전달하기에..
'Service Developments > Node.js,Express' 카테고리의 다른 글
Node.vm 으로 하위 가상 모듈 만들기 사용법 메모 (0) | 2024.07.19 |
---|---|
nginx 1.27.1 http3 설정 방법 및 체크 방법 (0) | 2024.07.19 |
ubunutu 20, 22 계열 기본 설치된 nginx 1.18 삭제 방법 (0) | 2024.07.19 |
express.js "uv_resident_set_memory" 오류 (0) | 2024.07.19 |
V8에서 GC를 조금 더 빠르게 쓰는 가장 간단한 팁 (0) | 2024.01.28 |