0.0.6 • Published 7 years ago

superviews-loader v0.0.6

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

superviews.js loader for webpack

Options

argstr (string) (default=undefined)

same as superviews.js

mode (string) (default=cjs)

same as superviews.js

### astring (object) (default={})

same as Astring

Webpack 2 with ES 2015 Module Exports

export@MDN
export@ECMAScript 2015 Language Specification

Using superviews.js with mode:'es6', will convert template to ES2015 Module.

template

<template name="NAME" args="ARGS"></template>

result

import {patch, elementOpen, elementClose, text, skip, currentElement} from "incremental-dom"

var __target
                                                                                
export function NAME (ARGS) {
                                                                   
}

Its not export default function. So, you should use as a ES2015 Module, not as a function.

import { NAME as render } from 'superviews-loader?mode=es6!./template.html';
render(ARGS);

with babel-loader

src/root.html

<template name="render" args="itemlist">
    <div each="item, item.Id in itemlist" style="{...item.style}">
    </div>
</template>

src/index.js

import {render} from './root.html';

render([
    { Id:0, style:{ position:'absolute' } }
]);

.babelrc

{
  "presets": [
      ["es2015", { "modules": false }]
    ],
  "plugins": [
      "transform-object-rest-spread"
    ],
}

webpack.config.js

var path = require('path');
var root = path.resolve(__dirname, '.')
module.exports = {
  context: root,
  entry: './src/index.js',
  output: {
    path: path.join(root, 'dist'),
    filename: 'index.js',
    publicPath: './',
  },
  target: 'web',
  module: {
    rules: [
      {
        test: /\.html$/,
        use: [
          'babel-loader',
          {
            loader: 'superviews-loader',
            options: {
              mode: 'es6'
            }
          }
        ]
      }
    ]
  },
  devtool: 'source-map'
};
0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago