emberjs / ember-optional-features Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
When used within an addon (done by default in Ember 3.4.0-beta.1) we should detect from tests/dummy/config/optional-features.json
(instead of config/optional-features.json
).
On a project without a lockfile, npm install
with a package.json with "ember-cli": "^3.4.1"
and "@ember/optional-features": "^0.5.2"
ends up with [email protected]
and @ember/[email protected]
. This combination goes ๐ฅ with optionFeatures.isFeatureEnabled is not a function
from within ember-cli
.
Discussed with @rwjblue and he suggested backporting isFeatureEnabled
After disabling application-template-wrapper
, the top-level wrapper div is still rendered and the application is still nested under it.
ember install @ember/optional-features
ember feature:disable application-template-wrapper
config/optional-features.json
{
"application-template-wrapper": false
}
application.hbs
<div class="ember-view">
{{!-- The following component displays Ember's default welcome message. --}}
{{welcome-page}}
{{!-- Feel free to remove this! --}}
{{outlet}}
</div>
ember-cli: 3.1.0-beta.1
node: 8.7.0
os: darwin x64
DEBUG: -------------------------------
DEBUG: Ember : 3.1.0-beta.2
DEBUG: Ember Data : 3.1.0-beta.1
DEBUG: jQuery : 3.3.1
DEBUG: -------------------------------
Here is a link to the ember app I set up for this: https://github.com/dorilla/ember-test-no-wrap
Thanks for your help! And I'm assuming i did something wrong somewhere in my setup, any help is appreciated.
It appears that the codemod implementation only runs against components in the app/
directory, which will not work for addons, which store their components in the addon/
directory and may not re-export them at all (since doing so is dangerous and a bad pattern). In order for addons to successfully enable this feature, the codemod needs to be able to create backing classes for addon components.
ember-cli: 3.7.1
node: 10.15.0
os: darwin x64
optional-features addon: 0.7.0
ember install @ember/optional-features
ember feature:enable jquery-integration
โ test-addon git:(master) โ node_modules/.bin/ember feature:enable jquery-integration
Enabled jquery-integration. Be sure to commit config/optional-features.json to source control!
โ test-addon git:(master) โ cat tests/dummy/config/optional-features.json
{
"jquery-integration": true
}
template-only-glimmer-components
โ test-addon git:(master) โ node_modules/.bin/ember feature:enable template-only-glimmer-components
Enabled template-only-glimmer-components. Be sure to commit config/optional-features.json to source control!
โ test-addon git:(master) โ cat tests/dummy/config/optional-features.json
{
"template-only-glimmer-components": true
}
At times, addons will need to know if specific optional features are enabled or not. With the current architecture it is only possible to detect at runtime via window.EmberENV._SOME_FLAG_HERE
, but we should not encourage that type of coupling to EmberENV
.
As I see it we have a few options:
@ember/optional-features
module that can be imported and checked for various opt-in's. This would allow consumers to use an import and conditionals in their code based on a given optional flag value.@ember/optional-features
as a direct dependency. This babel plugin would provide custom build time replacement of @ember/optional-features
based conditionals, and would therefore allow addons to include support for multiple variations of features without bloating the total asset size.Hi, in the readme of this addon, it's written
It is intended for use with apps only not addons.
Is there a way to hide the warning in the addon package (and also engine package)? Currently I'm seeing this warning in console.
DEPRECATION: The integration of jQuery into Ember has been deprecated and will be removed with Ember 4.0. You can either opt-out of using jQuery, or install the `@ember/jquery` addon to provide the jQuery integration. Please consult the deprecation guide for further details: https://emberjs.com/deprecations/v3.x#toc_jquery-apis
Thank you
This flag is not a simple boolean, so it would probably require some redesign/refactor to make it work.
Apparently
ember-optional-features/commands/index.js
Line 27 in 0bc704f
this.project
However this
is a command, and it does not have a project
property, event when it should.
I've included the @ember/optional-features
in the addon's package.json. And I've tried creating a config/optional-features.json
in the root directory of addon. Still no dice.
Edit:
I realized I haven't explained it in detail. I have a few template only components (or partials) that I am trying to use in the in of the addon templates. I couldn't find any documentation to include template only components into the application. I keep running into <component-name>
is not a helper.
I suspect that the component files aren't being included in the application. I've read this issue and it's still not clear how to include a template that is not backed by a js
file.
2nd Edit:
This is what my package.json looks like:
"name": "ember-wizard",
"dependencies": {
"@ember/optional-features": "^0.5.2",
"babel-plugin-htmlbars-inline-precompile": "^0.2.4",
"ember-cli-babel": "^6.8.2",
"ember-cli-htmlbars": "^2.0.3",
"ember-cli-htmlbars-inline-precompile": "^1.0.0"
}
Each time this one of feature:enable, feature:disable commands is executed, optional-features.js file is updated (existing key: value in the file are replaced with the new one) not appended. This caused a bit of a heartache for me as it put me in a loop for a bit. ๐ I had to manually edit the file and the key:values to the object inside it.
Currently, enabling template-only-glimmer-components
will act like any TypeScript components (i.e., app/components/x-foo.ts
) are template-only components because
If a correctly-named TS file is found, it's a pretty strong sign that this isn't a template-only situation
[email protected]
shows the following for further information. The rendered rfc link however ends up in a 404:
default-async-observers (Default: false)
Makes all observers asynchronous (unless manually indicated as synchronous when calling addObserver/observes).
More information: https://github.com/emberjs/rfcs/pull/494
Should we change the rfc link to the archive (assuming this is the official archive - just found the link through google)?
https://emberjs.github.io/rfcs/0494-async-observers.html
app/components/foo.hbs
is not handled by ember feature:enable template-only-glimmer-components --run-codemods
I don't get a warning or a generated class component for these components.
The presence of process.env.EMBER_OPTIONAL_FEATURES
should override config/optional-features.{js,json}
.
This mechanism will be how ember-try scenarios can test different configurations...
As part of Ember.js RFC #0800, this package needs to supply type definitions. Preferably, this would happen by converting to TS and generating from the source; as an alternative, it can publish ambient types (presumably starting with the ones on DefinitelyTyped).
All the members of the Typed Ember team are happy to advise on how to do this; feel free to reach out in #dev-typescript on Discord if you have questions!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.