Skip to content
This repository has been archived by the owner on Jul 30, 2018. It is now read-only.

@dojo/has Plugin #142

Closed
kitsonk opened this issue May 18, 2017 · 1 comment
Closed

@dojo/has Plugin #142

kitsonk opened this issue May 18, 2017 · 1 comment

Comments

@kitsonk
Copy link
Member

kitsonk commented May 18, 2017

Enhancement

Part of the original vision for @dojo/has was that as part of the build process, code could be built out by providing a set of static flags to assert during the build process removing the run-time evaluation of the feature flag and instead substituting the build time assertion.

Therefore the HasPlugin would take something like the below:

import has from '@dojo/has/has';

if (has('foo')) {
  console.log('foo');
}
else {
  console.log('bar');
}

And where the feature 'foo' would be set to true at build time would generate:

import has from '@dojo/has/has';

if (true) {
  console.log('foo');
}
else {
  console.log('bar');
}

Which would during minification get rewritten as:

console.log('foo');

Also, from a consumer API, we should provide an abstraction that allows the user to build without having to understand the details of the flags. We would provide several pre-configured sets of flags which would be reduced to the final set being passed to the plugin. From an end users perspective it would operate something like this:

$ dojo build --target=ie11
$ dojo build --target=ie11,es2015
$ dojo build --target=touch,es2016
@kitsonk
Copy link
Member Author

kitsonk commented May 18, 2017

This should also make it possible for us to eliminate the @dojo/shim/native/* modules. As if we ensure our non-native modules take the static flags appropriately, the blocks defining the shim code should elide in a final build, meaning that we wouldn't have to substitute modules (which we don't have a solution for at the moment anyways). While this does not deal with syntactical targeting, it does deal with functional targeting which is the bigger impact on the build size anyways. (Though as @matt-gadd has identified, the shims aren't significant parts of a build anyways).

@dylans dylans added this to the 2017.06 milestone May 19, 2017
@dylans dylans added the beta3 label May 19, 2017
@dylans dylans modified the milestones: 2017.06, 2017.07 Jul 4, 2017
@dylans dylans modified the milestones: 2017.07, 2017.08 Jul 29, 2017
kitsonk added a commit that referenced this issue Aug 30, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants