Skip to content
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

Make exclusion similar to r.js #1697

Closed
robdodson opened this issue Nov 2, 2014 · 7 comments
Closed

Make exclusion similar to r.js #1697

robdodson opened this issue Nov 2, 2014 · 7 comments
Assignees

Comments

@robdodson
Copy link
Contributor

In r.js when you're creating module bundles you can tell one bundle to exclude everything that's in another bundle. Here's an example. I'm creating 3 bundles (common, main-about, main-contact). Instead of having to manually go through everything in common to find all of the dependencies and exclude each as a regex, I can just tell the main-about and main-contact bundles to exclude all of the modules in common. This makes it very easy to lazy load AMD bundled modules and I think imports could use a similar approach.

@ebidel
Copy link
Contributor

ebidel commented Nov 3, 2014

Seems like we need a flag (e.g. --remove or --exclude-strip) that's different than --exclude currently is, but that actually can remove an import from a bundle. This would be super useful for us. I would use it in a heartbeat. Our current bundled app segments leaving out a few reused/shared imports. This makes the bundle have several unoptimized segments. Instead, we could move those shared imports to the main app vulcanized bundle.

@robdodson
Copy link
Contributor Author

@ebidel I think that's captured on this ticket: https://github.com/Polymer/vulcanize/issues/66

Specifically I'm asking if we can do away with the regex in excludes.imports and instead point it at other vulcanized bundles.

ex:

excludes: ['foo.vulcanized.html', 'bar.vulcanized.html']

In the above example, let's say I'm creating a file called baz.vulcanized.html, it would exclude/remove any links or scripts that it finds in foo.vulcanized.html and bar.vulcanized.html.

@ragingwind
Copy link
Contributor

Great, I agree with this approach. Actually I'm developing a new tool for modular vulcanize. :) :( Anyway If we could make a bundled it that I can use the bundle like as a static library in native environments.

In my use case, that is development Chrome apps:

after bower install, I bundled polymer and installed any web-components to polymer-cores.html, polymer-papers.html and 3rd-party-components.html, then I import them to my custom component and I write a my custom component html with external scripts. I don't have to do 'vulcanzie --csp` every time for a while development chrome apps and have more benefit .

@ragingwind
Copy link
Contributor

We could improve config file to supports more options that can be similar to Makefile. see below.

{
    "options": {
        "csp": "true"
    },
    "vulcanize": {
        "app/components.html": {
            "imports": [
                // specific import
                "component/core-toolbar/core-toolbar.html,
                // regex or glob pattern
                "component/paper-(fab|icon-button|ripple)/*.html
            ]
        },
        "app/foo.html": [
            output: "app/foo.vulcanized.html",
        ],
        "app/bar.html": [
            output: "app/bar.vulcanized.html",
        ],
        "app/baz.html": [
            output: "app/baz.vulcanized.html",
            excludes: [(foo|bar).vulcanized.html]
        ]
    }
}

In first step, Vulcanize would create a component.html which has shared imports. other custom-elements in app could be imported the 'component.html'. and it should be supported multiple vulcanize execution with various options.

@dfreedm
Copy link
Member

dfreedm commented Nov 3, 2014

This approach would require that vulcanize keep some sort of metadata about what each vulcanized bundle contains. That information is not stored anywhere currently. Where should that metadata go? It can either be in the output file as a special comment, or as a separate file.

@dfreedm dfreedm self-assigned this Nov 5, 2014
@dfreedm
Copy link
Member

dfreedm commented May 22, 2015

Vulcanize 1.x exclusion includes transitive dependencies via hydrolysis.

@dfreedm dfreedm closed this as completed May 22, 2015
@amitnavale
Copy link

:) now I am running into an issue which I guess you guys have envisioned earlier.
I really like the idea of excludes: ['foo.vulcanized.html', 'bar.vulcanized.html'].
Do we have this implemented yet?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants
@dfreedm @aomarks @ragingwind @ebidel @robdodson @amitnavale and others