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

fix: add support for Bun #250

Merged
merged 1 commit into from
Jul 27, 2023
Merged

fix: add support for Bun #250

merged 1 commit into from
Jul 27, 2023

Conversation

muan
Copy link
Contributor

@muan muan commented Jul 26, 2023

Ref: #181

Minimum test file:

// test.js
import { Eta } from 'eta'
const eta = new Eta({ views: 'views' })
console.log(eta.render('index'))
// views/index.eta
hello

When running with Node node test.js

hello

When running with Bun bun run test.js

2 |         var r = [null];
43 |         r.push.apply(r, e);
44 |         var a = new (Function.bind.apply(t, r));
45 |         return n && i(a, n.prototype), a;
46 | 
47 |       }, a.apply(null, arguments);
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     ^
Eta Error: Failed to get template 'index'
      at a (/Users/muan/Code/testz/node_modules/eta/dist/browser.umd.js:1:1170)
      at n (/Users/muan/Code/testz/node_modules/eta/dist/browser.umd.js:1:1523)
      at new e (/Users/muan/Code/testz/node_modules/eta/dist/browser.umd.js:1:2051)
      at F (/Users/muan/Code/testz/node_modules/eta/dist/browser.umd.js:1:7263)
      at O (/Users/muan/Code/testz/node_modules/eta/dist/browser.umd.js:1:7464)
      at /Users/muan/Code/testz/test.js:3:12

Note the /dist/browser.umd.js. This is due to how bun resolves files. It's simply by the order of exports keys and it's only if exports does not exist does it fallback to module.

I can't seem to track down a relevant issue in Bun so this is the best I can come up with for now. 🤷🏻‍♀️ Tracked oven-sh/bun#2357.

With this fix direct applied inside of node_modules/eta, the template file resolution is fixed.

@nebrelbug
Copy link
Collaborator

@muan wow, this is a fascinating issue! Thank you for contributing a fix.

Will you amend your last commit message or create a new commit message to align with the Commitizen spec? i.e., fix: remove bun as a key and reorder instead or feat: add Bun support. This is required for the build to pass.

I'll then be happy to merge this!

@muan
Copy link
Contributor Author

muan commented Jul 27, 2023

I've squashed them and amended the commit message. 👍🏻 Thanks for the quick turnaround.

@nebrelbug nebrelbug changed the title Add support for Bun fix: add support for Bun Jul 27, 2023
@nebrelbug nebrelbug merged commit acea87c into eta-dev:main Jul 27, 2023
2 checks passed
@nebrelbug
Copy link
Collaborator

@muan thank you! Just merged and will release a new minor version.

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

Successfully merging this pull request may close these issues.

None yet

2 participants