Skip to content
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

Pass all files other then node_modules though babel loader by default #6566

Closed
wants to merge 27 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
eab2ed4
OPTIMIZE webpack & babel
ndelangen Apr 19, 2019
17ee8e2
ADD support for css & other files for manager
ndelangen Apr 19, 2019
e5cb1ed
REMOVE aliases for preview
ndelangen Apr 19, 2019
416ee3d
CHANGE babel config to transpile to ESM
ndelangen Apr 19, 2019
d021181
MIGRATE to core-js v3.0.1
ndelangen Apr 19, 2019
2193c36
FIX version in root
ndelangen Apr 19, 2019
5d45bd5
FIX bad typing of client-logger && FIX broken import of Type
ndelangen Apr 19, 2019
8409dd8
REMOVE core-js from ui paths
ndelangen Apr 19, 2019
bab828c
FIX IE11
ndelangen Apr 23, 2019
70b5eeb
CLEANUP
ndelangen Apr 23, 2019
42aab66
Merge branch 'next' into tech/loader-scope-changes
ndelangen Apr 23, 2019
4e9760c
CLEANUP
ndelangen Apr 23, 2019
42eec05
REFACTOR to use import { addons } as we say users should too
ndelangen Apr 23, 2019
553ae86
CLEANUP
ndelangen Apr 23, 2019
cbcaa92
FIX tests
ndelangen Apr 23, 2019
0f57bdd
FIX linting
ndelangen Apr 23, 2019
3c88aa7
WIP
ndelangen Apr 24, 2019
70d827c
Merge branch 'next' into tech/loader-scope-changes
ndelangen Apr 24, 2019
07bf0f4
FIXED runtime
ndelangen Apr 24, 2019
3706a7b
Merge branch 'next' into tech/loader-scope-changes
ndelangen Apr 26, 2019
c4f42e3
FIX build & runtime
ndelangen Apr 27, 2019
2f148bd
FIX some linting
ndelangen Apr 27, 2019
3eac27c
UPGRADE codejs3 for angular-cli example
ndelangen Apr 27, 2019
47c31a7
Merge branch 'next' into tech/loader-scope-changes
ndelangen May 6, 2019
f7b07f2
FIX linting
ndelangen May 6, 2019
13818f0
Merge branch 'next' into tech/loader-scope-changes
ndelangen May 20, 2019
9f28b8e
FIX linting issues with types not being re-exported
ndelangen May 20, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 32 additions & 3 deletions .babelrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@ const withTests = {
presets: [
[
'@babel/preset-env',
{ shippedProposals: true, useBuiltIns: 'usage', corejs: '3', targets: { node: 'current' } },
{
shippedProposals: true,
useBuiltIns: 'usage',
corejs: '3',
targets: { node: 'current' },
modules: 'commonjs',
},
],
],
plugins: [
Expand All @@ -14,7 +20,18 @@ const withTests = {

module.exports = {
presets: [
['@babel/preset-env', { shippedProposals: true, useBuiltIns: 'usage', corejs: '3' }],
[
'@babel/preset-env',
{
shippedProposals: true,
useBuiltIns: 'usage',
corejs: '3',
modules: false,
targets: {
browsers: ['Chrome >= 52', 'Explorer 11'],
},
},
],
'@babel/preset-typescript',
'@babel/preset-react',
'@babel/preset-flow',
Expand Down Expand Up @@ -47,7 +64,18 @@ module.exports = {
{
test: './lib',
presets: [
['@babel/preset-env', { shippedProposals: true, useBuiltIns: 'usage', corejs: '3' }],
[
'@babel/preset-env',
{
shippedProposals: true,
useBuiltIns: 'usage',
corejs: '3',
modules: false,
targets: {
browsers: ['Chrome >= 52', 'Explorer 11'],
},
},
],
'@babel/preset-react',
],
plugins: [
Expand Down Expand Up @@ -84,6 +112,7 @@ module.exports = {
node: '8.11',
},
corejs: '3',
modules: 'commonjs',
},
],
],
Expand Down
7 changes: 6 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@ module.exports = {
env: { es6: true, node: true, 'jest/globals': true },
settings: {
'import/core-modules': ['enzyme'],
'import/ignore': ['node_modules\\/(?!@storybook)'],
'import/ignore': [
'node_modules\\/(?!@storybook)',
// I'd rather not have this, but a babel/typescript issue is not detecting all exports
// related: https://github.com/babel/babel/issues/8361#issuecomment-494093009
'@storybook/*',
],
'import/resolver': { node: { extensions: ['.js', '.ts', '.tsx', '.mjs'] } },
'html/html-extensions': ['.html'],
},
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@ integration/__image_snapshots__/__diff_output__
lib/*.jar
lib/**/dll
.expo/packager-info.json
.cache-loader
scripts/storage
htpasswd
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ exports[`HighlightToggle component should match snapshot 1`] = `
"toString": [Function],
},
"hoverable": Object {
"map": "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9hbmltYXRpb24udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBd0NxQiIsImZpbGUiOiIuLi9zcmMvYW5pbWF0aW9uLnRzIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgY3NzLCBrZXlmcmFtZXMgfSBmcm9tICdAZW1vdGlvbi9jb3JlJztcblxuZXhwb3J0IGNvbnN0IGVhc2luZyA9IHtcbiAgcnViYmVyOiAnY3ViaWMtYmV6aWVyKDAuMTc1LCAwLjg4NSwgMC4zMzUsIDEuMDUpJyxcbn07XG5cbmNvbnN0IHJvdGF0ZTM2MCA9IGtleWZyYW1lc2Bcblx0ZnJvbSB7XG5cdFx0dHJhbnNmb3JtOiByb3RhdGUoMGRlZyk7XG5cdH1cblx0dG8ge1xuXHRcdHRyYW5zZm9ybTogcm90YXRlKDM2MGRlZyk7XG5cdH1cbmA7XG5cbmNvbnN0IGdsb3cgPSBrZXlmcmFtZXNgXG4gIDAlLCAxMDAlIHsgb3BhY2l0eTogMTsgfVxuICA1MCUgeyBvcGFjaXR5OiAuNDsgfVxuYDtcblxuY29uc3QgZmxvYXQgPSBrZXlmcmFtZXNgXG4g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M2QoMCwwLDApOyB9XG4gIDEyLjUlLCA2Mi41JSB7IHRyYW5zZm9ybTp0cmFuc2xhdGUzZCgtNHB4LDAsMCk7IH1cbiAgMzcuNSUsIDg3LjUlIHsgIHRyYW5zZm9ybTogdHJhbnNsYXRlM2QoNHB4LDAsMCk7ICB9XG5gO1xuXG5jb25zdCBpbmxpbmVHbG93ID0gY3NzYFxuICBhbmltYXRpb246ICR7Z2xvd30gMS41cyBlYXNlLWluLW91dCBpbmZpbml0ZTtcbiAgY29sb3I6IHRyYW5zcGFyZW50O1xuICBjdXJzb3I6IHByb2dyZXNzO1xuYDtcblxuLy8gaG92ZXIgJiBhY3RpdmUgc3RhdGUgZm9yIGxpbmtzIGFuZCBidXR0b25zXG5jb25zdCBob3ZlcmFibGUgPSBjc3NgXG4gIHRyYW5zaXRpb246IGFsbCAxNTBtcyBlYXNlLW91dDtcbiAgdHJhbnNmb3JtOiB0cmFuc2xhdGUzZCgwLCAwLCAwKTtcblxuICAmOmhvdmVyIHtcbiAgICB0cmFuc2Zvcm06IHRyYW5zbGF0ZTNkKDAsIC0ycHgsIDApO1xuICB9XG5cbiAgJjphY3RpdmUge1xuICAgIHRyYW5zZm9ybTogdHJhbnNsYXRlM2QoMCwgMCwgMCk7XG4gIH1cbmA7XG5cbmV4cG9ydCBjb25zdCBhbmltYXRpb24gPSB7XG4gIHJvdGF0ZTM2MCxcbiAgZ2xvdyxcbiAgZmxvYXQsXG4gIGppZ2dsZSxcbiAgaW5saW5lR2xvdyxcbiAgaG92ZXJhYmxlLFxufTtcbiJdfQ== */",
"name": "1023qba-hoverable",
"styles": "transition:all 150ms ease-out;transform:translate3d(0,0,0);&:hover{transform:translate3d(0,-2px,0);}&:active{transform:translate3d(0,0,0);}label:hoverable;",
},
"inlineGlow": Object {
"map": "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9hbmltYXRpb24udHMiXSwibmFtZXMiOlt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cbiAgdHJhbnNmb3JtOiB0cmFuc2xhdGUzZCgwLCAwLCAwKTtcblxuICAmOmhvdmVyIHtcbiAgICB0cmFuc2Zvcm06IHRyYW5zbGF0ZTNkKDAsIC0ycHgsIDApO1xuICB9XG5cbiAgJjphY3RpdmUge1xuICAgIHRyYW5zZm9ybTogdHJhbnNsYXRlM2QoMCwgMCwgMCk7XG4gIH1cbmA7XG5cbmV4cG9ydCBjb25zdCBhbmltYXRpb24gPSB7XG4gIHJvdGF0ZTM2MCxcbiAgZ2xvdyxcbiAgZmxvYXQsXG4gIGppZ2dsZSxcbiAgaW5saW5lR2xvdyxcbiAgaG92ZXJhYmxlLFxufTtcbiJdfQ== */",
"name": "1euta6d-inlineGlow",
"next": Object {
"name": "animation-r0iffl",
Expand Down
2 changes: 1 addition & 1 deletion addons/actions/src/manager.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import addons from '@storybook/addons';
import { addons } from '@storybook/addons';
import ActionLogger from './containers/ActionLogger';
import { ADDON_ID, PANEL_ID } from '.';

Expand Down
2 changes: 1 addition & 1 deletion addons/actions/src/preview/__tests__/action.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import addons from '@storybook/addons';
import { addons } from '@storybook/addons';
import { action } from '../..';
// import { configureActions } from '../..';

Expand Down
3 changes: 3 additions & 0 deletions addons/centered/react.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import wrapper from './src/react';

export default wrapper;
2 changes: 1 addition & 1 deletion addons/contexts/register.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from './dist/register';
import './dist/register';
5 changes: 4 additions & 1 deletion addons/contexts/src/manager/libs/useChannel.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import addons from '@storybook/addons';
import { useEffect } from 'react';
import { addons } from '@storybook/addons';

import { AnyFunctionReturns } from '../../shared/types.d';

export { Channel } from '@storybook/channels';

/**
* The React hook version of Storybook Channel API.
*/
Expand Down
56 changes: 56 additions & 0 deletions addons/contexts/src/preview/api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { addons } from '@storybook/addons';
import { FORCE_RE_RENDER, SET_CURRENT_STORY } from '@storybook/core-events';
import { REBOOT_MANAGER, UPDATE_PREVIEW, UPDATE_MANAGER } from '../shared/constants';
import { getContextNodes, getPropsMap, getRendererFrom, singleton } from './libs';
import { ContextNode, PropsMap } from '../shared/types.d';

/**
* @Public
* A singleton for handling wrapper-manager side-effects
*/
export const addonContextsAPI = singleton(() => {
const channel = addons.getChannel();
let memorizedNodes: null | ContextNode[] = null;
let selectionState = {};

// from manager
channel.on(SET_CURRENT_STORY, () => {
memorizedNodes = null;
});
channel.on(REBOOT_MANAGER, () => channel.emit(UPDATE_MANAGER, memorizedNodes, selectionState));
channel.on(UPDATE_PREVIEW, state => {
selectionState = Object.freeze(state);
});
channel.on(UPDATE_PREVIEW, () => channel.emit(FORCE_RE_RENDER));

// to manager
const getContextNodesWithSideEffects: typeof getContextNodes = (...arg) => {
// we want to notify the manager only when the story changed since `parameter` can be changed
if (memorizedNodes === null) {
memorizedNodes = getContextNodes(...arg);
channel.emit(UPDATE_MANAGER, memorizedNodes);
}
return memorizedNodes;
};

/**
* (Vue specific)
* Vue will inject getter/setters on the first rendering of the addon,
* which is the reason why we have to keep an internal reference and use `Object.assign` to update it.
*/
const reactivePropsMap = {};
const updateReactiveSystem = (propsMap: PropsMap) =>
/* tslint:disable:prefer-object-spread */
Object.assign(reactivePropsMap, propsMap);

return {
// methods get called on Storybook event lifecycle
getContextNodes: getContextNodesWithSideEffects,
getSelectionState: () => selectionState,
getPropsMap,

// methods for processing framework specific bindings
getRendererFrom,
updateReactiveSystem,
};
});
3 changes: 2 additions & 1 deletion addons/contexts/src/register.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { createElement } from 'react';
import addons, { types } from '@storybook/addons';
import { addons, types } from '@storybook/addons';

import { ContextsManager } from './manager/ContextsManager';
import { ID } from './shared/constants';

Expand Down
6 changes: 3 additions & 3 deletions addons/events/src/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import addons from '@storybook/addons';
import CoreEvents from '@storybook/core-events';
import { addons } from '@storybook/addons';
import { REGISTER_SUBSCRIPTION } from '@storybook/core-events';
import deprecate from 'util-deprecate';

import { EVENTS } from './constants';
Expand Down Expand Up @@ -27,7 +27,7 @@ const addEvents = ({ emit, events }) => {
prevEvents = events;
}
currentEmit = emit;
addons.getChannel().emit(CoreEvents.REGISTER_SUBSCRIPTION, subscription);
addons.getChannel().emit(REGISTER_SUBSCRIPTION, subscription);
};

const WithEvents = deprecate(({ children, ...options }) => {
Expand Down
2 changes: 1 addition & 1 deletion addons/events/src/manager.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import addons from '@storybook/addons';
import { addons } from '@storybook/addons';

import Panel from './components/Panel';
import { ADDON_ID, PANEL_ID } from './constants';
Expand Down
5 changes: 2 additions & 3 deletions addons/graphql/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@
},
"license": "MIT",
"main": "dist/index.js",
"jsnext:main": "src/index.js",
"scripts": {
"prepare": "node ../../scripts/prepare.js"
},
"dependencies": {
"@storybook/addons": "5.1.0-alpha.28",
"@storybook/api": "5.1.0-alpha.28",
"@storybook/addons": "5.1.0-beta.1",
"@storybook/api": "5.1.0-beta.1",
"core-js": "^3.0.1",
"global": "^4.3.2",
"graphiql": "^0.13.0",
Expand Down
2 changes: 1 addition & 1 deletion addons/jest/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import addons from '@storybook/addons';
import { addons } from '@storybook/addons';
import deprecate from 'util-deprecate';
import { normalize, sep } from 'upath';
import { ADD_TESTS } from './shared';
Expand Down
2 changes: 1 addition & 1 deletion addons/jest/src/register.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import addons from '@storybook/addons';
import { addons } from '@storybook/addons';
import { ADDON_ID, PANEL_ID } from './shared';

import Panel from './components/Panel';
Expand Down
2 changes: 1 addition & 1 deletion addons/knobs/src/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import addons, { makeDecorator } from '@storybook/addons';
import { addons, makeDecorator } from '@storybook/addons';

import { SET_OPTIONS } from './shared';

Expand Down
2 changes: 1 addition & 1 deletion addons/knobs/src/register.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import addons from '@storybook/addons';
import { addons } from '@storybook/addons';
import Panel from './components/Panel';
import { ADDON_ID, PANEL_ID } from './shared';

Expand Down
2 changes: 1 addition & 1 deletion addons/knobs/src/registerKnobs.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import addons from '@storybook/addons';
import { addons } from '@storybook/addons';
import { STORY_CHANGED, FORCE_RE_RENDER, REGISTER_SUBSCRIPTION } from '@storybook/core-events';
import debounce from 'lodash/debounce';

Expand Down
2 changes: 1 addition & 1 deletion addons/links/src/manager.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import addons from '@storybook/addons';
import { addons } from '@storybook/addons';

import EVENTS, { ADDON_ID } from './constants';

Expand Down
2 changes: 1 addition & 1 deletion addons/links/src/preview.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import addons from '@storybook/addons';
import { addons } from '@storybook/addons';
import { SELECT_STORY } from '@storybook/core-events';
import { linkTo, hrefTo } from './preview';

Expand Down
2 changes: 1 addition & 1 deletion addons/links/src/preview.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { SyntheticEvent } from 'react';
import { document } from 'global';
import qs from 'qs';
import addons from '@storybook/addons';
import { addons } from '@storybook/addons';
import { SELECT_STORY, STORY_CHANGED } from '@storybook/core-events';
import { toId } from '@storybook/router/utils';

Expand Down
2 changes: 1 addition & 1 deletion addons/links/src/react/components/link.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { shallow } from 'enzyme';
import React from 'react';
import addons from '@storybook/addons';
import { addons } from '@storybook/addons';

import { SELECT_STORY } from '@storybook/core-events';
import { mockChannel } from '../../preview.test';
Expand Down
2 changes: 1 addition & 1 deletion addons/notes/src/register.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import addons, { types } from '@storybook/addons';
import { addons, types } from '@storybook/addons';

import { ADDON_ID, PANEL_ID } from './shared';

Expand Down
2 changes: 1 addition & 1 deletion addons/ondevice-backgrounds/src/register.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import addons from '@storybook/addons';
import { addons } from '@storybook/addons';

import { ADDON_ID, PANEL_ID } from './constants';
import BackgroundPanel from './BackgroundPanel';
Expand Down
2 changes: 1 addition & 1 deletion addons/ondevice-knobs/src/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import addons from '@storybook/addons';
import { addons } from '@storybook/addons';
import Panel from './panel';

export function register() {
Expand Down
2 changes: 1 addition & 1 deletion addons/ondevice-notes/src/register.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { View } from 'react-native';
import Markdown from 'react-native-simple-markdown';
import addons from '@storybook/addons';
import { addons } from '@storybook/addons';
import Events from '@storybook/core-events';

export const PARAM_KEY = `notes`;
Expand Down
2 changes: 1 addition & 1 deletion addons/options/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import deprecate from 'util-deprecate';
import addons, { makeDecorator } from '@storybook/addons';
import { addons, makeDecorator } from '@storybook/addons';

import EVENTS from './constants';

Expand Down
2 changes: 1 addition & 1 deletion addons/options/src/register.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import addons from '@storybook/addons';
import { addons } from '@storybook/addons';
import EVENTS, { ADDON_ID } from './constants';

addons.register(ADDON_ID, api => {
Expand Down
2 changes: 1 addition & 1 deletion addons/storyshots/storyshots-core/src/api/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import global, { describe } from 'global';
import addons, { mockChannel } from '@storybook/addons';
import { addons, mockChannel } from '@storybook/addons';
import ensureOptionsDefaults from './ensureOptionsDefaults';
import snapshotsTests from './snapshotsTestsTemplate';
import integrityTest from './integrityTestTemplate';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import 'core-js';
import 'core-js/es/reflect';
import 'core-js/proposals/reflect-metadata';

import hasDependency from '../hasDependency';
import configure from '../configure';

Expand Down
2 changes: 1 addition & 1 deletion addons/storysource/src/manager.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable react/prop-types */
import React from 'react';
import addons from '@storybook/addons';
import { addons } from '@storybook/addons';

import StoryPanel from './StoryPanel';
import { ADDON_ID, PANEL_ID } from '.';
Expand Down
2 changes: 1 addition & 1 deletion addons/storysource/src/preview.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import addons from '@storybook/addons';
import { addons } from '@storybook/addons';
import { EVENT_ID } from './events';

const getLocation = (context, locationsMap) => locationsMap[context.id];
Expand Down
6 changes: 6 additions & 0 deletions addons/viewport/preview.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export {
configureViewport,
DEFAULT_VIEWPORT,
INITIAL_VIEWPORTS,
withViewport,
} from './src/legacy_preview/index';
2 changes: 1 addition & 1 deletion addons/viewport/src/register.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import addons, { types } from '@storybook/addons';
import { addons, types } from '@storybook/addons';

import { ADDON_ID } from './constants';

Expand Down
Loading