Skip to content

Commit 3ae3cf3

Browse files
authored
Toggle mjs files to javascript/auto type (#5151)
1 parent 2a7346e commit 3ae3cf3

File tree

7 files changed

+81
-0
lines changed

7 files changed

+81
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
const {
2+
bootstrap,
3+
isSuccessfulDevelopment,
4+
isSuccessfulProduction,
5+
} = require('../../utils');
6+
beforeEach(async () => {
7+
await bootstrap({ directory: global.testDirectory, template: __dirname });
8+
});
9+
10+
describe('graphql with mjs entrypoint', () => {
11+
it('builds in development', async () => {
12+
await isSuccessfulDevelopment({ directory: global.testDirectory });
13+
});
14+
it('builds in production', async () => {
15+
await isSuccessfulProduction({ directory: global.testDirectory });
16+
});
17+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"dependencies": {
3+
"apollo-boost": "0.1.16",
4+
"graphql": "14.0.2",
5+
"react-apollo": "2.2.1",
6+
"react": "latest",
7+
"react-dom": "latest",
8+
"react-scripts": "latest"
9+
}
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<title>React App</title>
5+
</head>
6+
<body>
7+
<div id="root"></div>
8+
</body>
9+
</html>
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import React, { Component } from 'react';
2+
3+
import ApolloClient from 'apollo-boost';
4+
import { ApolloProvider } from 'react-apollo';
5+
6+
const client = new ApolloClient({
7+
uri: '/whatever',
8+
});
9+
10+
class App extends Component {
11+
render() {
12+
return (
13+
<ApolloProvider client={client}>
14+
<div />
15+
</ApolloProvider>
16+
);
17+
}
18+
}
19+
20+
export default App;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import React from 'react';
2+
import ReactDOM from 'react-dom';
3+
import App from './App';
4+
5+
ReactDOM.render(<App />, document.getElementById('root'));

packages/react-scripts/config/webpack.config.dev.js

+10
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,16 @@ module.exports = {
187187
],
188188
include: paths.appSrc,
189189
},
190+
{
191+
// `mjs` support is still in its infancy in the ecosystem, so we don't
192+
// support it.
193+
// Modules who define their `browser` or `module` key as `mjs` force
194+
// the use of this extension, so we need to tell webpack to fall back
195+
// to auto mode (ES Module interop, allows ESM to import CommonJS).
196+
test: /\.mjs$/,
197+
include: /node_modules/,
198+
type: 'javascript/auto',
199+
},
190200
{
191201
// "oneOf" will traverse all following loaders until one will
192202
// match the requirements. When no loader matches it will fall

packages/react-scripts/config/webpack.config.prod.js

+10
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,16 @@ module.exports = {
244244
],
245245
include: paths.appSrc,
246246
},
247+
{
248+
// `mjs` support is still in its infancy in the ecosystem, so we don't
249+
// support it.
250+
// Modules who define their `browser` or `module` key as `mjs` force
251+
// the use of this extension, so we need to tell webpack to fall back
252+
// to auto mode (ES Module interop, allows ESM to import CommonJS).
253+
test: /\.mjs$/,
254+
include: /node_modules/,
255+
type: 'javascript/auto',
256+
},
247257
{
248258
// "oneOf" will traverse all following loaders until one will
249259
// match the requirements. When no loader matches it will fall

0 commit comments

Comments
 (0)