Skip to content

Convert to ES6 module #89

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

Closed
ghost opened this issue Jun 25, 2020 · 10 comments · Fixed by #259
Closed

Convert to ES6 module #89

ghost opened this issue Jun 25, 2020 · 10 comments · Fixed by #259
Labels
enhancement New feature or request

Comments

@ghost
Copy link

ghost commented Jun 25, 2020

why using module.exports whne you can import/export?

@Minigugus
Copy link
Contributor

Because Node.JS ESM support is still experimental and using import/export means adding a build step, which break the 0 dependencies principle 😉

@porsager
Copy link
Owner

porsager commented Aug 3, 2020

Actually @Minigugus, if you look back before 1.0 release in the commits I had the source in import/export syntax, and then a small script to convert to commonjs, hehe.. The reason I removed it was because I didn't want to spend more time setting up dual packages (it didn't seem set in stone then), and I also liked being able to just instantly test stuff out..

I think the time is better now, so I'd be fine digging the conversion script back out, convert and also help us in the progress of making Postgres.js deno compatible 😉

@Minigugus
Copy link
Contributor

I think the time is better now, so I'd be fine digging the conversion script back out, convert and also help us in the progress of making Postgres.js deno compatible

Awesome 😄 Maybe this can help https://github.com/Minigugus/postgres-deno 😏 😉

Also, if you are ready for ES6 modules, what about full TypeScript conversion (still Deno compatible 😉)?

@stalniy
Copy link
Contributor

stalniy commented Nov 10, 2020

Nodejs 14 is LTS NOW, supports import/export and dual package loading. So, it’s time to migrate :)

@porsager porsager added the enhancement New feature or request label Mar 23, 2021
@maxpain
Copy link

maxpain commented Jun 4, 2021

Any updates?

@porsager
Copy link
Owner

@maxpain There's a PR now, you're welcome to try out npm install porsager/postgres#esm

I still need to test this for all supported node versions using both cjs and esm before I can merge..

@porsager porsager mentioned this issue Jan 11, 2022
Merged
@elhananjair
Copy link

Hello friends I really wish this library supports CommonJS of importing packages using require, many libraries I am using here mainly support that.

@porsager
Copy link
Owner

It does 😉

@elhananjair
Copy link

It does 😉

ow wow, therefore I can use

const postgres = require('postgres')

const sql = postgres({ /* options */ }) // will use psql environment variables
export default SQL

This is very nice, can you please add this as an example to the documentation?
Thanks

@porsager
Copy link
Owner

porsager commented Jul 30, 2024 via email

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

Successfully merging a pull request may close this issue.

5 participants