ember-intl / ember-intl

Internationalization for Ember projects
https://ember-intl.github.io
MIT License
434 stars 167 forks source link

Rebuild not working with embroider (translation file changes will be ignored) #1544

Closed mkszepp closed 6 months ago

mkszepp commented 3 years ago

When i add/edit a translation the rebuild with embroider is not working. There is always necessary to stop an restart ember s.

Original issue: https://github.com/embroider-build/embroider/issues/718

Environment

Steps to Reproduce

  1. npm install -g ember-cli
  2. ember new test-app
  3. npm i @embroider/core @embroider/compat @embroider/webpack
  4. edit ember-cli-build.js (specified in Readme.md)
  5. ember install ember-intl + required file changes (see ember-intl quickstart)
  6. ember s
  7. modify a translation file

Workaround

Set environment variable EMBROIDER_REBUILD_ADDONS=ember-intl

Originally posted by @ef4 in https://github.com/embroider-build/embroider/issues/718#issuecomment-796914941

It looks like ember-intl considers your translations part of itself (they live inside it's own module namespace instead of the app's).

Try setting the environment variable EMBROIDER_REBUILD_ADDONS=ember-intl. That will probably work around this problem.

ember-intl should consider refactoring so that translations stay in the app's module namespace.

jasonmit commented 3 years ago

Embroider isn't officially supported.

Someone would need to port the addon's use of treeForAddon to treeForApp and change how the translations are loaded into the app to read from the app namespace by introducing a new loading strategy.

ef4 commented 3 years ago

Embroider isn't officially supported.

Embroider the build tool isn't yet, but embroider the addon format is, and we're talking about addon behavior here. So it would be good to collaborate on a plan for how ember-intl can conform to that spec, or what extensions to the spec will be required before it can switch over.

Someone would need to port the addon's use of treeForAddon to treeForApp.

When somebody chooses to spend time on this issue, I would suggest against that approach. I don't actually know if it solves the rebuild problem, and treeForApp itself is really a backward-compatibility feature that Ember is starting to move away from. Letting every library copy code directly into your app leads to a lot of hard-to-understand behavior, both for humans and for compilers.

jasonmit commented 3 years ago

Embroider the build tool isn't yet, but embroider the addon format is

I was referring to ember-intl not officially supporting it

treeForApp itself is really a backward-compatibility feature that Ember is starting to move away from.

I've been inactive in the Ember community, first time hearing of this. Seems like a significant change in direction for addons.

ef4 commented 3 years ago

To be clear, it's not imminent. I don't think anybody needs to rush into doing anything, and no support is going to get dropped any time soon.

But taking the holistic view of recent RFCs like strict mode templates plus the embroider one linked above, it's pretty clear to me that new feature development is avoiding the runtime resolver, and that's what motivates treeForApp in the first place.

I'm totally supportive of addon authors taking a wait-and-see approach until they get clear enough guidance. I only brought up the future compatibility concerns in the context of "if you were going to rewrite anyway..".

jasonmit commented 3 years ago

https://github.com/ember-cli/ember-cli/pull/9495 is going to bring embroider into ember-cli and then ~6 weeks out it'll hit stable. We'll want to come up with a strategy around this soon.

NullVoxPopuli commented 2 years ago

would it make sense to provide an unplugin for intl for the build stuff? that way ember-intl is then mostly the service, helper, and then maintains the unplugin for folks to put in their webpack/vite/etc configs?

lifeart commented 9 months ago

This plugin should work https://github.com/lifeart/demo-ember-vite/blob/master/plugins/i18n-loader.ts, it's generates translation files on the fly as virtual module.

ijlee2 commented 6 months ago

Closing this issue, as I don't see a rebuild issue in docs/my-app and there isn't a reproduction repo in the original message. It's possible that the error had occurred under different assumptions back in 2021.

mkszepp commented 6 months ago

confirm that works now without EMBROIDER_REBUILD_ADDONS=ember-intl maybe refacoring in embroider has resolved