Skip to content

Commit

Permalink
Add .mjs support (jaredpalmer#469)
Browse files Browse the repository at this point in the history
  • Loading branch information
glennreyes authored and jaredpalmer committed Jan 22, 2018
1 parent e3f61d6 commit 295a91c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
8 changes: 4 additions & 4 deletions packages/razzle/config/createConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ module.exports = (
// It is guaranteed to exist because we tweak it in `env.js`
nodePath.split(path.delimiter).filter(Boolean)
),
extensions: ['.js', '.json', '.jsx'],
extensions: ['.js', '.json', '.jsx', '.mjs'],
alias: {
// This is required so symlinks work during development.
'webpack/hot/poll': require.resolve('webpack/hot/poll'),
Expand All @@ -114,7 +114,7 @@ module.exports = (
// Disable require.ensure as it's not a standard language feature.
// { parser: { requireEnsure: false } },
{
test: /\.(js|jsx)$/,
test: /\.(js|jsx|mjs)$/,
enforce: 'pre',
use: [
{
Expand All @@ -126,15 +126,15 @@ module.exports = (
},
// Transform ES6 with Babel
{
test: /\.(js|jsx)$/,
test: /\.(js|jsx|mjs)$/,
loader: require.resolve('babel-loader'),
include: [paths.appSrc],
options: mainBabelOptions,
},
{
exclude: [
/\.html$/,
/\.(js|jsx)$/,
/\.(js|jsx|mjs)$/,
/\.(ts|tsx)$/,
/\.(vue)$/,
/\.(less)$/,
Expand Down
14 changes: 8 additions & 6 deletions packages/razzle/config/createJestConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,22 @@ module.exports = (resolve, rootDir) => {
// TODO: I don't know if it's safe or not to just use / as path separator
// in Jest configs. We need help from somebody with Windows to determine this.
const config = {
collectCoverageFrom: ['src/**/*.{js,jsx}'],
collectCoverageFrom: ['src/**/*.{js,jsx,mjs}'],
setupTestFrameworkScriptFile: setupTestsFile,
testMatch: [
'<rootDir>/src/**/__tests__/**/*.js?(x)',
'<rootDir>/src/**/?(*.)(spec|test).js?(x)',
'<rootDir>/src/**/__tests__/**/*.{js,jsx,mjs}',
'<rootDir>/src/**/?(*.)(spec|test).{js,jsx,mjs}',
],
testEnvironment: 'node',
testURL: 'http://localhost',
transform: {
'^.+\\.(js|jsx)$': resolve('config/jest/babelTransform.js'),
'^.+\\.(js|jsx|mjs)$': resolve('config/jest/babelTransform.js'),
'^.+\\.css$': resolve('config/jest/cssTransform.js'),
'^(?!.*\\.(js|jsx|css|json)$)': resolve('config/jest/fileTransform.js'),
'^(?!.*\\.(js|jsx|mjs|css|json)$)': resolve(
'config/jest/fileTransform.js'
),
},
transformIgnorePatterns: ['[/\\\\]node_modules[/\\\\].+\\.(js|jsx)$'],
transformIgnorePatterns: ['[/\\\\]node_modules[/\\\\].+\\.(js|jsx|mjs)$'],
moduleNameMapper: {
'^react-native$': 'react-native-web',
},
Expand Down

0 comments on commit 295a91c

Please sign in to comment.