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

Incompatible with the browser, tries to require fs #2

Closed
NullVoxPopuli opened this issue Jul 30, 2023 · 9 comments
Closed

Incompatible with the browser, tries to require fs #2

NullVoxPopuli opened this issue Jul 30, 2023 · 9 comments

Comments

@NullVoxPopuli
Copy link

the non-@babel/standalone dependencies, in particular @babel/core, attempts to load fs, which doesn't exist in the browser.

@patricklx
Copy link
Owner

patricklx commented Jul 30, 2023

Mmmm, there is a browser version: https://cdnjs.com/libraries/babel-core

Just need to look how to set it up to use that an include in in the target for browser and publish a hybrid package

@NullVoxPopuli
Copy link
Author

@babel/standalone is the babel-recommended way to use babel in the browser: https://babeljs.io/docs/babel-standalone

I'm not sure how you'd both use @babel/standalone and not depending on targets. maybe a small rollup plugin to swap out the imports when building for browser? idk.
The other thing is that both node and browser support ESM, and package.json#exports doesn't let you differentiate between node and browser. 🙃

@patricklx
Copy link
Owner

Ah, this happens when using esm in the browser. So publish a second version which is only for browser...

@patricklx
Copy link
Owner

@patricklx
Copy link
Owner

fixed in c43fa55.
you can now import via

import { } from 'ember-template-tag/browser-esm';

@patricklx
Copy link
Owner

patricklx commented Jul 31, 2023

The browser version also uses babel core and is built with webpack... It has a lower size than including standalone

@NullVoxPopuli
Copy link
Author

I gave this another go -- but was unsuccessful -- was the above change released? https://www.npmjs.com/package/ember-template-tag?activeTab=code
not seeing browser-esm anywhere

@patricklx
Copy link
Owner

it should also work if you add fs: false
here:
https://github.com/NullVoxPopuli/limber/blob/479380c7dc33cc9b44d74249e14f0b9a66fdc3c2/apps/repl/ember-cli-build.js#L123
Or import ember-template-tag/browser. Is that not in there?

@patricklx
Copy link
Owner

Yeah, forgot to build it... But with fs: false the size is smaller as the browser build includes glimmer as well.

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