Skip to content

Commit bb39819

Browse files
Migrate away from expose-loader to fix ES6 import-related issues
1 parent 037b016 commit bb39819

File tree

5 files changed

+49
-25
lines changed

5 files changed

+49
-25
lines changed

src/React.Core/RenderFunctions/ReactHelmetFunctions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public class ReactHelmetFunctions : RenderFunctionsBase
2424
public override void PostRender(Func<string, string> executeJs)
2525
{
2626
var helmetString = executeJs(@"
27-
var helmetResult = Helmet.default.renderStatic();
27+
var helmetResult = Helmet.renderStatic();
2828
JSON.stringify(['base', 'bodyAttributes', 'htmlAttributes', 'link', 'meta', 'noscript', 'script', 'style', 'title']
2929
.reduce((mappedResults, helmetKey) => Object.assign(mappedResults, { [helmetKey]: helmetResult[helmetKey] && helmetResult[helmetKey].toString() }), {}));");
3030

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11
{
2-
"presets": ["react", "env"],
3-
"plugins": [
4-
"add-module-exports"
5-
]
2+
"presets": ["react", "env"]
63
}
Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
1-
require('expose-loader?React!react');
2-
require('expose-loader?ReactDOM!react-dom');
3-
require('expose-loader?ReactDOMServer!react-dom/server');
4-
5-
require('expose-loader?RootComponent!./home.jsx');
6-
require('expose-loader?Styled!styled-components');
7-
require('expose-loader?ReactJss!react-jss');
8-
require('expose-loader?EmotionServer!emotion-server');
9-
require('expose-loader?Helmet!react-helmet');
1+
import React from 'react';
2+
import ReactDOM from 'react-dom';
3+
import ReactDOMServer from 'react-dom/server';
4+
5+
import RootComponent from './home.jsx';
6+
import { ServerStyleSheet } from 'styled-components';
7+
import { JssProvider, SheetsRegistry } from 'react-jss';
8+
import { renderStylesToString } from 'emotion-server';
9+
import Helmet from 'react-helmet';
10+
11+
global.React = React;
12+
global.ReactDOM = ReactDOM;
13+
global.ReactDOMServer = ReactDOMServer;
14+
15+
global.Styled = { ServerStyleSheet };
16+
global.ReactJss = { JssProvider, SheetsRegistry };
17+
global.EmotionServer = { renderStylesToString };
18+
global.Helmet = Helmet;
19+
20+
global.RootComponent = RootComponent;

src/React.Sample.Webpack.CoreMvc/package-lock.json

Lines changed: 27 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/React.Sample.Webpack.CoreMvc/package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,10 @@
99
"dependencies": {
1010
"babel-core": "^6.26.3",
1111
"babel-loader": "^7.1.2",
12-
"babel-plugin-add-module-exports": "^0.2.1",
1312
"babel-preset-env": "^1.6.1",
1413
"babel-preset-react": "^6.24.1",
1514
"emotion": "^9.2.12",
1615
"emotion-server": "^9.2.12",
17-
"expose-loader": "^0.7.3",
1816
"react": "^16.5.2",
1917
"react-dom": "^16.5.2",
2018
"react-emotion": "^9.2.12",

0 commit comments

Comments
 (0)