Aujourd'hui, webpack nous permet d'inclure un asset comme s'il s'agissait d'un fichier javascript :
import style from './style.css'
Mais les avantages de cette approches ne sont ils pas inférieurs aux inconvéniants ?
// Available variables: | |
// - Machine | |
// - interpret | |
// - assign | |
// - send | |
// - sendParent | |
// - spawn | |
// - raise | |
// - actions |
Machine({ | |
id: 'JSON File', | |
initial: 'unknown', | |
context: { | |
path: null, | |
content: null, | |
}, | |
states: { | |
unknown: { | |
on: { |
export default (value, cb, path = '', res = {}, scannedValues=[]) => { | |
if (!value || typeof value !== 'object' || scannedValues.includes(value)) { | |
return res; | |
} | |
scannedValues.push(value); | |
if (Array.isArray(value)) { | |
value.forEach((next, index) => { | |
if (cb(next, index)) { |
export const closestToZero = input => { | |
if (!(Array.isArray(input) && input.length)) { | |
return 0; | |
} | |
return input.reduce((prev, value) => { | |
const ratio = Math.abs(prev / value); | |
if (ratio > 1 || (ratio === 1 && value > 0)) { | |
return value; |
const childProcess = require('child_process'); | |
function RelayCompilerPlugin(options) { | |
this.schema = options.schema; | |
this.src = options.src; | |
} | |
RelayCompilerPlugin.prototype.apply = function(compiler) { | |
const cmd = `relay-compiler --src ${this.src} --schema ${this.schema}`; |
import { GraphQLObjectType } from 'graphql'; | |
import { globalIdField } from 'graphql-relay'; | |
import { nodeInterface, defineNodeType } from './node'; | |
import { findById } from '../models/User'; | |
export const UserType = new GraphQLObjectType({ | |
name: 'User', | |
fields: { | |
id: globalIdField('User') |
export default createSubscriptionManager = () => { | |
const subs = [] | |
return { | |
subscriptions: subs, | |
interval: attachSubscriptionMethod(subs, interval), | |
listen: attachSubscriptionMethod(subs, listen), | |
timeout: attachSubscriptionMethod(subs, timeout), | |
promise: attachSubscriptionMethod(subs, promise), | |
import React from 'react' | |
export function DataSelect({ | |
children, | |
onData, | |
onChange, | |
value, | |
defaultValue, | |
...props, | |
}) { |