Coder Social home page Coder Social logo

parcel-plugin-surplus's Introduction

Parcel Surplus Plugin

A parcel plugin to compile your Surplus JSX views.

Build Status JavaScript Style Guide

Usage

$ npm install --save-dev parcel-plugin-surplus

example

For TypeScript users

To work with TypeScript it's necessary to add in your tsconfig.json the jsxFactory prop:

{
  "compilerOptions": {
    ...
    "jsx": "preserve",
    "jsxFactory": "Surplus",
  }
}

parcel-plugin-surplus's People

Contributors

tinchoz49 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

parcel-plugin-surplus's Issues

Compilation error when compiling .tsx with generics.

Hi, I think I found a bug, but it might be just misconfiguration.

I'm trying to use parcel with this plugin to bundle a Surplus.js app written in Typescript.
The problem can be reproduced with this tsx file:

import * as Surplus from "surplus";
let a: Array<number> = [1, 2, 3];

The error I get when trying to run parcel on this project:

project_path>yarn parcel build src/index.html
yarn run v1.7.0
$ project_path/node_modules/.bin/parcel build src/index.html
ร—  project_path/src/main.tsx: element missing close tag at line 1 col 12: ``<number> = [1, 2, 3];''
    at ERR (project_path/node_modules/surplus/compiler/index.js:374:15)
    at jsxElement (project_path/node_modules/surplus/compiler/index.js:165:17)
    at program (project_path/node_modules/surplus/compiler/index.js:92:31)
    at parse (project_path/node_modules/surplus/compiler/index.js:84:12)
    at Object.compile (project_path/node_modules/surplus/compiler/index.js:1540:45)
    at TSAsset.pretransform (project_path/node_modules/parcel-plugin-surplus/lib/surplus-asset.js:20:39)
    at TSAsset.process (project_path/node_modules/parcel-bundler/src/Asset.js:202:18)
    at <anonymous>
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

This seems like the tsx source is ran through the surplus compiler before being compiled by the ts compiler, and the surplus compiler thinking this is a JSX starting tag.

Do you think this is a bug, and if it is, can it be fixed?

Use with HMR?

Hi, do you have any tips on using surplus with parcel's HMR? At the moment I have their "hello world" example working, but every time I save it attaches a new element to the dom.

Ready to add to Surplus README?

I wanted to thank you for taking the time to make a Parcel plugin for surplus. Is this at a state where you think it's ready to be linked from the Surplus README page?

Please consider reducing the list of extensions to simply .jsx

Compiling all .js files means you must also be able to parse all language extensions, which is very much not the case. For example, using parcel-plugin-surplus prevents me from using mermaid anywhere in the project because regex parsing seems bugged.

Since Parcel doesn't really do "configuration" very well, it's hard for me to tell this plugin to ignore non-.jsx files.

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.