isuslov / polymer-auto-import Goto Github PK
View Code? Open in Web Editor NEWScript that checks web components used in your .html file and tries to import definitions automatically
License: MIT License
Script that checks web components used in your .html file and tries to import definitions automatically
License: MIT License
Support for pages which have <html>
<head>
tags. Right now we support only polymer elements.
Right now the script removes all existing imports and creates new.
Instead of this it is better to save all unused
imports under special comment
<!--UNUSED DIRECTLY-->
Also if import already exists it is important to preserve all its attributes.
subj
Right now <iron-icon icon="menu"></iron-icon>
is not resolved to import
<link rel="import" href="/components/iron-icons/iron-icons.html">
Should be:
icon
should be checked:
:
, standard iron-icons should be imported:
, than specific icon set should be imported with the name of namespace.Handle <style>
include
attribute
Script can not resolve last value in array where comma stays after last element :
behaviors: [
Polymer.NeonAnimationRunnerBehavior,
Polymer.NeonAnimatableBehavior,
]
it tries to resolve to neon-animatable-behavior,
Right now we take first and last import tag and remove everything between them including first and last tag. We should go smart and affect to only import tags.
Handle effects attribute.
To import behaviors we can look at behaviors array and normalize last word from right.
For example Polymer.IronResizableBehavior
should become IronResizableBehavior
and then de-camelcased to iron-resizable-behavior.html
for look up.
MyNamespace.Something.SomeBehavior
to some-behavior.html
.
Right now iron-icon is resolved to bower_components/iron-icon/test/iron-icon.html
.
We should avoid test
folders.
Currently animations are ignored.
What could be done:
entry-animation
and exit-animation
attributes.animationConfig
propertyIf a snippet has deep
calls like this Something.Something
or this.$.lalala
-> we will get ReferenceError
when polymer-auto-import will try eval
it.
Optionally there should be ability to path rootPath (path to the root of the project) and config.json file path for configuration this way:
For second and third arguments should be this rule:
-If argument exists and is a directory, treat it as root path of the project.
-if argument exists and is .json file, treat it as config file.
Default config contains following properties:
{
"rootDir": "",
"bowerFolderName": "bower_components",
"ignoredFolders": ["test", "demo"],
"ignoredComponents": [],
"attributes": [
"effects",
"entry-animation",
"exit-animation"
],
"resolve: {
"iron-flex": "iron-flex-layout-classes",
"iron-flex-reverse": "iron-flex-layout-classes",
"iron-flex-alignment": "iron-flex-layout-classes",
"iron-flex-factors": "iron-flex-layout-classes",
"iron-positioning": "iron-flex-layout-classes"
}
}
When property in custom config exists, default property should be overridden. No merge.
If script can not find polymer.json it means it can not find root dir of the project which is critical, so a error should be thrown.
hey! Are you still using this yourself? Would love it for Polymer 3, shouldn't be so different. The paths basically stayed the same, gotta use es6 imports now instead though. What do you think?
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.