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

Add support to NODE_PATH when looking at modules. #528

Merged
merged 1 commit into from
Oct 4, 2016
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
Empty file modified dist/server/build.js
100755 → 100644
Empty file.
12 changes: 8 additions & 4 deletions dist/server/config/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.nodeModulesPaths = exports.excludePaths = exports.includePaths = exports.OccurenceOrderPlugin = undefined;
exports.nodePaths = exports.nodeModulesPaths = exports.excludePaths = exports.includePaths = exports.OccurenceOrderPlugin = undefined;

var _keys = require('babel-runtime/core-js/object/keys');

Expand Down Expand Up @@ -35,6 +35,12 @@ var includePaths = exports.includePaths = [_path2.default.resolve('./')];

var excludePaths = exports.excludePaths = [_path2.default.resolve('./node_modules')];

var nodeModulesPaths = exports.nodeModulesPaths = _path2.default.resolve('./node_modules');

var nodePaths = exports.nodePaths = (process.env.NODE_PATH || '').split(process.platform === 'win32' ? ';' : ':').filter(Boolean).map(function (p) {
return _path2.default.resolve('./', p);
});

// Load environment variables starts with STORYBOOK_ to the client side.
function loadEnv() {
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
Expand All @@ -52,6 +58,4 @@ function loadEnv() {
});

return env;
}

var nodeModulesPaths = exports.nodeModulesPaths = _path2.default.resolve('./node_modules');
}
3 changes: 3 additions & 0 deletions dist/server/config/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ exports.default = function () {
}]
},
resolve: {
// Add support to NODE_PATH. With this we could avoid relative path imports.
// Based on this CRA feature: https://github.com/facebookincubator/create-react-app/issues/253
fallback: _utils.nodePaths,
alias: {
// This is to add addon support for NPM2
'@kadira/storybook-addons': require.resolve('@kadira/storybook-addons')
Expand Down
7 changes: 5 additions & 2 deletions dist/server/config/webpack.config.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ exports.default = function () {
}]
},
resolve: {
// Add support to NODE_PATH. With this we could avoid relative path imports.
// Based on this CRA feature: https://github.com/facebookincubator/create-react-app/issues/253
fallback: _utils.nodePaths,
alias: {
// This is to add addon support for NPM2
'@kadira/storybook-addons': require.resolve('@kadira/storybook-addons')
Expand All @@ -68,10 +71,10 @@ var _webpack = require('webpack');

var _webpack2 = _interopRequireDefault(_webpack);

var _utils = require('./utils');

var _babelProd = require('./babel.prod.js');

var _babelProd2 = _interopRequireDefault(_babelProd);

var _utils = require('./utils');

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9 changes: 7 additions & 2 deletions src/server/config/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ export const excludePaths = [
path.resolve('./node_modules'),
];

export const nodeModulesPaths = path.resolve('./node_modules');

export const nodePaths = (process.env.NODE_PATH || '')
.split(process.platform === 'win32' ? ';' : ':')
.filter(Boolean)
.map(p => path.resolve('./', p));

// Load environment variables starts with STORYBOOK_ to the client side.
export function loadEnv(options = {}) {
const defaultNodeEnv = options.production ? 'production' : 'development';
Expand All @@ -30,5 +37,3 @@ export function loadEnv(options = {}) {

return env;
}

export const nodeModulesPaths = path.resolve('./node_modules');
4 changes: 4 additions & 0 deletions src/server/config/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
excludePaths,
nodeModulesPaths,
loadEnv,
nodePaths,
} from './utils';
import babelLoaderConfig from './babel.js';

Expand Down Expand Up @@ -49,6 +50,9 @@ export default function () {
],
},
resolve: {
// Add support to NODE_PATH. With this we could avoid relative path imports.
// Based on this CRA feature: https://github.com/facebookincubator/create-react-app/issues/253
fallback: nodePaths,
alias: {
// This is to add addon support for NPM2
'@kadira/storybook-addons': require.resolve('@kadira/storybook-addons'),
Expand Down
11 changes: 10 additions & 1 deletion src/server/config/webpack.config.prod.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import path from 'path';
import webpack from 'webpack';
import { OccurenceOrderPlugin, includePaths, excludePaths, loadEnv } from './utils';
import babelLoaderConfig from './babel.prod.js';
import {
OccurenceOrderPlugin,
includePaths,
excludePaths,
loadEnv,
nodePaths,
} from './utils';

export default function () {
const entries = {
Expand Down Expand Up @@ -54,6 +60,9 @@ export default function () {
],
},
resolve: {
// Add support to NODE_PATH. With this we could avoid relative path imports.
// Based on this CRA feature: https://github.com/facebookincubator/create-react-app/issues/253
fallback: nodePaths,
alias: {
// This is to add addon support for NPM2
'@kadira/storybook-addons': require.resolve('@kadira/storybook-addons'),
Expand Down