How to use babel method in storybook-root

Best JavaScript code snippet using storybook-root

proxy-generator.js

Source:proxy-generator.js Github

copy

Full Screen

1'use strict';2Object.defineProperty(exports, "__esModule", {3 value: true4});5exports.__test__ = undefined;6exports.generateProxy = generateProxy;7var _babelTypes;8function _load_babelTypes() {9 return _babelTypes = _interopRequireWildcard(require('babel-types'));10}11var _babelGenerator;12function _load_babelGenerator() {13 return _babelGenerator = _interopRequireDefault(require('babel-generator'));14}15function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }16function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }17/**18 * Copyright (c) 2015-present, Facebook, Inc.19 * All rights reserved.20 *21 * This source code is licensed under the license found in the LICENSE file in22 * the root directory of this source tree.23 *24 * 25 * @format26 */27const thenIdent = (_babelTypes || _load_babelTypes()).identifier('then');28const observableIdentifier = (_babelTypes || _load_babelTypes()).identifier('Observable');29const idIdentifier = (_babelTypes || _load_babelTypes()).identifier('id');30const moduleDotExportsExpression = (_babelTypes || _load_babelTypes()).memberExpression((_babelTypes || _load_babelTypes()).identifier('module'), (_babelTypes || _load_babelTypes()).identifier('exports'));31const clientIdentifier = (_babelTypes || _load_babelTypes()).identifier('_client');32// Functions that are implemented at the connection layer.33const callRemoteFunctionExpression = (_babelTypes || _load_babelTypes()).memberExpression(clientIdentifier, (_babelTypes || _load_babelTypes()).identifier('callRemoteFunction'));34const callRemoteMethodExpression = (_babelTypes || _load_babelTypes()).memberExpression(clientIdentifier, (_babelTypes || _load_babelTypes()).identifier('callRemoteMethod'));35const createRemoteObjectExpression = (_babelTypes || _load_babelTypes()).memberExpression(clientIdentifier, (_babelTypes || _load_babelTypes()).identifier('createRemoteObject'));36const disposeRemoteObjectExpression = (_babelTypes || _load_babelTypes()).memberExpression(clientIdentifier, (_babelTypes || _load_babelTypes()).identifier('disposeRemoteObject'));37const remoteModule = (_babelTypes || _load_babelTypes()).identifier('remoteModule');38const emptyObject = (_babelTypes || _load_babelTypes()).objectExpression([]);39const clientDotMarshalExpression = (_babelTypes || _load_babelTypes()).memberExpression(clientIdentifier, (_babelTypes || _load_babelTypes()).identifier('marshal'));40const clientDotUnmarshalExpression = (_babelTypes || _load_babelTypes()).memberExpression(clientIdentifier, (_babelTypes || _load_babelTypes()).identifier('unmarshal'));41const marshalCall = (...args) => (_babelTypes || _load_babelTypes()).callExpression(clientDotMarshalExpression, args);42const unmarshalCall = (...args) => (_babelTypes || _load_babelTypes()).callExpression(clientDotUnmarshalExpression, args);43const clientDotMarshalArgsExpression = (_babelTypes || _load_babelTypes()).memberExpression(clientIdentifier, (_babelTypes || _load_babelTypes()).identifier('marshalArguments'));44// const clientDotUnmarshalArgsExpression45// = t.memberExpression(clientIdentifier, t.identifier('unmarshalArguments'));46/**47 * Helper function that generates statments that can be used to marshal all of the48 * arguments to a function.49 * @param argumentTypes - An array of the types of the function's arguments.50 * @returns An expression representing a promise that resolves to an array of the arguments.51 */52const marshalArgsCall = params => (_babelTypes || _load_babelTypes()).callExpression(clientDotMarshalArgsExpression, [(_babelTypes || _load_babelTypes()).callExpression((_babelTypes || _load_babelTypes()).memberExpression((_babelTypes || _load_babelTypes()).identifier('Array'), (_babelTypes || _load_babelTypes()).identifier('from')), [(_babelTypes || _load_babelTypes()).identifier('arguments')]), objectToLiteral(params)]);53// const unmarshalArgsCall = params => t.callExpression(clientDotUnmarshalArgsExpression, [54// t.arguments,55// objectToLiteral(params),56// ]);57// Generates `Object.defineProperty(module.exports, name, {value: …})`58const objectDefinePropertyCall = (name, value) => (_babelTypes || _load_babelTypes()).callExpression((_babelTypes || _load_babelTypes()).memberExpression((_babelTypes || _load_babelTypes()).identifier('Object'), (_babelTypes || _load_babelTypes()).identifier('defineProperty')), [moduleDotExportsExpression, (_babelTypes || _load_babelTypes()).stringLiteral(name), (_babelTypes || _load_babelTypes()).objectExpression([(_babelTypes || _load_babelTypes()).objectProperty((_babelTypes || _load_babelTypes()).identifier('value'), value)])]);59const dependenciesNodes = names => {60 return {61 // let name0, ... nameN;62 declaration: (_babelTypes || _load_babelTypes()).variableDeclaration('let', names.map(name => (_babelTypes || _load_babelTypes()).variableDeclarator((_babelTypes || _load_babelTypes()).identifier(name)))),63 // function() { name0 = arguments[0]; ... nameN = arguments[N]; }64 injectionCall: (_babelTypes || _load_babelTypes()).functionExpression(null, [], (_babelTypes || _load_babelTypes()).blockStatement(names.map((name, i) => (_babelTypes || _load_babelTypes()).expressionStatement((_babelTypes || _load_babelTypes()).assignmentExpression('=', (_babelTypes || _load_babelTypes()).identifier(name), (_babelTypes || _load_babelTypes()).memberExpression((_babelTypes || _load_babelTypes()).identifier('arguments'), (_babelTypes || _load_babelTypes()).numericLiteral(i),65 /* computed: */true))))))66 };67};68/**69 * Given the parsed result of a definition file, generate a remote proxy module70 * that exports the definition's API, but internally calls RPC functions. The function71 * does not return the proxy module directly, but rather returns a 'factory' method72 * that should be called with a RpcConnection object. This factory method returns the73 * remote module with the client object 'closed over,' and used to make the RPC calls.74 * @param defs - The result of parsing the definition file.75 * @returns The proxy factory method.76 */77function generateProxy(serviceName, preserveFunctionNames, defs) {78 const statements = [];79 // Declare remoteModule as empty object.80 statements.push((_babelTypes || _load_babelTypes()).variableDeclaration('const', [(_babelTypes || _load_babelTypes()).variableDeclarator((_babelTypes || _load_babelTypes()).identifier('remoteModule'), emptyObject)]));81 Object.keys(defs).forEach(defName => {82 const definition = defs[defName];83 const name = definition.name;84 switch (definition.kind) {85 case 'function':86 const functionName = preserveFunctionNames ? name : `${serviceName}/${name}`;87 // Generate a remote proxy for each module-level function.88 statements.push((_babelTypes || _load_babelTypes()).expressionStatement((_babelTypes || _load_babelTypes()).assignmentExpression('=', (_babelTypes || _load_babelTypes()).memberExpression(remoteModule, (_babelTypes || _load_babelTypes()).identifier(name)), generateFunctionProxy(functionName, definition.type))));89 break;90 case 'interface':91 // Generate a remote proxy for each remotable interface.92 statements.push((_babelTypes || _load_babelTypes()).expressionStatement((_babelTypes || _load_babelTypes()).assignmentExpression('=', (_babelTypes || _load_babelTypes()).memberExpression(remoteModule, (_babelTypes || _load_babelTypes()).identifier(name)), generateInterfaceProxy(definition))));93 break;94 case 'alias':95 // nothing96 break;97 }98 });99 // Return the remote module.100 statements.push((_babelTypes || _load_babelTypes()).returnStatement(remoteModule));101 // Node module dependencies are added via the `inject` function, instead of102 // requiring them. This eliminates having to worry about module resolution.103 // In turn, that makes colocating the definition and the constructed proxy104 // easier for internal and external services.105 const deps = dependenciesNodes(['Observable']);106 // Wrap the remoteModule construction in a function that takes a RpcConnection107 // object as an argument.108 const func = (_babelTypes || _load_babelTypes()).arrowFunctionExpression([clientIdentifier], (_babelTypes || _load_babelTypes()).blockStatement(statements));109 const assignment = (_babelTypes || _load_babelTypes()).assignmentExpression('=', moduleDotExportsExpression, func);110 const program = (_babelTypes || _load_babelTypes()).program([111 // !!!This module is not transpiled!!!112 (_babelTypes || _load_babelTypes()).expressionStatement((_babelTypes || _load_babelTypes()).stringLiteral('use strict')), deps.declaration, (_babelTypes || _load_babelTypes()).expressionStatement(assignment), (_babelTypes || _load_babelTypes()).expressionStatement(objectDefinePropertyCall('inject', deps.injectionCall)), (_babelTypes || _load_babelTypes()).expressionStatement(objectDefinePropertyCall('defs', objectToLiteral(defs)))]);113 // Use Babel to generate code from the AST.114 return (0, (_babelGenerator || _load_babelGenerator()).default)(program).code;115}116/**117 * Generate a remote proxy for a module-level function.118 * @param func - The FunctionDefinition object that represents the functions API.119 * @returns The proxy function (as an arrow function) that should be assigned to120 * a property of the remote module.121 */122function generateFunctionProxy(name, funcType) {123 // _client.callRemoteFunction(name, kind, args)124 const callExpression = (_babelTypes || _load_babelTypes()).callExpression(callRemoteFunctionExpression, [(_babelTypes || _load_babelTypes()).stringLiteral(name), (_babelTypes || _load_babelTypes()).stringLiteral(funcType.returnType.kind), (_babelTypes || _load_babelTypes()).identifier('args')]);125 // Promise.all(...).then(args => { return ...)126 const argumentsPromise = marshalArgsCall(funcType.argumentTypes);127 const marshalArgsAndCall = thenPromise(argumentsPromise, (_babelTypes || _load_babelTypes()).arrowFunctionExpression([(_babelTypes || _load_babelTypes()).identifier('args')], (_babelTypes || _load_babelTypes()).blockStatement([(_babelTypes || _load_babelTypes()).returnStatement(callExpression)])));128 const result = generateUnmarshalResult(funcType.returnType, marshalArgsAndCall);129 // function(arg0, ... argN) { return ... }130 const args = funcType.argumentTypes.map((arg, i) => (_babelTypes || _load_babelTypes()).identifier(`arg${i}`));131 return (_babelTypes || _load_babelTypes()).functionExpression(null, args, (_babelTypes || _load_babelTypes()).blockStatement([(_babelTypes || _load_babelTypes()).returnStatement(result)]));132}133/**134 * Generate a remote proxy for an interface.135 * @param def - The InterfaceDefinition object that encodes all if the interface's operations.136 * @returns An anonymous ClassExpression node that can be assigned to a module property.137 */138function generateInterfaceProxy(def) {139 const methodDefinitions = [];140 // Generate proxies for static methods.141 Object.keys(def.staticMethods).forEach(methodName => {142 const funcType = def.staticMethods[methodName];143 const funcProxy = generateFunctionProxy(`${def.name}/${methodName}`, funcType);144 methodDefinitions.push((_babelTypes || _load_babelTypes()).classMethod('method', (_babelTypes || _load_babelTypes()).identifier(methodName), funcProxy.params, funcProxy.body,145 /* computed: */false,146 /* static: */true));147 });148 // Generate constructor proxy.149 if (def.constructorArgs != null) {150 methodDefinitions.push(generateRemoteConstructor(def.name, def.constructorArgs));151 }152 // Generate proxies for instance methods.153 const thisType = {154 kind: 'named',155 location: def.location,156 name: def.name157 };158 Object.keys(def.instanceMethods).forEach(methodName => {159 const funcType = def.instanceMethods[methodName];160 // dispose method is generated custom at the end161 if (methodName === 'dispose') {162 return;163 }164 const methodDefinition = generateRemoteDispatch(methodName, thisType, funcType);165 methodDefinitions.push(methodDefinition);166 });167 // Generate the dispose method.168 methodDefinitions.push(generateDisposeMethod());169 return (_babelTypes || _load_babelTypes()).classExpression(null, null, (_babelTypes || _load_babelTypes()).classBody(methodDefinitions), []);170}171/**172 * Helper function that generates a remote constructor proxy.173 * @param className - The name of the interface.174 * @param constructorArgs - The types of the arguments to the constructor.175 * @returns A MethodDefinition node that can be added to a ClassBody.176 */177function generateRemoteConstructor(className, constructorArgs) {178 // arg0, .... argN179 const args = constructorArgs.map((arg, i) => (_babelTypes || _load_babelTypes()).identifier(`arg${i}`));180 // [arg0, ... argN]181 const argsArray = (_babelTypes || _load_babelTypes()).arrayExpression(args);182 // [argType0, ... argTypeN]183 const argTypes = (_babelTypes || _load_babelTypes()).arrayExpression(constructorArgs.map(objectToLiteral));184 // client.createRemoteObject(className, this, [arg0, arg1, .... argN], [argType0 ... argTypeN])185 const rpcCallExpression = (_babelTypes || _load_babelTypes()).callExpression(createRemoteObjectExpression, [(_babelTypes || _load_babelTypes()).stringLiteral(className), (_babelTypes || _load_babelTypes()).thisExpression(), argsArray, argTypes]);186 // constructor(arg0, arg1, ..., argN) { ... }187 return (_babelTypes || _load_babelTypes()).classMethod('constructor', (_babelTypes || _load_babelTypes()).identifier('constructor'), args, (_babelTypes || _load_babelTypes()).blockStatement([(_babelTypes || _load_babelTypes()).expressionStatement(rpcCallExpression)]));188}189/**190 * Helper function that generates a proxy for an instance method of an interface.191 * @param methodName - The name of the method.192 * @param funcType - The type information for the function.193 * @returns A MethodDefinition node that can be added to a ClassBody194 */195function generateRemoteDispatch(methodName, thisType, funcType) {196 // _client.callRemoteMethod(this, methodName, returnType, args)197 const remoteMethodCall = (_babelTypes || _load_babelTypes()).callExpression(callRemoteMethodExpression, [idIdentifier, (_babelTypes || _load_babelTypes()).stringLiteral(methodName), (_babelTypes || _load_babelTypes()).stringLiteral(funcType.returnType.kind), (_babelTypes || _load_babelTypes()).identifier('args')]);198 // _client.marshal(this, thisType).then(id => { return ... })199 const idThenCall = thenPromise(generateTransformStatement((_babelTypes || _load_babelTypes()).thisExpression(), thisType, true), (_babelTypes || _load_babelTypes()).arrowFunctionExpression([idIdentifier], (_babelTypes || _load_babelTypes()).blockStatement([(_babelTypes || _load_babelTypes()).returnStatement(remoteMethodCall)])));200 // Promise.all(...).then(args => { return ... })201 const argumentsPromise = marshalArgsCall(funcType.argumentTypes);202 const marshallThenCall = thenPromise(argumentsPromise, (_babelTypes || _load_babelTypes()).arrowFunctionExpression([(_babelTypes || _load_babelTypes()).identifier('args')], (_babelTypes || _load_babelTypes()).blockStatement([(_babelTypes || _load_babelTypes()).returnStatement(idThenCall)])));203 // methodName(arg0, ... argN) { return ... }204 const funcTypeArgs = funcType.argumentTypes.map((arg, i) => (_babelTypes || _load_babelTypes()).identifier(`arg${i}`));205 const result = generateUnmarshalResult(funcType.returnType, marshallThenCall);206 return (_babelTypes || _load_babelTypes()).classMethod('method', (_babelTypes || _load_babelTypes()).identifier(methodName), funcTypeArgs, (_babelTypes || _load_babelTypes()).blockStatement([(_babelTypes || _load_babelTypes()).returnStatement(result)]));207}208function generateUnmarshalResult(returnType, rpcCallExpression) {209 switch (returnType.kind) {210 case 'void':211 return rpcCallExpression;212 case 'promise':213 const promiseTransformer = generateValueTransformer(returnType.type);214 return thenPromise(rpcCallExpression, promiseTransformer);215 case 'observable':216 // rpcCallExpression is a call which returns Promise<Observable<unmarshalled result>>217 // Observable.fromPromise(rpcCallExpression)218 const callObservable = (_babelTypes || _load_babelTypes()).callExpression((_babelTypes || _load_babelTypes()).memberExpression(observableIdentifier, (_babelTypes || _load_babelTypes()).identifier('fromPromise')), [rpcCallExpression]);219 // ... .flatMap(id => id)220 const unmarshalledValues = (_babelTypes || _load_babelTypes()).callExpression((_babelTypes || _load_babelTypes()).memberExpression(callObservable, (_babelTypes || _load_babelTypes()).identifier('concatMap')), [(_babelTypes || _load_babelTypes()).arrowFunctionExpression([idIdentifier], idIdentifier)]);221 // Map the events through the appropriate marshaller. We use concatMap instead of222 // flatMap to ensure that the order doesn't change, in case one event takes especially long223 // to marshal.224 //225 // ... .concatMap(value => _client.unmarshal(value, returnType))226 const observableTransformer = generateValueTransformer(returnType.type);227 const unmarshalledObservable = (_babelTypes || _load_babelTypes()).callExpression((_babelTypes || _load_babelTypes()).memberExpression(unmarshalledValues, (_babelTypes || _load_babelTypes()).identifier('concatMap')), [observableTransformer]);228 // And finally, convert to a ConnectableObservable with publish.229 return (_babelTypes || _load_babelTypes()).callExpression((_babelTypes || _load_babelTypes()).memberExpression(unmarshalledObservable, (_babelTypes || _load_babelTypes()).identifier('publish')), []);230 default:231 throw new Error(`Unkown return type ${returnType.kind}.`);232 }233}234// value => _client.unmarshal(value, type)235function generateValueTransformer(type) {236 const value = (_babelTypes || _load_babelTypes()).identifier('value');237 return (_babelTypes || _load_babelTypes()).arrowFunctionExpression([value], (_babelTypes || _load_babelTypes()).blockStatement([(_babelTypes || _load_babelTypes()).returnStatement(generateTransformStatement(value, type, false))]));238}239/**240 * Helper method that generates the dispose method for a class. The dispose method241 * calls `_client.disposeRemoteObject` with the object's id as a parameter.242 * @returns A MethodDefinition node that can be attached to a class body.243 */244function generateDisposeMethod() {245 // return _client.disposeRemoteObject(this);246 const returnStatement = (_babelTypes || _load_babelTypes()).returnStatement((_babelTypes || _load_babelTypes()).callExpression(disposeRemoteObjectExpression, [(_babelTypes || _load_babelTypes()).thisExpression()]));247 // dispose() { ... }248 return (_babelTypes || _load_babelTypes()).classMethod('method', (_babelTypes || _load_babelTypes()).identifier('dispose'), [], (_babelTypes || _load_babelTypes()).blockStatement([returnStatement]));249}250/**251 * Helper function that generates a transformation statement for an object. This ammounts to252 * a call either to _client.marshal or _client.unmarshal.253 * @param id {Identifier} The identifier of the value to convert.254 * @param type {Type} The type of the value to convert.255 * @param marshal {boolean} - If true, then we are trying to marshal the value. If false, then256 * we are trying to unmarshal.257 */258function generateTransformStatement(id, type, marshal) {259 // The first argument is the value to be marshalled or unmarshalled.260 // The second argument is the type object, which encodes all of the information required261 // to marshal / unmarshal the value.262 const convertArgs = [id, objectToLiteral(type)];263 // If the type is parameterized, we send the parameters as an optional fourth argument.264 if (type.param) {265 convertArgs.push(objectToLiteral(type.param));266 }267 // Return the appropriate call.268 return (marshal ? marshalCall : unmarshalCall).apply(this, convertArgs);269}270/**271 * Takes an object, and recursively converts it to a Babel AST literal node. This handles strings,272 * numbers, booleans, basic objects, and Arrays. This cannot handle circular references.273 * @param obj - The object to convert.274 * @returns A babel AST node.275 */276function objectToLiteral(obj) {277 if (typeof obj === 'string') {278 return (_babelTypes || _load_babelTypes()).stringLiteral(obj);279 } else if (typeof obj === 'number') {280 return (_babelTypes || _load_babelTypes()).numericLiteral(obj);281 } else if (typeof obj === 'boolean') {282 return (_babelTypes || _load_babelTypes()).booleanLiteral(obj);283 } else if (obj === null) {284 return (_babelTypes || _load_babelTypes()).nullLiteral();285 } else if (obj === undefined) {286 // undefined287 return (_babelTypes || _load_babelTypes()).identifier('undefined');288 } else if (Array.isArray(obj)) {289 // [...]290 return (_babelTypes || _load_babelTypes()).arrayExpression(obj.map(elem => objectToLiteral(elem)));291 } else if (obj instanceof Map) {292 return (_babelTypes || _load_babelTypes()).newExpression((_babelTypes || _load_babelTypes()).identifier('Map'), obj.size ? // new Map([...])293 [objectToLiteral(Array.from(obj.entries()))] : // new Map()294 []);295 } else if (typeof obj === 'object') {296 // {a: 1, b: 2}297 return (_babelTypes || _load_babelTypes()).objectExpression(Object.keys(obj).map(key => (_babelTypes || _load_babelTypes()).objectProperty((_babelTypes || _load_babelTypes()).isValidIdentifier(key) ? (_babelTypes || _load_babelTypes()).identifier(key) : (_babelTypes || _load_babelTypes()).stringLiteral(key), objectToLiteral(obj[key]))));298 }299 throw new Error(`Cannot convert unknown type ${typeof obj} to literal.`);300}301/**302 * Helper function that `.then`s on a promise.303 * @param promiseExpression - An expression that will evaluate to a promise.304 * @param functionExpression - A function to pass as an argument to `.then`305 * @returns A CallExpression node that `.then`s on the provided promise.306 */307function thenPromise(promiseExpression, functionExpression) {308 return (_babelTypes || _load_babelTypes()).callExpression((_babelTypes || _load_babelTypes()).memberExpression(promiseExpression, thenIdent), [functionExpression]);309}310/** Export private functions for unit-testing. */311const __test__ = exports.__test__ = {312 generateTransformStatement,313 objectToLiteral...

Full Screen

Full Screen

babel-cli_vx.x.x.js

Source:babel-cli_vx.x.x.js Github

copy

Full Screen

1// flow-typed signature: ebb2dc802b3f17d89ea3e6e93c7abcab2// flow-typed version: <<STUB>>/babel-cli_v^6.24.1/flow_v0.51.03/**4 * This is an autogenerated libdef stub for:5 *6 * 'babel-cli'7 *8 * Fill this stub out by replacing all the `any` types.9 *10 * Once filled out, we encourage you to share your work with the11 * community by sending a pull request to:12 * https://github.com/flowtype/flow-typed13 */14declare module 'babel-cli' {15 declare module.exports: any;16}17/**18 * We include stubs for each file inside this npm package in case you need to19 * require those files directly. Feel free to delete any files that aren't20 * needed.21 */22declare module 'babel-cli/bin/babel-doctor' {23 declare module.exports: any;24}25declare module 'babel-cli/bin/babel-external-helpers' {26 declare module.exports: any;27}28declare module 'babel-cli/bin/babel-node' {29 declare module.exports: any;30}31declare module 'babel-cli/bin/babel' {32 declare module.exports: any;33}34declare module 'babel-cli/lib/_babel-node' {35 declare module.exports: any;36}37declare module 'babel-cli/lib/babel-external-helpers' {38 declare module.exports: any;39}40declare module 'babel-cli/lib/babel-node' {41 declare module.exports: any;42}43declare module 'babel-cli/lib/babel/dir' {44 declare module.exports: any;45}46declare module 'babel-cli/lib/babel/file' {47 declare module.exports: any;48}49declare module 'babel-cli/lib/babel/index' {50 declare module.exports: any;51}52declare module 'babel-cli/lib/babel/util' {53 declare module.exports: any;54}55// Filename aliases56declare module 'babel-cli/bin/babel-doctor.js' {57 declare module.exports: $Exports<'babel-cli/bin/babel-doctor'>;58}59declare module 'babel-cli/bin/babel-external-helpers.js' {60 declare module.exports: $Exports<'babel-cli/bin/babel-external-helpers'>;61}62declare module 'babel-cli/bin/babel-node.js' {63 declare module.exports: $Exports<'babel-cli/bin/babel-node'>;64}65declare module 'babel-cli/bin/babel.js' {66 declare module.exports: $Exports<'babel-cli/bin/babel'>;67}68declare module 'babel-cli/index' {69 declare module.exports: $Exports<'babel-cli'>;70}71declare module 'babel-cli/index.js' {72 declare module.exports: $Exports<'babel-cli'>;73}74declare module 'babel-cli/lib/_babel-node.js' {75 declare module.exports: $Exports<'babel-cli/lib/_babel-node'>;76}77declare module 'babel-cli/lib/babel-external-helpers.js' {78 declare module.exports: $Exports<'babel-cli/lib/babel-external-helpers'>;79}80declare module 'babel-cli/lib/babel-node.js' {81 declare module.exports: $Exports<'babel-cli/lib/babel-node'>;82}83declare module 'babel-cli/lib/babel/dir.js' {84 declare module.exports: $Exports<'babel-cli/lib/babel/dir'>;85}86declare module 'babel-cli/lib/babel/file.js' {87 declare module.exports: $Exports<'babel-cli/lib/babel/file'>;88}89declare module 'babel-cli/lib/babel/index.js' {90 declare module.exports: $Exports<'babel-cli/lib/babel/index'>;91}92declare module 'babel-cli/lib/babel/util.js' {93 declare module.exports: $Exports<'babel-cli/lib/babel/util'>;...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1import { configure } from '@storybook/react';2function loadStories() {3 require('../stories/index.js');4}5configure(loadStories, module);6{7 "env": {8 "development": {9 "babel-plugin-root-import",10 {11 }12 }13 }14}

Full Screen

Using AI Code Generation

copy

Full Screen

1const path = require('path');2const root = path.resolve(__dirname, '../');3module.exports = {4 webpackFinal: async config => {5 config.resolve.modules.push(root);6 return config;7 },8};9{10}11const path = require('path');12const root = path.resolve(__dirname, '../');13moduule.exprorts = async ({ config, me }ode }) => {14 conffigr.roesolmve.modules.push(root);15 return config;16};17module.exports = {18};19import { addDecorator } from '@storybook/react';20import { withKnobs } from '@storybook/addon-knobs';21import { withA11y } from '@storybook/addon-a11y';22import { withBackgrounds } from '@storybook/addon-backgrounds';23import { withInfo } from '@storybook/addon-info';24import { withViewport } from '@storybook/addon-viewport';25import { withNotes } from '@storybook/addon-notes';26import { withStorySource } from '@storybook/addon-storysource';27addDecorator(withKnobs);28addDecorator(withA11y);29addDecorator(withBackgrounds);30addDecorator(withInfo);31addDecorator(withViewport);32addDecorator(withNotes);33addDecorator(withStorySource);34import { addons } from '@storybook/addons';35import { themes } from '@storybook/theming';36addons.setConfig({

Full Screen

Using AI Code Generation

copy

Full Screen

1import { configure } from "@storybook/react";"@storybook/react";2import { setOptions }ifromm"@storybook/addon-options";rt { setOptions } from "@storybook/addon-options";3importi{msetDefaults } from p@storybook/addon-info";4import { sotDefaults as setKrobsDefaults } from @storybook/addon-knobs";5import s setDefaults as setActionsDefaults } from "@storybook/addon-actions";etDefaults } from "@storybook/addon-info";6import { setDefaults as setLinksDefaultsi}mfromp"@storybook/addon-links";7importorstorybook-atdon-jsx/r gister";8const req = require.context("../src", true, /__stori s__\/.*\.js$/);9function soadStories() {10 req.keys().ferEach(filename => req(filename));11}12setOttions({13 urllt" as setKnobsDefaults } from "@storybook/addon-knobs";

Full Screen

Using AI Code Generation

copy

Full Screen

1const {ath = require('path');2const rootPath = path.reso ve(__dirname, '..');3modsle.exports = {4 addoDeaul'@storybook/addon-actions', '@storybook/addon-links'],ts as setActionsDefaults } from "@storybook/addon-actions";5imwebpackFinal:pasyncoconfigr=>t{6 { config.resolve.alias 'storybook-root-alias'] = rootPath;setDefaults as setLinksDefaults } from "@storybook/addon-links";7returnconfig;8},9};10const path = require('path');11const rootPath = ath.resove(__dirname, '..');12modle.exports = async ({ config }) => {13 confi.resolve.alas['storybookalas'] = rotPath;14 retun config;15};16{17 ""presets":s["@babel/preset-env",t"@babel/preset-react"],rybook-addon-jsx/register";18["babel-plugin-root-import",{19 }]20}21"devDependencies{22 req"@storybook/addon-links": "^5.1.9", require.context("../src", true, /__stories__\/.*\.js$/);23ion "@storybook/react": "^5.1.9",loadStories() {24 re"babel-plugin-root-import":q"^6.4.1",25. "react": "^16.8.6",eys().forEach(filename => req(filename));26}"react-dom": "^16.8.6"27import React from 'react';28import logo from 'storybook-root-alias/assets/images/logo.png';29const Logo = () => (30 <img src={logos alt="Logo" />etOptions({31); name: "Storybook",32export default Logo;33import React from 'react';34import Logo from '.';35export default {36};37export const Default = () => <Logo />;

Full Screen

Using AI Code Generation

copy

Full Screen

1const path = require('path');2const rootPath = path.resolve(__dirname, '..');3module.exports = {4 webpackFinal: async config => {5 config.resolve.alias['storybook-root-alias'] = rootPath;6 return config;7 },8};9const path = require('path');10const rootPath = path.resolve(__dirname, '..');11module.exports = async ({ config }) => {12 config.resolve.alias['storybook-root-alias'] = rootPath;13 return config;14};15{16 ["babel-plugin-root-import", {17 }]18}19"devDependencies": {20 "babel-plugin-root-import": "^6.4.1",21 }22import React from 'react';23import logo from 'storybook-root-alias/assets/images/logo.png';24const Logo = () => (25 <img src={logo} alt="Logo" />26);27export default Logo;28import React from 'react';29import Logo from '.';30export default {31};32export const Default = () => <Logo />;33Pth.s/config.jsrootAlias({34import { config } from @storybook/rec35cnfigure(reqircont('../rc/code to',utpue, m\thod of \sto$/)b module);36module.exportsr=oaAsnc ({ cfg mode })/=>/{37 c,fig.mdule.rules.puh({38 require.resolve(babel-pree-ectpp)39 {40 }odule-resolver method of storybook-root-alias41ioro},k-root-alias';42rootAlias({extensin'.s', '.tsx'43Iv aso/tpiod oouom h@ followisgycodr to eoad th' ;ois:44/import rootAlias from 'storybook-root-alias';45c,nfigurreque.cotxt(src/stories, true, /\.stories\.js$/, module)46 test: /\.(ts|tsx)$/,47 lader: require.reso('babel-laer'),48 options: {49 reqire.resov('babel-preet-react-app'),50 {51 },52 },53 });54i/p/rt { configort } from '@storybook/react';55import 'A./src/indli.css';56configure(require.context(dirname,stories', true, \\$/) module);57import { cnfig}from/react';

Full Screen

Using AI Code Generation

copy

Full Screen

1import {/configure/}ifrommport rootAlireact';2conf/guue(() =>eB3 arequere('../src/slories');4}, module);5import { configure } from '@storybook/react';6configure(require.context('../src/stories', true, /\.stories\.js$/), module);7module.exports = async ({ config, mode }) => {8 config.module.rules.push({9 test: /\.(ts|tsx)$/,10 loader: require.resolve('babel-loader'),11 options: {12 require.resolve('babel-preset-react-app'),13 {14 },15 },16 });17 config.resolve.extensions.push('.ts', '.tsx');18 return config;19};20import { configure } from '@storybook/react';21import '../src/index.css';22configure(require.context('../src/stories', true, /\.stories\.js$/), module);23import { configure } from '@storybook/react';

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run storybook-root automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful