NaverPayDev / nurl

MIT License
3 stars 0 forks source link

dependency alias 적용 후 punycode의 module field가 적용되지 않음 #31

Closed yongholeeme closed 26 minutes ago

yongholeeme commented 3 hours ago

dependency alias 적용 후 dist/esm/index.js 에서 import {decode, encode} from 'npm-punycode' 로 import 하고 있는 부분에서 npm-punycode의 cjs 코드를 참조해 에러가 발생하는 듯

file:///Users/USER/dev/github/nurl1/dist/esm/index.mjs:1
import { encode as d, decode as c } from "npm-punycode";
                      ^^^^^^
SyntaxError: Named export 'decode' not found. The requested module 'npm-punycode' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:

import pkg from 'npm-punycode';
const { encode: d, decode: c } = pkg;

    at ModuleJob._instantiate (node:internal/modules/esm/module_job:134:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:217:5)
    at async ModuleLoader.import (node:internal/modules/esm/loader:316:24)
    at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:123:5)

Node.js v20.13.1
2-one-week commented 2 hours ago

기본 punycode를 설치하고, pnpm patch 처리하는 것도 좋은 것 같아요~

yceffort-naver commented 2 hours ago

https://unpkg.com/browse/punycode@2.3.1/package.json

저희는

https://github.com/NaverPayDev/nurl/blob/c32a83f6e24b7e347515c3833143b2b9cba47dc0/package.json#L8-L16

이렇게 exports로 찾아가고 있는데, 저기는 그게 없이 module로만 되어 있어서 그런거같네요...

yceffort-naver commented 2 hours ago

코드 좀 훔쳐와서 es-punycode라도 만들까요 ㅋㅋㅋ

https://github.com/mathiasbynens/punycode.js/issues?q=is%3Aissue+is%3Aopen+esm+

보니까 더이상 뭐할 의지는 없어보이긴하네요

2-one-week commented 2 hours ago

있어도 좀 특이한...ㅋㅋㅋ

"module": "punycode.es6.js",

yceffort-naver commented 2 hours ago

준내 오래되보이긴하네요 ㅋㅋ

2-one-week commented 2 hours ago

그렇다고.. es6 자체를 지원안하고 있는건 아닌 것 같아서,, 싸게싸게 가려면 그냥 저거 patch 처리해서 파일명 바꾸고 package.json 수정하면 될 것 같은데,, 이게 패키지라서 제대로 말려서 들어갈 진 모르겠네여?

yceffort-naver commented 2 hours ago

module은 번들러에서만 지원하는 야매 필드라, nodejs 환경에서는 제대로 안될거같습니다

2-one-week commented 2 hours ago

흐음.. 그러면 es-punycode로 가는 수 밖에!ㅋㅋ

yongholeeme commented 1 hour ago

punycode-esm 이 있습니다만 cjs 에서 사용할 수가 없..(사용할 순 있지만..)

yceffort-naver commented 1 hour ago

당신의 선택 ~~~~

yongholeeme commented 1 hour ago

다같이 빌드해버리자는 말씀이시죠?

이거 하고 싶지는 않은데.. ㅠ^ㅠ 일단 코드 수정해서 nurl esm에서 punycode cjs import 정상적으로 사용할 수 있게 할까요?

yceffort-naver commented 1 hour ago

이거 하고 싶지는 않은데.. ㅠ^ㅠ

22222

일단 코드 수정해서 nurl esm에서 punycode cjs import 정상적으로 사용할 수 있게 할까요?

`import punycode from 'punycode'

해서 punycode.decode 이렇게여?

yongholeeme commented 1 hour ago

@yceffort-naver 님, 네 맞습니다

yceffort-naver commented 1 hour ago

일단 그러케 하시죠~~~~

yongholeeme commented 26 minutes ago

@naverpay/punycode ..? 🫣