Skip to content

Commit

Permalink
FIX unambiguous modules (often the case when files are pre-transpiled…
Browse files Browse the repository at this point in the history
… in a monorepo) (such as ours)
  • Loading branch information
ndelangen committed Nov 15, 2019
1 parent 371bfc8 commit f67ac36
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions lib/core/src/server/common/babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export default ({ configType }) => {
const prodPresets = isProd ? createProdPresets() : [];

return {
sourceType: 'unambiguous',
presets: [
[
require.resolve('@babel/preset-env'),
Expand Down
9 changes: 5 additions & 4 deletions lib/core/src/server/config/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,24 @@ import { getEnvironment } from 'lazy-universal-dotenv';
import findUp from 'find-up';

const projectRoot = () => {
let result;
try {
return findUp.sync('.git');
result = result || path.join(findUp.sync('.git', { type: 'directory' }), '..');
} catch (e) {
//
}
try {
return findUp.sync('.svn');
result = result || path.join(findUp.sync('.svn', { type: 'directory' }), '..');
} catch (e) {
//
}
try {
return __dirname.split('node-modules')[0];
result = result || __dirname.split('node-modules')[0];
} catch (e) {
//
}

return process.cwd();
return result || process.cwd();
};

export const includePaths = [projectRoot()];
Expand Down
5 changes: 3 additions & 2 deletions lib/core/src/server/preview/iframe-webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import CoreJSUpgradeWebpackPlugin from 'corejs-upgrade-webpack-plugin';

import resolveFrom from 'resolve-from';

import babelLoader from '../common/babel-loader';
import createBabelLoader from '../common/babel-loader';
import { nodeModulesPaths, loadEnv } from '../config/utils';
import { getPreviewHeadHtml, getPreviewBodyHtml } from '../utils/template';

Expand All @@ -31,6 +31,7 @@ export default ({
configType,
}) => {
const { raw, stringified } = loadEnv({ production: true });
const babelLoader = createBabelLoader(babelOptions);
const isProd = configType === 'PRODUCTION';

return {
Expand Down Expand Up @@ -74,7 +75,7 @@ export default ({
].filter(Boolean),
module: {
rules: [
babelLoader(babelOptions),
babelLoader,
{
test: /\.md$/,
use: [
Expand Down

0 comments on commit f67ac36

Please sign in to comment.