Skip to content
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

Transpile for non-modern browsers #1

Closed
isBatak opened this issue Mar 16, 2020 · 8 comments
Closed

Transpile for non-modern browsers #1

isBatak opened this issue Mar 16, 2020 · 8 comments

Comments

@isBatak
Copy link

isBatak commented Mar 16, 2020

Could you use https://github.com/developit/microbundle to support older browsers?
It seems this lib is not working on browsers that don't support spread operators, like old Edge and IE11.

@bartlomiejzuber
Copy link
Owner

Hey, thanks for letting me know. I will check this one out. 👍

@bartlomiejzuber
Copy link
Owner

bartlomiejzuber commented Mar 17, 2020

@isBatak Fixed in 1.2.1 version. You can update it via yarn upgrade use-open-window@1.2.1.
I've checked the lib you've proposed but according to latest issue (developit/microbundle#565) this lib have really ugly bug inside and while the change you require is quite simple to fix via tsconfig I've decided to not migrate to microbundle yet.

Thank you for you're contribution here.

@isBatak
Copy link
Author

isBatak commented Mar 17, 2020

@bartlomiejzuber maybe you can check this one https://github.com/jaredpalmer/tsdx. It's comparable with microbundle https://github.com/jaredpalmer/tsdx/blob/master/README.md#comparison-to-microbundle.
At least you should setup Rollup bundler to support all module types (and there are few of them https://dev.to/iggredible/what-the-heck-are-cjs-amd-umd-and-esm-ikm).

I'm using your lib with Next.js so it should support cjs (node), umd(old browsers) and esm (modern). vercel/next.js#7563
I'm not sure tsc can handle them all.

@isBatak
Copy link
Author

isBatak commented Mar 17, 2020

This should work also.

"main": "./dist/index.js",
"module": "./esm/index.js",
"types": "./dist/index.d.ts",
"files": [
    "dist/**",
    "esm/**"
],
"scripts": {
    "build": "npm run build:esm && npm run build:cjs",
    "build:cjs": "ncc build src/index.ts -o dist -m -e react",
    "build:esm": "tsc --target ESNext --module ES6 --outDir esm",
},
...

ncc is this lib https://www.npmjs.com/package/@zeit/ncc

@bartlomiejzuber
Copy link
Owner

Sounds great, I've used lib https://github.com/jaredpalmer/tsdx. All mentioned module types has been shipped inside 1.2.2 version. Here's how /dist looks like.
image

@isBatak
Copy link
Author

isBatak commented Mar 17, 2020

Wooohoo!!! Thx! You are the best! :D

@isBatak
Copy link
Author

isBatak commented Mar 17, 2020

@bartlomiejzuber I think you need to add these three settings to package.json also

"module": "dist/use-open-window.esm.js",
  "typings": "dist/index.d.ts",
  "files": [
    "dist"
  ],

@bartlomiejzuber
Copy link
Owner

@isBatak It's done and published under 1.2.3 version. :) Glad that I could help and I learnt something as well. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants