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

SNOW-1293653: ESM (ESModule) support #813

Open
cjnoname opened this issue Apr 2, 2024 · 6 comments
Open

SNOW-1293653: ESM (ESModule) support #813

cjnoname opened this issue Apr 2, 2024 · 6 comments
Assignees
Labels
enhancement The issue is a request for improvement or a new feature status-triage_done Initial triage done, will be further handled by the driver team

Comments

@cjnoname
Copy link

cjnoname commented Apr 2, 2024

What is the current behavior?

This package does not support ESM (ESModule)

What is the desired behavior?

This package should suport both CommonJS and ESModule

How would this improve snowflake-connector-nodejs?

More and more new projects are adopting ESM

@github-actions github-actions bot changed the title ESM (ESModule) support SNOW-1293653: ESM (ESModule) support Apr 2, 2024
@sfc-gh-dszmolka
Copy link
Collaborator

thank you for submitting this enhancement idea - team will consider it for later, as it is not in the plans for the near future.

@sfc-gh-dszmolka sfc-gh-dszmolka added enhancement The issue is a request for improvement or a new feature status-triage_done Initial triage done, will be further handled by the driver team labels Apr 2, 2024
@cjnoname
Copy link
Author

thank you for submitting this enhancement idea - team will consider it for later, as it is not in the plans for the near future.

Thanks dude!

@bienzaaron
Copy link

Would you accept a PR for this?

@sfc-gh-dszmolka
Copy link
Collaborator

as it is not in plans for the foreseeable future, if you however have the resources then it's indeed very much appreciated !

@maxtuzz
Copy link

maxtuzz commented Jul 8, 2024

Since most modern JS/TS codebases leverage ES Modules, could you at least provide documentation on how to update build config using commonjs/polyfill to be compatible?

EDIT: For those of you struggling to get this lib building and running in an ES Module based project. I'd recommend checking out Sequelize with their Snowflake experimental support. It uses this lib under the hood but provides good quality of life features on top of it such as using ESModule out of the box, it enables the use of async/await so you don't have to manage promise wrapping yourself (longest running feature request since 2018 on this lib) + you get the added benefit of adding types to your query results which is useful in Typescript based projects.

@phdesign
Copy link

Adding this shim to my esbuild options allows it work with ES Modules, but it's painful.

"banner": {
  "js": "import { createRequire } from 'module'; const require = createRequire(import.meta.url); import { fileURLToPath } from 'url'; const __filename = fileURLToPath(import.meta.url); import path from 'path'; const __dirname = path.dirname(__filename);"
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement The issue is a request for improvement or a new feature status-triage_done Initial triage done, will be further handled by the driver team
Projects
None yet
Development

No branches or pull requests

7 participants