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

source-loader: separate server and client code #7510

Merged
merged 1 commit into from
Jul 21, 2019
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
8 changes: 2 additions & 6 deletions .babelrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ module.exports = {
},
{
test: './lib',
exclude: './addons/storysource/src/loader',
presets: [
['@babel/preset-env', { shippedProposals: true, useBuiltIns: 'usage', corejs: '3' }],
'@babel/preset-react',
Expand All @@ -75,14 +74,11 @@ module.exports = {
},
{
test: [
'./lib/core/src/server',
'./lib/node-logger',
'./lib/codemod',
'./lib/source-loader/src',
'./addons/storyshots',
'./addons/storysource/src/loader',
'./app/**/src/server/**',
'./app/**/src/bin/**',
'**/src/server/**',
'**/src/bin/**',
],
presets: [
[
Expand Down
4 changes: 2 additions & 2 deletions lib/source-loader/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
"directory": "lib/source-loader"
},
"license": "MIT",
"main": "dist/index.js",
"jsnext:main": "src/index.js",
"main": "dist/server/index.js",
"jsnext:main": "src/server/index.js",
"scripts": {
"prepare": "node ../../scripts/prepare.js"
},
Expand Down
1 change: 1 addition & 0 deletions lib/source-loader/preview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('./dist/client/preview');
File renamed without changes.
6 changes: 0 additions & 6 deletions lib/source-loader/src/index.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,7 @@ storiesOf('Foo', module)
`;

exports[`inject-decorator will not change the source when there are no "storiesOf" functions 1`] = `
"var addSourceDecorator = require(\\"@storybook/source-loader/dist/preview\\").addSource;
"var addSourceDecorator = require(\\"@storybook/source-loader/preview\\").addSource;
while(true) {
console.log(\\"it's a kind of magic\\");
}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const STORY_DECORATOR_STATEMENT =
const ADD_PARAMETERS_STATEMENT =
'.addParameters({ storySource: { source: __STORY__, locationsMap: __ADDS_MAP__ } })';
const IMPORT_DECLARATION_FOR_EXPORTED_STORIES_DECORATOR =
'var addSourceDecorator = require("@storybook/source-loader/dist/preview").addSource;\n';
'var addSourceDecorator = require("@storybook/source-loader/preview").addSource;\n';
const applyExportDecoratorStatement = part =>
` addSourceDecorator(${part}, {__STORY__, __ADDS_MAP__,__MAIN_FILE_LOCATION__,__MODULE_DEPENDENCIES__,__LOCAL_DEPENDENCIES__,__SOURCE_PREFIX__,__IDS_TO_FRAMEWORKS__});`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function transform(inputSource) {
localDependencies,
idsToFrameworks,
}) => `
var withSourceLoader = require('@storybook/source-loader/dist/preview').withSource;
var withSourceLoader = require('@storybook/source-loader/preview').withSource;
var __SOURCE_PREFIX__ = "${prefix.replace(/\\([^\\ ])/g, '\\\\$1')}";
var __STORY__ = ${sourceJson};
var __ADDS_MAP__ = ${JSON.stringify(addsMap)};
Expand Down
3 changes: 3 additions & 0 deletions lib/source-loader/src/server/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { transform } from './build';

export default transform;