-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/babel6 simple #81
Changes from 6 commits
1e039fd
4cc2303
2a985e3
2b5efc8
bcf1243
89a23fe
3e5848a
7b4cdf6
f8999b9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,10 @@ | ||
{ | ||
"stage": 0 | ||
"env": { | ||
"development": { | ||
"presets": [ | ||
"react-hmre" | ||
] | ||
} | ||
}, | ||
"presets": ["es2015", "react", "stage-0"] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
v5 | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,10 +12,9 @@ function getPackagePath(packageName) { | |
|
||
module.exports = function(env) { | ||
var isProd = env === 'production'; | ||
var cssLoader = 'css?modules&importLoaders=1&localIdentName=ReactStyleguidist-[name]__[local]!postcss'; | ||
var cssLoader = 'css?module&importLoaders=1&localIdentName=ReactStyleguidist-[name]__[local]!postcss'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It should be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My bad... #willfix |
||
|
||
var codeMirrorPath = getPackagePath('codemirror'); | ||
var reactTransformPath = getPackagePath('babel-plugin-react-transform'); | ||
|
||
var includes = [ | ||
__dirname, | ||
|
@@ -74,7 +73,7 @@ module.exports = function(env) { | |
} | ||
], | ||
noParse: [ | ||
/babel-core\/browser.js/ | ||
/babel-standalone/ | ||
] | ||
}, | ||
postcss: function() { | ||
|
@@ -114,10 +113,7 @@ module.exports = function(env) { | |
{ | ||
test: /\.jsx?$/, | ||
include: includes, | ||
loader: 'babel', | ||
query: { | ||
stage: 0 | ||
} | ||
loader: 'babel' | ||
} | ||
] | ||
} | ||
|
@@ -145,28 +141,7 @@ module.exports = function(env) { | |
{ | ||
test: /\.jsx?$/, | ||
include: includes, | ||
loader: 'babel', | ||
query: { | ||
stage: 0, | ||
plugins: [ | ||
reactTransformPath | ||
], | ||
extra: { | ||
'react-transform': { | ||
transforms: [ | ||
{ | ||
transform: 'react-transform-hmr', | ||
imports: ['react'], | ||
locals: ['module'] | ||
}, | ||
{ | ||
transform: 'react-transform-catch-errors', | ||
imports: ['react', 'redbox-react'] | ||
} | ||
] | ||
} | ||
} | ||
} | ||
loader: 'babel' | ||
} | ||
] | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
import React, { Component, PropTypes } from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import babel from 'babel-core/browser'; | ||
import {transform} from 'babel-standalone'; | ||
import Wrapper from 'rsg-components/Wrapper'; | ||
|
||
import s from './Preview.css'; | ||
|
@@ -11,7 +11,7 @@ export default class Preview extends Component { | |
static propTypes = { | ||
code: PropTypes.string.isRequired, | ||
evalInContext: PropTypes.func.isRequired | ||
} | ||
}; | ||
|
||
constructor() { | ||
super(); | ||
|
@@ -37,7 +37,10 @@ export default class Preview extends Component { | |
} | ||
|
||
compileCode(code) { | ||
return babel.transform(code, {stage: 0}).code; | ||
return transform(code, { | ||
presets: ['es2015', 'react', 'stage-0'], | ||
ignore: [/node_modules/] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need to ignore There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Force of habit :) |
||
}).code; | ||
} | ||
|
||
executeCode() { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it required by Babel 6 or is it a good practice or something very useful? ;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not required by Babel 6, but incredibly useful to people who need to switch between versions of Node: on some projects I need to use the Node LTS version (4.2.x) to stay in sync with an environment, on others I want to switch to v5.
Using https://github.com/wbyoung/avn, simply by cd'ing into the directory I get switched to the project-specific version. I can certainly remove, but it's a nice feature for some.