27
loading...
This website collects cookies to deliver better user experience
npx @ember/octanify from which set some dependencies and flipped flags in optional-features.json
package.json
and feature flags in optional-features.json
. Optional features are one way that new features are rolled out in Ember apps without making breaking changes. When you are ready, you can opt into them, but if you are not ready, you aren't blocked from upgrading. Regular upgrading is critical for companies and teams that value getting security, bugfixes, and feature updates over long periods of time.optional-features.json
:{
"default-async-observers": true,
"jquery-integration": false,
"template-only-glimmer-components": true,
"application-template-wrapper": false,
}
jquery-integration: false
meant that instead of using this.$()
in our apps, we had to install @ember/jquery
and import jQuery individually - no problem. However, the jquery-integration
flag made us wonder, could we remove jQuery
from our app altogether? We were only using it in one place in our app, and doing so would cut some kb from our app.node_modules
for usages, but that would return a lot of false positives compared to a strategy that Chris Thoburn showed me.npx ember build
dist/
directory. Then, Chris was able to search for this.$
and Ember.$
and confirm that our app's addons did not need jQuery. This is better than searching node_modules
, since we are only checking for the use of jQuery in addon features we are actually using.ember-fetch
installed, it will use fetch
instead. It's important to install ember-fetch
in order to provide broad browser support for your fetch requests.import { action } from '@ember/object';
import Component from '@ember/component';
import jQuery from 'jquery';
export default class TableOfContents extends Component {
@action
toggle(type) {
jQuery(this.element)
.find('ol.toc-level-1.' + type)
.slideToggle(200);
}
}
# Start your app
npx ember serve
# Run the codemods
npx ember-cli-update --run-codemods
fpe
. This stands for "function prototype extension."ember serve
. Such codemods look at the built files in order to infer the correct changes to make. This is possible through a strategy called telemetry, via ember-codemods-telemetry-helpers
.ember-modules-codemod
, we encountered an error. The codemod helpfully told us which line it failed on:titleToken(model) {
return model?.fn?.name;
}
?.
syntax. Optional chaining is a feature of JavaScript that was added after these codemods were initially written.jsconfig.json
from our app's .gitignore
, and then configured VSCode to stop yelling about decorators in jsconfig.json
:{
"compilerOptions": {
"experimentalDecorators": true
},
}
link-to
:// before codemod
{{#link-to
data-test-uses-link
(concat parentName section.routeSuffix)
model.project.id
model.projectVersion.compactVersion
model.name
item.name
(query-params anchor=item.name)}}
{{item.name}}
{{/link-to}}
// after codemod
<LinkTo @route={{concat this.parentName section.routeSuffix }} @models={{array this.model.project.id this.model.projectVersion.compactVersion}} @query={{hash anchor=item.name}}>
// correct
/ember-data/3.26/classes/Ember.Inflector/methods/singular?anchor=singular
// incorrect
/ember-data/3.26/classes/ember-data/methods/3.26?anchor=singular
tracked
. Thanks for reading!27