Giter Club home page Giter Club logo

web-components-loader's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

web-components-loader's Issues

Ensure web component JS files can be transpiled

...possibly <script> tags in imported HTML files too. This may be less important for WCs pulled in as dependencies, but for Web Components developed as part of the project, this may indeed be needed.

Unit tests

Probably easiest to use Jasmine for this, since I'm most comfortable with that particular library.

Initial docs

Include a few sample Webpack configs, covering a project with home-grown WCs, and a project with some home-grown WCs + 3rd-party WCs pulled in via package.json.

Allow inline `<script>` code to be transformed too

Building upon #2, which added the ability to transform WC JS files. This will take that one step further and allow <script> content inside of WC HTML files to be transformed as well.

  1. When parsing an HTML file, grab each <script> element without a src attribute.
  2. Call this.options.webComponentsLoader.transformJs (if available), passing the stringified contents of the <script>.
  3. Replace contents of <script> with output returned from transformJs when writing HTML file to output location.

Can I use web-components-loader together with typescript?

I would like to load web components that use typescript. Can I use web-components-loader loader in this scenario?
Currently I have the following setup:

webpack

module: {

    loaders: [{
            test: /\.ts?$/,
            loader: "awesome-typescript-loader",
            include: PUBLIC_DIR,
            exclude: /node_modules/
        },
        {
            test: /\.css$/,
            exclude: /node_modules/,
            loader: "style-loader!css-loader!autoprefixer-loader"
        },
        {
            test: /\.scss$/,
            loader: 'style-loader!css-loader!sass-loader'
        },
    ]

},

app.ts

/**
 * App
 */
export class App extends HTMLElement {

    constructor() {
        super();
    }

    connectedCallback() {
        this.innerHTML = this.template;
    }

    get template() {
        return `
        <div>This is a div</div>
        `;
    }
}
window.customElements.define('vs-app', App);

Why Append Ref Link to Head?

hi there, i noticed in the example, the web-component (WC) ref tag is appended to the body...
document.body.appendChild(importEl)

from a number of documentation i've read, WC ref tags are usually in the head tag. So i guess, the question is really why append to document.body?

Better output path determination

Currently, an output query param must be passed to the loader. This is used to determine where to store the outputted WC files and used to determine the path of the href returned by the loader for the HTML import. This is probably not ideal, since it is possible that this path is not the root of the public directory.

Instead, the logic should probably be as follows:

  • Output WC files to ${this.options.output.path}/web-components
  • Construct returned href path using ${this.options.output.publicPath}/web-components

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.