Skip to content

Commit

Permalink
source-loader: separate server and client code (#7510)
Browse files Browse the repository at this point in the history
source-loader: separate server and client code
  • Loading branch information
shilman committed Jul 21, 2019
2 parents 3fdc615 + 08ac213 commit 8a21f97
Show file tree
Hide file tree
Showing 21 changed files with 11 additions and 17 deletions.
8 changes: 2 additions & 6 deletions .babelrc.js
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
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
@@ -0,0 +1 @@
module.exports = require('./dist/client/preview');
File renamed without changes.
File renamed without changes.
6 changes: 0 additions & 6 deletions lib/source-loader/src/index.js

This file was deleted.

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
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
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
@@ -0,0 +1,3 @@
import { transform } from './build';

export default transform;

1 comment on commit 8a21f97

@vercel
Copy link

@vercel vercel bot commented on 8a21f97 Jul 21, 2019

Choose a reason for hiding this comment

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

Please sign in to comment.