diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..c380e58 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,34 @@ +# EditorConfig helps developers define and maintain consistent coding styles between different editors and IDEs. +# Requires EditorConfig JetBrains Plugin - http://github.com/editorconfig/editorconfig-jetbrains + +# Set this file as the topmost .editorconfig +# (multiple files can be used, and are applied starting from current document location) +root = true + +[{package.json}] +indent_style = space +indent_size = 2 + +# Use bracketed regexp to target specific file types or file locations +[*.{js,json}] + +# Use hard or soft tabs ["tab", "space"] +indent_style = space + +# Size of a single indent [an integer, "tab"] +indent_size = tab + +# Number of columns representing a tab character [an integer] +tab_width = 4 + +# Line breaks representation ["lf", "cr", "crlf"] +end_of_line = lf + +# ["latin1", "utf-8", "utf-16be", "utf-16le"] +charset = utf-8 + +# Remove any whitespace characters preceding newline characters ["true", "false"] +trim_trailing_whitespace = true + +# Ensure file ends with a newline when saving ["true", "false"] +insert_final_newline = true diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c209e54 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +node_modules +*.log +.DS_Store +lib +esdocs +coverage diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..a38661a --- /dev/null +++ b/.travis.yml @@ -0,0 +1,9 @@ +sudo: required +language: node_js +node_js: + - 4.2 + - stable +before_script: + - npm run link +after_success: + - npm run build diff --git a/LICENSE b/LICENSE index 9518836..ed56f05 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2016 Roc +Copyright (c) 2016 VG Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index fb3de21..149e0c5 100644 --- a/README.md +++ b/README.md @@ -1 +1,5 @@ -# roc-plugin-react \ No newline at end of file +# roc-plugin-react +[![Build Status](https://travis-ci.org/rocjs/roc-plugin-react.svg?branch=master)](https://travis-ci.org/rocjs/roc-plugin-react) + +__Adds React support to Webpack and Roc__ +- [roc-plugin-react](/packages/roc-plugin-react) diff --git a/package.json b/package.json new file mode 100644 index 0000000..45b0dd6 --- /dev/null +++ b/package.json @@ -0,0 +1,15 @@ +{ + "name": "roc-plugin-react", + "private": true, + "license": "MIT", + "scripts": { + "rid": "rid", + "build": "rid build", + "lint": "rid lint:alias", + "link": "rid link", + "test": "npm run lint" + }, + "devDependencies": { + "@rocjs/roc-internal-dev": "^1.0.0" + } +} diff --git a/packages/roc-plugin-react-dev/.eslintignore b/packages/roc-plugin-react-dev/.eslintignore new file mode 100644 index 0000000..bc73336 --- /dev/null +++ b/packages/roc-plugin-react-dev/.eslintignore @@ -0,0 +1,3 @@ +lib +esdocs +docs diff --git a/packages/roc-plugin-react-dev/.eslintrc b/packages/roc-plugin-react-dev/.eslintrc new file mode 100644 index 0000000..811e6a8 --- /dev/null +++ b/packages/roc-plugin-react-dev/.eslintrc @@ -0,0 +1,13 @@ +{ + "extends": "vgno", + + "parser": "babel-eslint", + + "env": { + "es6": true + }, + + "ecmaFeatures": { + "modules": true + } +} diff --git a/packages/roc-plugin-react-dev/README.md b/packages/roc-plugin-react-dev/README.md new file mode 100644 index 0000000..82e4599 --- /dev/null +++ b/packages/roc-plugin-react-dev/README.md @@ -0,0 +1,8 @@ +# roc-plugin-react-dev +Adds React support to Webpack and Roc. + +## Documentation +- [Actions](/packages/roc-plugin-react-dev/docs/Actions.md) +- [Commands](/packages/roc-plugin-react-dev/docs/Commands.md) +- [Hooks](/packages/roc-plugin-react-dev/docs/Hooks.md) +- [Settings](/packages/roc-plugin-react-dev/docs/Settings.md) diff --git a/packages/roc-plugin-react-dev/docs/Actions.md b/packages/roc-plugin-react-dev/docs/Actions.md new file mode 100644 index 0000000..dea88e2 --- /dev/null +++ b/packages/roc-plugin-react-dev/docs/Actions.md @@ -0,0 +1,21 @@ +# Actions for `roc-plugin-react-dev` + +## Actions +* [roc-plugin-react](#roc-plugin-react) + * [react](#react) +* [roc-plugin-react-dev](#roc-plugin-react-dev) + * [react](#react) + +## roc-plugin-react + +### react + +__Connects to extension:__ `roc-plugin-start` +__Connects to hook:__ `get-resolve-paths` + +## roc-plugin-react-dev + +### react + +__Connects to extension:__ Not specified +__Connects to hook:__ `build-webpack` diff --git a/packages/roc-plugin-react-dev/docs/Commands.md b/packages/roc-plugin-react-dev/docs/Commands.md new file mode 100644 index 0000000..e69de29 diff --git a/packages/roc-plugin-react-dev/docs/Hooks.md b/packages/roc-plugin-react-dev/docs/Hooks.md new file mode 100644 index 0000000..8298515 --- /dev/null +++ b/packages/roc-plugin-react-dev/docs/Hooks.md @@ -0,0 +1 @@ +No hooks available. \ No newline at end of file diff --git a/packages/roc-plugin-react-dev/docs/Settings.md b/packages/roc-plugin-react-dev/docs/Settings.md new file mode 100644 index 0000000..3c1f637 --- /dev/null +++ b/packages/roc-plugin-react-dev/docs/Settings.md @@ -0,0 +1,9 @@ +# Settings for `roc-plugin-react-dev` + +## Dev + +### HotMiddleware + +| Name | Description | Path | CLI option | Default | Type | Required | +| ------ | ----------- | ------------------------ | -------------------------- | ------- | --------- | -------- | +| reload | | dev.hotMiddleware.reload | --dev-hotMiddleware-reload | `false` | `Unknown` | No | diff --git a/packages/roc-plugin-react-dev/package.json b/packages/roc-plugin-react-dev/package.json new file mode 100644 index 0000000..7dc51d7 --- /dev/null +++ b/packages/roc-plugin-react-dev/package.json @@ -0,0 +1,37 @@ +{ + "name": "roc-plugin-react-dev", + "description": "Adds React support to Webpack and Roc (Development)", + "author": "VG", + "license": "MIT", + "version": "1.0.0-alpha.0", + "main": "lib/index.js", + "scripts": { + "lint": "eslint .", + "test": "npm run lint" + }, + "files": [ + "lib" + ], + "keywords": [ + "roc", + "roc-plugin" + ], + "repository": { + "type": "git", + "url": "https://github.com/rocjs/roc-plugin-react" + }, + "dependencies": { + "roc-plugin-react": "^1.0.0-alpha", + "babel-plugin-react-transform": "~2.0.0", + "babel-preset-react": "~6.3.13", + "react-transform-catch-errors": "~1.0.2", + "react-transform-hmr": "~1.0.2", + "redbox-react": "~1.1.0", + "react": "~0.14.0" + }, + "devDependencies": { + "babel-eslint": "~5.0.0", + "eslint": "~1.10.3", + "eslint-config-vgno": "~5.0.0" + } +} diff --git a/packages/roc-plugin-react-dev/roc.config.js b/packages/roc-plugin-react-dev/roc.config.js new file mode 100644 index 0000000..2d0a4b0 --- /dev/null +++ b/packages/roc-plugin-react-dev/roc.config.js @@ -0,0 +1,6 @@ +const path = require('path'); + +// Makes it possible for use to generate documentation for this package. +module.exports = { + packages: [path.join(__dirname, 'lib', 'index.js')] +}; diff --git a/packages/roc-plugin-react-dev/src/builder/index.js b/packages/roc-plugin-react-dev/src/builder/index.js new file mode 100644 index 0000000..c66e741 --- /dev/null +++ b/packages/roc-plugin-react-dev/src/builder/index.js @@ -0,0 +1,45 @@ +import { resolvePath } from 'roc-plugin-react'; + +export default () => ({ settings, previousValue: rocBuilder }) => (target) => () => { + let { + buildConfig, + builder, + info + } = rocBuilder; + + const DEV = settings.build.mode === 'dev'; + const WEB = target === 'web'; + + /** + * Update babel configuration for React + */ + buildConfig.babel.presets.push(require.resolve('babel-preset-react')); + if (DEV && WEB) { + buildConfig.babel.plugins.push([ + require.resolve('babel-plugin-react-transform'), { + transforms: [ + { + transform: require.resolve('react-transform-hmr'), + imports: ['react'], + locals: ['module'] + }, + { + transform: require.resolve('react-transform-catch-errors'), + imports: ['react', require.resolve('redbox-react')] + } + ] + } + ]); + } + + /** + * Add resolver from roc-plugin-react + */ + buildConfig.resolve.fallback.push(resolvePath); + + return { + buildConfig, + builder, + info + }; +}; diff --git a/packages/roc-plugin-react-dev/src/index.js b/packages/roc-plugin-react-dev/src/index.js new file mode 100644 index 0000000..5ed0e86 --- /dev/null +++ b/packages/roc-plugin-react-dev/src/index.js @@ -0,0 +1 @@ +export roc from './roc'; diff --git a/packages/roc-plugin-react-dev/src/roc/index.js b/packages/roc-plugin-react-dev/src/roc/index.js new file mode 100644 index 0000000..ee5dc05 --- /dev/null +++ b/packages/roc-plugin-react-dev/src/roc/index.js @@ -0,0 +1,21 @@ +import { name } from './util'; +import builder from '../builder'; + +export default { + name, + config: { + settings: { + dev: { + hotMiddleware: { + reload: false + } + } + } + }, + actions: { + react: { + hook: 'build-webpack', + action: builder + } + } +}; diff --git a/packages/roc-plugin-react-dev/src/roc/util.js b/packages/roc-plugin-react-dev/src/roc/util.js new file mode 100644 index 0000000..fd74b92 --- /dev/null +++ b/packages/roc-plugin-react-dev/src/roc/util.js @@ -0,0 +1,4 @@ +/** + * The name of the package, for easy consumption. + */ +export const name = require('../../package.json').name; diff --git a/packages/roc-plugin-react/.eslintignore b/packages/roc-plugin-react/.eslintignore new file mode 100644 index 0000000..bc73336 --- /dev/null +++ b/packages/roc-plugin-react/.eslintignore @@ -0,0 +1,3 @@ +lib +esdocs +docs diff --git a/packages/roc-plugin-react/.eslintrc b/packages/roc-plugin-react/.eslintrc new file mode 100644 index 0000000..811e6a8 --- /dev/null +++ b/packages/roc-plugin-react/.eslintrc @@ -0,0 +1,13 @@ +{ + "extends": "vgno", + + "parser": "babel-eslint", + + "env": { + "es6": true + }, + + "ecmaFeatures": { + "modules": true + } +} diff --git a/packages/roc-plugin-react/README.md b/packages/roc-plugin-react/README.md new file mode 100644 index 0000000..5eac8fa --- /dev/null +++ b/packages/roc-plugin-react/README.md @@ -0,0 +1,8 @@ +# roc-plugin-react +Adds React support to Webpack and Roc. + +## Documentation +- [Actions](/packages/roc-plugin-react/docs/Actions.md) +- [Commands](/packages/roc-plugin-react/docs/Commands.md) +- [Hooks](/packages/roc-plugin-react/docs/Hooks.md) +- [Settings](/packages/roc-plugin-react/docs/Settings.md) diff --git a/packages/roc-plugin-react/docs/Actions.md b/packages/roc-plugin-react/docs/Actions.md new file mode 100644 index 0000000..2c00ac5 --- /dev/null +++ b/packages/roc-plugin-react/docs/Actions.md @@ -0,0 +1,12 @@ +# Actions for `roc-plugin-react` + +## Actions +* [roc-plugin-react](#roc-plugin-react) + * [react](#react) + +## roc-plugin-react + +### react + +__Connects to extension:__ `roc-plugin-start` +__Connects to hook:__ `get-resolve-paths` diff --git a/packages/roc-plugin-react/docs/Commands.md b/packages/roc-plugin-react/docs/Commands.md new file mode 100644 index 0000000..e69de29 diff --git a/packages/roc-plugin-react/docs/Hooks.md b/packages/roc-plugin-react/docs/Hooks.md new file mode 100644 index 0000000..8298515 --- /dev/null +++ b/packages/roc-plugin-react/docs/Hooks.md @@ -0,0 +1 @@ +No hooks available. \ No newline at end of file diff --git a/packages/roc-plugin-react/docs/Settings.md b/packages/roc-plugin-react/docs/Settings.md new file mode 100644 index 0000000..0d5cd50 --- /dev/null +++ b/packages/roc-plugin-react/docs/Settings.md @@ -0,0 +1 @@ +No settings available. \ No newline at end of file diff --git a/packages/roc-plugin-react/package.json b/packages/roc-plugin-react/package.json new file mode 100644 index 0000000..ed00699 --- /dev/null +++ b/packages/roc-plugin-react/package.json @@ -0,0 +1,32 @@ +{ + "name": "roc-plugin-react", + "description": "Adds React support to Webpack and Roc", + "author": "VG", + "license": "MIT", + "version": "1.0.0-alpha.0", + "main": "lib/index.js", + "scripts": { + "lint": "eslint .", + "test": "npm run lint" + }, + "files": [ + "lib" + ], + "keywords": [ + "roc", + "roc-plugin" + ], + "repository": { + "type": "git", + "url": "https://github.com/rocjs/roc-plugin-react" + }, + "dependencies": { + "react": "~0.14.0", + "react-dom": "~0.14.0" + }, + "devDependencies": { + "babel-eslint": "~5.0.0", + "eslint": "~1.10.3", + "eslint-config-vgno": "~5.0.0" + } +} diff --git a/packages/roc-plugin-react/roc.config.js b/packages/roc-plugin-react/roc.config.js new file mode 100644 index 0000000..2d0a4b0 --- /dev/null +++ b/packages/roc-plugin-react/roc.config.js @@ -0,0 +1,6 @@ +const path = require('path'); + +// Makes it possible for use to generate documentation for this package. +module.exports = { + packages: [path.join(__dirname, 'lib', 'index.js')] +}; diff --git a/packages/roc-plugin-react/src/index.js b/packages/roc-plugin-react/src/index.js new file mode 100644 index 0000000..4e03014 --- /dev/null +++ b/packages/roc-plugin-react/src/index.js @@ -0,0 +1,3 @@ +export roc from './roc'; + +export resolvePath from './resolver'; diff --git a/packages/roc-plugin-react/src/resolver/index.js b/packages/roc-plugin-react/src/resolver/index.js new file mode 100644 index 0000000..e17f543 --- /dev/null +++ b/packages/roc-plugin-react/src/resolver/index.js @@ -0,0 +1,5 @@ +import { join } from 'path'; + +const resolvePath = join(__dirname, '..', '..', 'node_modules'); + +export default resolvePath; diff --git a/packages/roc-plugin-react/src/roc/index.js b/packages/roc-plugin-react/src/roc/index.js new file mode 100644 index 0000000..7d832a1 --- /dev/null +++ b/packages/roc-plugin-react/src/roc/index.js @@ -0,0 +1,13 @@ +import { name } from './util'; +import resolvePath from '../resolver'; + +export default { + name, + actions: { + react: { + extension: 'roc-plugin-start', + hook: 'get-resolve-paths', + action: () => () => () => () => resolvePath + } + } +}; diff --git a/packages/roc-plugin-react/src/roc/util.js b/packages/roc-plugin-react/src/roc/util.js new file mode 100644 index 0000000..fd74b92 --- /dev/null +++ b/packages/roc-plugin-react/src/roc/util.js @@ -0,0 +1,4 @@ +/** + * The name of the package, for easy consumption. + */ +export const name = require('../../package.json').name;