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

Use babelrc: false only for custom config in .storybook directory #4077

Merged
merged 3 commits into from
Aug 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions app/angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"react-dom": "^16.4.2",
"sass-loader": "^7.1.0",
"ts-loader": "^4.4.2",
"webpack": "^4.16.4",
"zone.js": "^0.8.26"
},
"peerDependencies": {
Expand Down
7 changes: 7 additions & 0 deletions app/angular/src/server/wrapInitialConfig.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import path from 'path';
import { ContextReplacementPlugin } from 'webpack';
import loadTsConfig from './ts_config';

export default (config, configDir) => ({
Expand Down Expand Up @@ -35,4 +37,9 @@ export default (config, configDir) => ({
...config.resolve,
extensions: [...config.resolve.extensions, '.ts', '.tsx'],
},
plugins: [
...config.plugins,
// See https:/angular/angular/issues/11580#issuecomment-401127742
new ContextReplacementPlugin(/@angular(\\|\/)core(\\|\/)fesm5/, path.resolve(__dirname, '..')),
],
});
3 changes: 2 additions & 1 deletion app/polymer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
"common-tags": "^1.8.0",
"global": "^4.3.2",
"react": "^16.4.2",
"react-dom": "^16.4.2"
"react-dom": "^16.4.2",
"webpack": "^4.16.4"
},
"devDependencies": {
"lit-html": "^0.10.2",
Expand Down
7 changes: 7 additions & 0 deletions app/polymer/src/server/wrapInitialConfig.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { IgnorePlugin } from 'webpack';

export default config => ({
...config,
module: {
Expand All @@ -16,4 +18,9 @@ export default config => ({
},
],
},
plugins: [
...config.plugins,
// See https:/webcomponents/webcomponentsjs/issues/794#issuecomment-386554298
new IgnorePlugin(/^vertx$/),
],
});
3 changes: 1 addition & 2 deletions examples/marko-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
},
"dependencies": {
"marko": "^4.12.4",
"marko-starter": "^2.0.4",
"marko-widgets": "^7.0.1"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why delete the widgets?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are deprecated and don't support marko 4

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay, clear!

"marko-starter": "^2.0.4"
},
"devDependencies": {
"@storybook/addon-actions": "4.0.0-alpha.17",
Expand Down
43 changes: 0 additions & 43 deletions examples/marko-cli/src/components/marko-widgets/button/index.js

This file was deleted.

This file was deleted.

14 changes: 0 additions & 14 deletions examples/marko-cli/src/components/marko-widgets/hello/index.js

This file was deleted.

This file was deleted.

28 changes: 1 addition & 27 deletions examples/marko-cli/src/stories/addon-knobs.stories.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { storiesOf } from '@storybook/marko';
import { withKnobs, boolean, text, number } from '@storybook/addon-knobs';
import { withKnobs, text, number } from '@storybook/addon-knobs';
import { withOptions } from '@storybook/addon-options';
import Hello from '../components/hello/index.marko';
import MarkoWidgetHello from '../components/marko-widgets/hello';
import MarkoWidgetButton from '../components/marko-widgets/button';

storiesOf('Addons|Knobs/Hello', module)
.addDecorator(withOptions)
Expand All @@ -17,27 +15,3 @@ storiesOf('Addons|Knobs/Hello', module)
age,
});
});

storiesOf('Addons|Knobs/Hello (Marko Widget)', module)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are no widgets in a new version?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like they decided to drop this functionality

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.addDecorator(withOptions)
.addDecorator(withKnobs)
.addParameters({ options: { addonPanelInRight: false } })
.add('Simple', () => {
const name = text('Name', 'John Doe');
return MarkoWidgetHello.renderSync({
name,
});
});

storiesOf('Addons|Knobs/Button (Marko Widget)', module)
.addDecorator(withKnobs)
.add('Simple', () => {
const body = text('Body', 'Hello Button');
const priority = text('Priority', 'danger');
const disabled = boolean('Disabled', false);
return MarkoWidgetButton.renderSync({
body,
priority,
disabled,
});
});
4 changes: 3 additions & 1 deletion examples/official-storybook/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const path = require('path');
const { DefinePlugin } = require('webpack');
const { DefinePlugin, ContextReplacementPlugin } = require('webpack');

module.exports = (baseConfig, env, defaultConfig) => ({
...defaultConfig,
Expand Down Expand Up @@ -38,5 +38,7 @@ module.exports = (baseConfig, env, defaultConfig) => ({
new DefinePlugin({
process: JSON.stringify(true),
}),
// See https:/graphql/graphql-language-service/issues/111#issuecomment-306723400
new ContextReplacementPlugin(/graphql-language-service-interface[/\\]dist/, /\.js$/),
],
});
16 changes: 0 additions & 16 deletions lib/cli/lib/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,6 @@ export function writePackageJson(packageJson) {
fs.writeFileSync(packageJsonPath, content, 'utf8');
}

export function getBabelRc() {
const babelRcPath = path.resolve('.babelrc');
if (!fs.existsSync(babelRcPath)) {
return false;
}

const babelRcContent = fs.readFileSync(babelRcPath, 'utf8');
return JSON.parse(babelRcContent);
}

export function writeBabelRc(babelRc) {
const content = `${JSON.stringify(babelRc, null, 2)}\n`;
const babelRcPath = path.resolve('.babelrc');
Expand Down Expand Up @@ -185,12 +175,6 @@ export async function installBabel(npmOptions, packageJson) {
);
// Babel 6
if (satisfies(latestCompatibleBabelVersion, '^6.0.0')) {
if (!getBabelRc()) {
logger.warn(
chalk.red(`
You have a dependency on Babel 6 but don't have a .babelrc file. Please add one either in project directory or in .storybook.'`)
);
}
babelLoaderVersion = '^7.0.0';
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { configure } from '@storybook/react';

// automatically import all files ending in *.stories.js
const req = require.context('../stories', true, /.stories.js$/);
function loadStories() {
req.keys().forEach(filename => req(filename));
}

configure(loadStories, module);
3 changes: 3 additions & 0 deletions lib/cli/test/fixtures/react_babel_config_js/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
plugins: ['@babel/plugin-proposal-optional-chaining'],
};
20 changes: 20 additions & 0 deletions lib/cli/test/fixtures/react_babel_config_js/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "react-babel-config-js-fixture",
"version": "1.0.0",
"license": "MIT",
"main": "stories/index.stories.js",
"scripts": {
"storybook": "start-storybook -p 6006",
"build-storybook": "build-storybook"
},
"dependencies": {
"react": "^16.4.2",
"react-dom": "^16.4.2"
},
"devDependencies": {
"@babel/plugin-proposal-optional-chaining": "7.0.0-rc.3",
"@babel/core": "7.0.0-rc.3",
"babel-loader": "8.0.0-beta.6",
"@storybook/react": "^4.0.0-alpha.17"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from 'react';

import { storiesOf } from '@storybook/react';

const data = {
user: {
name: 'Joe',
},
};

storiesOf('My Component', module)
.add('state', () => <span>Hello {data.user?.name}</span>)
3 changes: 3 additions & 0 deletions lib/cli/test/fixtures/react_babel_custom_preset/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["./babel-preset-custom"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { configure } from '@storybook/react';

// automatically import all files ending in *.stories.js
const req = require.context('../stories', true, /.stories.js$/);
function loadStories() {
req.keys().forEach(filename => req(filename));
}

configure(loadStories, module);
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = () => ({
plugins: ['@babel/plugin-proposal-optional-chaining'],
});
20 changes: 20 additions & 0 deletions lib/cli/test/fixtures/react_babel_custom_preset/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "react-babel-custom-preset-fixture",
"version": "1.0.0",
"license": "MIT",
"main": "stories/index.stories.js",
"scripts": {
"storybook": "start-storybook -p 6006",
"build-storybook": "build-storybook"
},
"dependencies": {
"react": "^16.4.2",
"react-dom": "^16.4.2"
},
"devDependencies": {
"@babel/plugin-proposal-optional-chaining": "7.0.0-rc.3",
"@babel/core": "7.0.0-rc.3",
"babel-loader": "8.0.0-beta.6",
"@storybook/react": "^4.0.0-alpha.17"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from 'react';

import { storiesOf } from '@storybook/react';

const data = {
user: {
name: 'Joe',
},
};

storiesOf('My Component', module)
.add('state', () => <span>Hello {data.user?.name}</span>)
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { configure } from '@storybook/react';

// automatically import all files ending in *.stories.js
const req = require.context('../stories', true, /.stories.js$/);
function loadStories() {
req.keys().forEach(filename => req(filename));
}

configure(loadStories, module);
23 changes: 23 additions & 0 deletions lib/cli/test/fixtures/react_babel_pkg_json/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "react-babel-pkg-json-fixture",
"version": "1.0.0",
"license": "MIT",
"main": "stories/index.stories.js",
"scripts": {
"storybook": "start-storybook -p 6006",
"build-storybook": "build-storybook"
},
"dependencies": {
"react": "^16.4.2",
"react-dom": "^16.4.2"
},
"devDependencies": {
"@babel/plugin-proposal-optional-chaining": "7.0.0-rc.3",
"@babel/core": "7.0.0-rc.3",
"babel-loader": "8.0.0-beta.6",
"@storybook/react": "^4.0.0-alpha.17"
},
"babel": {
"plugins": ["@babel/plugin-proposal-optional-chaining"]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from 'react';

import { storiesOf } from '@storybook/react';

const data = {
user: {
name: 'Joe',
},
};

storiesOf('My Component', module)
.add('state', () => <span>Hello {data.user?.name}</span>)
3 changes: 3 additions & 0 deletions lib/cli/test/fixtures/react_babelrc/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"plugins": ["@babel/plugin-proposal-optional-chaining"]
}
9 changes: 9 additions & 0 deletions lib/cli/test/fixtures/react_babelrc/.storybook/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { configure } from '@storybook/react';

// automatically import all files ending in *.stories.js
const req = require.context('../stories', true, /.stories.js$/);
function loadStories() {
req.keys().forEach(filename => req(filename));
}

configure(loadStories, module);
Loading