JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q25074F
  • License MIT

Single-file Component Loader

Package Exports

  • one-loader

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (one-loader) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

ComponentOne

A webpack loader to enable single-file React components. Inspired by vue-loader.

Usage

In webpack.config.js:

{
    module: {
        loaders: [
            {
                test: /\.one$/,
                loader: 'one-loader',
                options: {
                    map: {
                        css: 'style-loader!css-loader!',
                        react: 'babel-loader!'
                    }
                }
            }
        ]
    }
}

In ExampleComponent.one:

<style>
    html {
        background-color: green;
    }

    .basicExample {
        color: white;
    }
</style>

<script lang="react">
    export default () => {
        return <div className="basicExample">
            Hello World
        </div>
    }
</script>

Tips

Use .babelrc and postcss.config.js files to configure respective loaders.

Roadmap

  • Research: Extract CSS into separate file abilities
  • Tests: Create tests with Jest
  • Feature: Scoped styling and CSS Modules
  • Feature: React Native and SSR support via CSS2JS