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

Improvements #13

Merged
merged 20 commits into from
Jul 13, 2020
Merged

Improvements #13

merged 20 commits into from
Jul 13, 2020

Conversation

peterhass
Copy link
Contributor

@peterhass peterhass changed the title Improvements 𝙒𝐈𝑃 Improvements Jul 10, 2020
@peterhass peterhass changed the title 𝙒𝐈𝑃 Improvements Improvements Jul 10, 2020
Comment on lines 27 to 28
"start": "start-storybook -p 3000 --ci --config-dir ../../.storybook",
"start:ssr-preview": "SSR=true start-storybook -p 3000 --ci --preview-url=/ssr-iframe --config-dir ../../.storybook",
Copy link
Contributor Author

@peterhass peterhass Jul 10, 2020

Choose a reason for hiding this comment

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

Idea: Extract to ../../scripts/start-storybook and ../../scripts/start-ssr-storybook

Copy link
Contributor

Choose a reason for hiding this comment

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

or start from root and serve all storybooks?

Comment on lines 24 to 25
"start": "start-storybook -p 3000 --ci --config-dir ../../.storybook",
"start:ssr-preview": "SSR=true start-storybook -p 3000 --ci --preview-url=/ssr-iframe --config-dir ../../.storybook",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -2,9 +2,10 @@ const path = require('path');
const sassFunctions = require('sass-functions');
const sass = require('sass');

const ROOT_PKG_PATH = path.join(__dirname, '../../../');
const ROOT_PKG_PATH = path.join(__dirname, '../');
Copy link
Contributor

Choose a reason for hiding this comment

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

will we run storybook from root or from packages? ⚖️ about the same?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Almost yes but I think it would make a difference in load times. SSR-preview is already pretty slow because it has to load all stories of ONE package but we load all stories in all packages it could get worse.

I think it's ok for subpackages to have their own start, lint, build scripts

@@ -23,7 +23,7 @@ const forceServerSideRender = (story) => {

const api = start(render);

require(`${PKG_PATH}/.storybook/preview-ssr`);
require(`root-pkg/.storybook/preview-ssr`);
Copy link
Contributor

Choose a reason for hiding this comment

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

do same as in core app? @ or @root and @package?

@@ -1,7 +1,7 @@
const path = require('path');
Copy link
Contributor

Choose a reason for hiding this comment

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

if we placed .eslintrc.js/babel/mocha at the root wouldn't it work without package configs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes it works, I removed the 'extend' part.

But still, we need those custom rules for no-extraneous-dependencies until there is a better solution for that problem.
import-js/eslint-plugin-import#1174

Copy link
Contributor

Choose a reason for hiding this comment

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

there seem to be several options within the thread you posted, none work? or maybe disable package checking altogether for now?

Copy link
Contributor Author

@peterhass peterhass Jul 13, 2020

Choose a reason for hiding this comment

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

Comment on lines 27 to 28
"start": "start-storybook -p 3000 --ci --config-dir ../../.storybook",
"start:ssr-preview": "SSR=true start-storybook -p 3000 --ci --preview-url=/ssr-iframe --config-dir ../../.storybook",
Copy link
Contributor

Choose a reason for hiding this comment

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

or start from root and serve all storybooks?

@@ -23,7 +23,7 @@ const forceServerSideRender = (story) => {

const api = start(render);

require(`${PKG_PATH}/.storybook/preview-ssr`);
require(`@root/.storybook/preview-ssr`);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
require(`@root/.storybook/preview-ssr`);
require('@root/.storybook/preview-ssr');

const matchWebpackTest = (file, test) => (
test instanceof RegExp
? test.test(file)
: test === file
Copy link
Contributor

Choose a reason for hiding this comment

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

string? perhaps use .includes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure if this line is actually needed at all. Almost all rules use a regex test (at least the ones we want to target here).

A string test may need a more complex check because file path could be relative or something like that? Not sure?

I suggest: Always return false for strings and add a comment

Copy link
Contributor

Choose a reason for hiding this comment

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

not sure myself, leave a comment yes

@@ -1,3 +1,6 @@
const PKG_PATH = process.cwd();
Copy link
Contributor

Choose a reason for hiding this comment

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

not .babelrc?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks like .babelrc.js doesn't get resolved.
.babelrc -> json, .babelrc.js -> not working

mocha.config.js Outdated
module.exports = {
require: '@babel/register',
require: path.join(__dirname, '.mocha/babel-require.js'),
Copy link
Contributor

Choose a reason for hiding this comment

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

could we do the .mocha/babel-require.js right in this file and then let it require itself?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure what you mean. Had to extract the whole require part to babel-require.js because I have to pass options to babel. Found no other way to do that

@@ -1,7 +1,7 @@
const path = require('path');
Copy link
Contributor

Choose a reason for hiding this comment

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

there seem to be several options within the thread you posted, none work? or maybe disable package checking altogether for now?

@@ -1 +1 @@
module.exports = require("../../presets/mocha.config.js");
module.exports = require("../../mocha.config.js");
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
module.exports = require("../../mocha.config.js");
module.exports = require('../../mocha.config.js');

i think this file shouldn't be needed, any reason to have it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, you are right. Should be removed. Thought mocha doesn't have config lookup like babel does but after renaming mocha.config.js to .mocharc.js it worked

"start": "start-storybook -p 3000 --ci",
"start:ssr-preview": "SSR=true start-storybook -p 3000 --ci --preview-url=/ssr-iframe",
"start": "../../scripts/start-storybook",
"start:ssr-preview": "../../scripts/start-storybook --ssr-preview",
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't we default to SSR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, SSR is much slower.

@@ -1 +1 @@
module.exports = require("../../presets/mocha.config.js");
Copy link
Contributor

Choose a reason for hiding this comment

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

same as above

@@ -1 +1 @@
module.exports = require("../../presets/mocha.config.js");
module.exports = require("../../mocha.config.js");
Copy link
Contributor

Choose a reason for hiding this comment

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

same as above

@peterhass peterhass merged commit 5f0342b into master Jul 13, 2020
@peterhass peterhass deleted the improvements branch July 13, 2020 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants