-
-
Notifications
You must be signed in to change notification settings - Fork 518
Vite Tracking Branch #2162
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
Merged
Vite Tracking Branch #2162
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
c612ed4
update addons-and-dependencies to be ready for Vite
mansona 1a932ca
fix lint
mansona 3c6c5a6
speed up running remark to lint files
mansona 86db0df
add new tutorial output
mansona 6a567aa
add assets
mansona 86ce08e
add TomTom to local dictionary
mansona 4c9068c
Merge pull request #2160 from ember-learn/addons-and-dependencies
mansona 271cb8d
Merge pull request #2161 from ember-learn/tutorial-vite
ef4 9f1e7da
chore: remove ember install references
jaredgalanis ad29daa
update testing index
mansona 366d0aa
update testing application to remove ember test command
mansona fc78791
fix typos
mansona 51c2aa9
stop showing the GJS warning on the vite branch
mansona b11497b
Merge pull request #2163 from ember-learn/remove-ember-install-refs
jaredgalanis 95d694e
chore: update build-targets and remove broccoli reference
jaredgalanis 8b01fe0
updating the quick-start for Vite
mansona 3c971e2
update build-targets
mansona 5b47d32
Merge pull request #2167 from ember-learn/quickstart
mansona 2bc1b3c
Merge pull request #2165 from ember-learn/remove-gjs-warning
mansona 5d5ea87
Merge pull request #2164 from ember-learn/update-ember-test
mansona 330c057
Merge pull request #2166 from ember-learn/update-build-targets-remove…
mansona 43863cb
add basic landing pages for Vite build systems
mansona 3d30369
fix lint and tests
mansona 87ae7e4
Merge pull request #2168 from ember-learn/build-tools
mansona 8befcfa
remove comments on gjsVersion config
mansona 9cdb491
Merge pull request #2171 from ember-learn/fix-gjs-versions
mansona File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| Ember supports two different build environments: | ||
|
|
||
| - Our [Vite integration](./vite) works on all Ember versions back to 3.28. It became the default for newly-generated apps at Ember 6.8. | ||
| - The legacy [ember-cli based build](https://cli.emberjs.com/release/) is also still supported on all Ember versions. | ||
|
|
||
| You can tell which one you're using based on the presence of `@embroider/vite` in your `package.json` file. | ||
|
|
||
| Existing apps can use [Ember Vite Codemod](https://github.com/mainmatter/ember-vite-codemod) to switch from the ember-cli based build to the Vite based build. | ||
|
|
||
| On Ember versions after 6.8, you can optionally choose to generate a new app using the older build environment via: | ||
|
|
||
| ```sh | ||
| npx ember-cli@ new my-app-name -b @ember-tooling/classic-build-app-blueprint | ||
| ``` | ||
|
|
||
|
|
||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| When you generate a new Ember app your default build system will be using Vite. | ||
|
|
||
| > Vite is a blazing fast frontend build tool powering the next generation of web applications. | ||
|
|
||
| You can read more about [Vite on their documentation](https://vite.dev/guide/) site. Ember's Vite implementation is [powered by Embroider](https://github.com/embroider-build/embroider), which acts as a Vite plugin that allows Vite to effectively build an Ember app. | ||
|
|
||
| ## Basic Usage | ||
|
|
||
| For most developers the only interaction that they will have with the build system is running the `npm start`, or `npm run build` scripts defined in their `package.json`. If you have a look at your `package.json` scripts you will see that they are just deferring to `vite` (which by default runs `vite dev` and starts the Vite dev server) and `vite build` respectively. | ||
|
|
||
| You can see more docs on these commands in the Vite documentation | ||
|
|
||
| ### Sensible defaults | ||
|
|
||
| As Ember developers we expect reasonable defaults, because of that we have provided a default vite config for you that takes care of most of the Vite configuration you need as an Ember developer. For example, we automatically include your `tests/index.html` in the `build.rollupOptions.input` when you are building in `develoment` mode so that you can navigate to http://localhost:4200/tests/ | ||
|
|
||
| For most applications you will not need to override the config that we provide by default, instead you can just add to the config as you need. If you do need to change the defaults that we provide, you can just define the new configuration in your `vite.config.js` because anything you define there will take precedence over anything we provide. | ||
|
|
||
|
|
||
| ### Integrating 3rd party plugins | ||
|
|
||
| Now that Ember uses Vite for its build system, you no longer need an Ember-specific plugin to augment your build. If you find a Vite or rollup plugin that you would like to use you can follow the installation instructions to add that to your `vite.config.js` without any Ember-specific instructions necessary. | ||
|
|
||
| ## Advanced Usage | ||
|
|
||
| Most developers will not need to change the defaults that we provide, but in some rare cases it can be useful to know how to change the defaults. | ||
|
|
||
| ### Running Tests Against Production Code | ||
|
|
||
| By default, we don't build your tests when you build for production. This is because, in most cases, people don't want their tests included in the bundle they ship to end-users. This means if you run `npm run build` in your app it will default to `--mode production` (because this is [the default for `vite build`](https://vite.dev/config/shared-options.html#mode)) and it will not include your tests in your build output. | ||
|
|
||
| If you needed to run your tests against your production environment for any reason (maybe you have a vite/rollup plugin that you only run during your production build) then you can use the `FORCE_BUILD_TESTS=true` environment variable. This is just a convenience in the code that the default `ember()` plugin provides, you can always define your inputs in the `vite.config.js` which will take precedent over anything we're doing automatically for you in the `ember()` plugin. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,39 @@ | ||
| Ember application builds are created by the Ember CLI build pipeline. Just as with your application code, | ||
| Ember CLI ships with a sensible set of defaults to compile and bundle the assets that can be deployed | ||
| to production. Under the hood, this is accomplished using a series of Broccoli plugins, each of which | ||
| can be configured in the `ember-cli-build.js` file at the root of your project. | ||
|
|
||
| Ember CLI uses [Babel.js](https://babeljs.io/) for the compile step in this process. If you've used Babel | ||
| before, you know that it comes with a large set of options, including the ability to configure | ||
| "targets"; i.e. the environments in which your application is expected to run. | ||
| For example, if your application is embedded in an [Electron app](https://www.electronjs.org), | ||
| you might only care about compiling for the latest Chromium build. Or if your app targets Enterprise | ||
| users, you may need to compile your JavaScript to older syntax that runs in IE11. | ||
|
|
||
| For any of these cases, you can configure `ember build` to do The Right Thing. You can read more about | ||
| this in [the Ember CLI Guides](https://cli.emberjs.com/release/advanced-use/build-targets/)! | ||
| By default, Ember apps are built with Vite. The toolchain uses Babel, esbuild, and Rollup so you can write current-generation JavaScript and TypeScript while still allowing your application to work with older browsers. | ||
|
|
||
| Rather than always compiling everything down to legacy syntax, Ember determines what—if anything—needs to be transformed based on the browsers you target. With today’s defaults aimed at evergreen browsers, many features (ES modules, classes, arrow functions, async/await, etc.) ship largely as-is. | ||
|
|
||
| Why does this matter? Over-transpiling to very old JavaScript increases bundle size, slows parsing, and in some cases can slow down the execution of your JavaScript code. As the Web platform has advanced and percentage of users on legacy browsers have decreased, Ember’s default targets avoid unnecessary transforms to keep apps smaller and faster. | ||
|
|
||
| If you need to update the defaults for any reason (i.e. need to target a very legacy browser), you can set the targets for your app and the compiler applies only the minimal transforms and polyfills required for those browsers. | ||
|
|
||
| If you open `config/targets.js`, you will find the following code: | ||
|
|
||
| ```javascript {data-filename=config/targets.js} | ||
| "use strict"; | ||
|
|
||
| const browsers = [ | ||
| "last 1 Chrome versions", | ||
| "last 1 Firefox versions", | ||
| "last 1 Safari versions", | ||
| ]; | ||
|
|
||
| module.exports = { | ||
| browsers, | ||
| }; | ||
| ``` | ||
|
|
||
| If you inspect your compiled code after running a build with `npm run build`, you'll see that many modern features (like arrow functions and async/await) preserved when your targets support them. | ||
|
|
||
| This feature is backed by [Browserslist](https://github.com/ai/browserslist) and [Can I Use](https://caniuse.com/). | ||
| These websites track usage stats of browsers, so you can use complex queries based on the user base of every browser. | ||
|
|
||
| If you want to target all browsers with more than a 4% market share in Canada, | ||
| you'd have the following options: | ||
|
|
||
| ```javascript {data-filename=config/targets.js} | ||
| module.exports = { | ||
| browsers: ["> 4% in CA"], | ||
| }; | ||
| ``` | ||
|
|
||
| It is very important that you properly configure the targets of your app so you get the smallest and fastest code possible. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The example above was changed to ember-concurrency, this install should have been updated to match the example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any chance I could ask you to PR the patch? 🙈 it's just on master now