Skip to content
This repository has been archived by the owner on Mar 7, 2024. It is now read-only.

Commit

Permalink
fix: 修正 module import 错误
Browse files Browse the repository at this point in the history
  • Loading branch information
yesmeck committed Oct 14, 2019
1 parent 3638327 commit e27547e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { Adapter } from '../../adapters';
import { isNativeComponent } from './util';
import { RemaxOptions } from '../../../getConfig';
import alias from '../alias';
import extensions from '../../../extensions';

interface Component {
type: string;
Expand Down Expand Up @@ -52,6 +53,7 @@ export default (options: RemaxOptions, adapter: Adapter) => () => ({

let sourcePath = alias(options).resolveId(source, importer) || source;
sourcePath = resolve.sync(sourcePath, {
extensions,
basedir: path.dirname(importer),
});

Expand Down
12 changes: 7 additions & 5 deletions packages/remax-cli/src/build/rollupConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ import fixRegeneratorRuntime from './plugins/fixRegeneratorRuntime';
import nativeComponents from './plugins/nativeComponents/index';
import nativeComponentsBabelPlugin from './plugins/nativeComponents/babelPlugin';
import alias from './plugins/alias';
import extensions from '../extensions';
import { without } from 'lodash';

export default function rollupConfig(
options: RemaxOptions,
Expand Down Expand Up @@ -98,15 +100,15 @@ export default function rollupConfig(
'scheduler',
'react-reconciler',
],
extensions: ['.mjs', '.js', '.jsx', '.json', '.ts', '.tsx'],
extensions,
customResolveOptions: {
moduleDirectory: 'node_modules',
},
}),
commonjs({
include: /node_modules/,
namedExports,
extensions: ['.mjs', '.js', '.jsx', '.json', '.ts', '.tsx'],
extensions,
ignoreGlobal: false,
}),
stub({
Expand All @@ -115,19 +117,19 @@ export default function rollupConfig(
babel({
babelrc: false,
include: entries.pages.map(p => p.file),
extensions: ['.js', '.jsx', '.ts', '.tsx'],
extensions: without(extensions, '.json'),
plugins: [nativeComponentsBabelPlugin(options, adapter), page],
presets: [[require.resolve('babel-preset-remax'), { react: false }]],
}),
babel({
babelrc: false,
include: entries.app,
extensions: ['.js', '.jsx', '.ts', '.tsx'],
extensions: without(extensions, '.json'),
plugins: [nativeComponentsBabelPlugin(options, adapter), app],
presets: [[require.resolve('babel-preset-remax'), { react: false }]],
}),
babel({
extensions: ['.js', '.jsx', '.ts', '.tsx'],
extensions: without(extensions, '.json'),
plugins: [
nativeComponentsBabelPlugin(options, adapter),
components(adapter),
Expand Down
3 changes: 3 additions & 0 deletions packages/remax-cli/src/extensions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const extensions = ['.mjs', '.js', '.jsx', '.json', '.ts', '.tsx'];

export default extensions;

1 comment on commit e27547e

@vercel
Copy link

@vercel vercel bot commented on e27547e Oct 14, 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.