Giter Club home page Giter Club logo

rollup-plugin-riot's Introduction

Rollup Plugin for Riot

Build Status NPM version NPM downloads MIT License

Compiles tag files within rollup processes.

Important

If you are using Riot.js < 4.0.0 please check the v3 branch

Installation

npm install rollup-plugin-riot @riotjs/compiler -D

Requires @riotjs/compiler > 4.x.x and Rollup v1.x.x or above.

Usage

import riot from 'rollup-plugin-riot'
export default {
  input: 'src/main.js',
  output: {
    file: 'dist/bundle.js',
  },
  plugins: [riot()],
}

Options

You can specify some options:

import riot from 'rollup-plugin-riot'
const options = {
  ext: 'html',
}
export default {
  input: 'src/main.js',
  output: {
    file: 'dist/bundle.js',
  },
  plugins: [riot(options)],
}
  • ext: extension of tag file (default is 'riot')
  • include: a minimatch pattern for including files.
  • exclude: a minimatch pattern for excluding files.

And other options of @riotjs/compiler could be used.

Recipes

rollup-plugin-riot's People

Contributors

amarcruz avatar anonimusprogramus avatar c-rack avatar cognitom avatar dependabot[bot] avatar gianlucaguarini avatar greenkeeper[bot] avatar greenkeeperio-bot avatar vovkasm avatar

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

rollup-plugin-riot's Issues

An in-range update of postcss-cssnext is breaking the build 🚨

Version 3.0.1 of postcss-cssnext just got published.

Branch Build failing 🚨
Dependency postcss-cssnext
Current Version 3.0.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As postcss-cssnext is “only” a devDependency of this project it might not break production or downstream projects, but “only” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this 💪

Status Details
  • continuous-integration/travis-ci/push The Travis CI build could not complete due to an error Details

Release Notes 3.0.1
  • Fixed: specify the actual require peer dependency for caniuse database (caniuse-lite is used since latest caniuse-api latest major bump)
    (@MoOx)
  • Fixed: bump dependencies not updated to PostCSS@6
    (#401 - @MoOx)
Commits

The new version differs by 5 commits.

  • 7730660 3.0.1
  • 483b81f Fixed: specify the actual require peer dependency for caniuse database (caniuse-lite is used since latest caniuse-api latest major bump)
  • 50557fa Fixed: bump dependencies not updated to PostCSS@6
  • efb7100 Update babel config + some devDeps to be able to build website
  • 69169ac update package-lock.json to 3.0.0

See the full diff

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

Failure to parse multiline import statement

OK

<tag>
  <script>
    import { spawn } from 'child_process'
  </script>
</tag>

ERROR

<tag>
  <script>
    import {
      spawn
    } from 'child_process'
  </script>
</tag>

Error parsing ~/examples/rollup/src/md.tag: Unexpected token (2:4) in ~/examples/rollup/src/md.tag

Typescript as Preprocessor

Hi Gianluca,

thanks for your great work!

Is there any example how to use Typescript in RIOT components?

My approach so far:

rollup.config.js

...
import {registerPreprocessor} from '@riotjs/compiler'
import * as ts from 'typescript'
...
registerPreprocessor('javascript', 'ts', function (code, {options}) {
    const {file} = options

    const result = ts.transpileModule(code, { // doesnt find "transpileModule"
        fileName: file,
        compilerOptions: {
            module: ts.ModuleKind.ESNext
        }
    })

    return {
        code: result.outputText,
        map: null
    }
})
...
plugins: [
...
    riot(),
...
]

src/components/test.riot

<test>
    <script type="ts">
        const a :number = 123
    ...

Yes, I found this rollup config file but it doesn't show how to render TypeScript. My approach fails on the use of the TypeScript library. May I have a small hint on that?

Cheers.

Feedback from rollup/rollup#459

Rather than add a bunch of noise to rollup/rollup#459, I figured I'd add some feedback here. This isn't necessarily things related only to rollup, but just things I noticed while looking through the repo:

  • package.json is missing a files entry, so all the files in the directory are published. You should have an entry like this: "files": [ "dist/" ] (README.md and LICENSE.txt will automatically be included)
  • dist probably shouldn't be checked in. I usually add it to .gitignore.
  • The fragment import riot from 'riot'; is probably not what you really want there, but import * as riot from 'riot'; since the expected output uses properties of riot e.g. riot.tag2. Better still would be to import { tag2 } from 'riot'; and have the riot compiler generate a call to tag2 by itself.

"default is not exported" when trying to recreate riot 4 quick start

I've been trying to set up the riot 4 quick start using rollup, but it throws me this error. Output looks like:

$ rollup -c

src/main.js → stdout...
(!) Unresolved dependencies
https://rollupjs.org/guide/en#warning-treating-module-as-external-dependency
riot (imported by src\main.js, src\try-app.riot)
[!] Error: 'default' is not exported by src\try-app.riot
https://rollupjs.org/guide/en#error-name-is-not-exported-by-module-
src\main.js (2:7)
1: import * as riot from 'riot';
2: import TryApp from './try-app.riot';
          ^
3:
4: riot.component(TryApp)(document.getElementsByTagName('try-app'), { message: 'uh' });
Error: 'default' is not exported by src\try-app.riot
    at error (C:\dev\try-riot-4\node_modules\rollup\dist\rollup.js:3766:30)
    at Module.error (C:\dev\try-riot-4\node_modules\rollup\dist\rollup.js:14611:9)
    at handleMissingExport (C:\dev\try-riot-4\node_modules\rollup\dist\rollup.js:14538:21)
    at Module.traceVariable (C:\dev\try-riot-4\node_modules\rollup\dist\rollup.js:14880:17)
    at ModuleScope.findVariable (C:\dev\try-riot-4\node_modules\rollup\dist\rollup.js:13582:37)
    at Identifier.bind (C:\dev\try-riot-4\node_modules\rollup\dist\rollup.js:11415:40)
    at CallExpression.NodeBase.bind (C:\dev\try-riot-4\node_modules\rollup\dist\rollup.js:10439:31)
    at CallExpression.bind (C:\dev\try-riot-4\node_modules\rollup\dist\rollup.js:11531:31)
    at CallExpression.NodeBase.bind (C:\dev\try-riot-4\node_modules\rollup\dist\rollup.js:10443:23)
    at CallExpression.bind (C:\dev\try-riot-4\node_modules\rollup\dist\rollup.js:11531:31)

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

I attempted to add a export default {} to the tag, but it just throws the ES6 "can't export there" error instead.

Any ideas what I'm doing wrong (or is the rollup plugin not ready for riot 4? it seems to be....)?

Thanks!

also, I attached my code if anyone wants to take a look:
try-riot-4.zip

Sourcemap is likely to be incorrect

Using the plugin without options (riot()), I have the following warning from rollup:

Sourcemap is likely to be incorrect: a plugin was used to transform files, but didn't generate a sourcemap for the transformation. Consult the plugin documentation for help
https://github.com/rollup/rollup/wiki/Troubleshooting#sourcemap-is-likely-to-be-incorrect

Any help? Thanks.

Cannot set extension to "tag.html"

I used to use extension ".tag.html" by plugin-settings to make Riot tag files, but at v4, rollup shows error that "Unexpected token (Note that you need plugins to import files that are not JavaScript)". It goes well when I change the extension into "html".

riot.config.js

export default {
  hot: false,
  extension: 'tag.html'
}

rollup.config.js

import riot  from 'rollup-plugin-riot'
...
plugins: [
    riot({
      ext: 'tag.html'
    }),
]

Thanks.

Good bye, Babel

To fix the test on Travis, I've removed the dependencies related to Babel. Maybe we could fix them, but bit time-consuming. Instead of that, here're some changes made:

Bublé is much simpler alternative of Babel. For simple modules like rollup-plugin-riot, it's enough and faster option.

v1.0?

It's time to upgrade, I think 😉

README should reflect current Rollup config format

The config example using entry and what not threw me for a bit of a loop for a minute. I think this config format was for an older version of Rollup? It would be helpful to use the current version, with input and output.

how to use it with pug templates

Got an error while processing a pug tag. In my rollup.config.js I'm passing template:'pug' as a parser option. pug is installed globally on my machine.

[!] Error: Unexpected token                                                                                                                 
src/tags/signup/template.static.pug (3:16)                                                                                                  
1: import riot from 'riot';signup                                                                                                           
2:     script
3:         include signup.js
                   ^
4:     form(onsubmit="{doSignUp}")
5:         .form-group

function inputFileToConfig(input) {
    var ret = {
        entry: input,
        dest: input.replace('src', 'build'),
        format: 'iife',
        sourceMap: 'inline',
        plugins: [
            resolve({
                jsnext: true,
                main: true,
                browser: true,
            }),
            commonjs(),
            riot({
                ext: 'pug',
                parserOptions: {
                    template: 'pug'
                }
            }),
            replace({
                'process.env.NODE_ENV': JSON.stringify('')
            }),
        ]
    }
    return ret;
};
module.exports = inputFiles.map(inputFileToConfig);

Failed to parse a tag if inline styling were used

Hello,

My app uses a tag
<my-tag style="height:{height}px"> <my-tag>
Riot compiler makes its work fine, while rollup plugin fires an error. If instead of inline styling I'm using a class={myclass:condition} notation, all worked fine though.

Mikhail

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.