Skip to content
This repository has been archived by the owner on May 22, 2024. It is now read-only.

Enable format option with aggregated-translations pre-build tool. #175

Closed
bjankord opened this issue Oct 1, 2018 · 2 comments · Fixed by #234
Closed

Enable format option with aggregated-translations pre-build tool. #175

bjankord opened this issue Oct 1, 2018 · 2 comments · Fixed by #234
Milestone

Comments

@bjankord
Copy link
Contributor

bjankord commented Oct 1, 2018

Feature Request

Description

We've had some users run into issues where the generated files we produce via the aggregated-translations pre-build tool don't work in IE as it uses ES6+ features not supported in that browser natively. In our webpack config, we run those files through babel, though people who are not using our webpack config may miss running these generated files through babel resulting in code that doesn't work in one of our supported browsers.

To help with this, I propose we add a format option to the aggregated-translations pre-build tool.
By default, format would be undefined and would result in the generated files using an ES5 format. Generated files would use var statements and functions instead of const statements and arrow functions. By making the default undefined, users wouldn't have to change anything in therir code to get a version of the generated file that will work in all browsers terra-ui supports.

By setting the format option to modern, we would generate a file that uses modern ES6+ features intended to be run through babel. I'm flexible on what name we use for value that enables this format, for now I went with modern.

Additional Context / Screenshots

This format option resolves an issue we saw recently. It also solves a compatibility issue we'd run into with trying to use aggregated-translations pre-build tool with create-react-app v2. CRA v2 prevents the use of require.ensure, which is what we use in our current generated files. When using the modern format, we would switch to use dynamic imports, which CRA v2 supports.

As we add this format option, we wouldn't need to add dynamic imports at the same time. We could enhance the modern format to use dynamic imports at a later date and just have the modern version generate files the same as we do currently with const and arrow functions.

@emilyrohrbough
Copy link
Contributor

What are the pros and cons of offering two types of generation? If there value to proving a modern generated version instead of always providing a generated version that doesn't need to be pre-compiled with babel?

@bjankord
Copy link
Contributor Author

bjankord commented Oct 1, 2018

The value in providing an option for a modern generated version is support with create-react-app v2.
The value in providing an option for a non-modern version, one that use ES5, is that people can use it and not have to configure babel to transpile it.

Pros:

  • Support wider use-cases (untranspiled and transpiled)

Cons:

  • Increase code-base complexity with needing to support 2 formats

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants