Skip to content
This repository was archived by the owner on Jun 26, 2020. It is now read-only.

Commit debac25

Browse files
committed
simplify Object.create shim
1 parent 3da6e75 commit debac25

File tree

3 files changed

+21
-9
lines changed

3 files changed

+21
-9
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* Copyright (c) 2015-present, Facebook, Inc.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the BSD-style license found in the
6+
* LICENSE file in the root directory of this source tree. An additional grant
7+
* of patent rights can be found in the PATENTS file in the same directory.
8+
*
9+
* @flow
10+
*/
11+
'use strict';
12+
13+
module.exports = window.__REACT_DEVTOOLS_GLOBAL_HOOK__.nativeObjectCreate;

shells/chrome/webpack.backend.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,6 @@
1111

1212
var webpack = require('webpack');
1313
var fs = require('fs');
14-
var HELPERS_PATH = __dirname + '/custom-babel-helpers.js';
15-
16-
var helpers = require("babel-core").buildExternalHelpers(null, 'var');
17-
helpers = helpers.replace(/Object\.create/g, '__REACT_DEVTOOLS_GLOBAL_HOOK__.nativeObjectCreate');
18-
helpers = helpers + ';module.exports = babelHelpers;';
19-
20-
fs.writeFileSync(HELPERS_PATH, helpers);
2114

2215
module.exports = {
2316
devtool: 'cheap-module-eval-source-map',
@@ -32,7 +25,7 @@ module.exports = {
3225
module: {
3326
loaders: [{
3427
test: /\.jsx?$/,
35-
loader: 'babel-loader?stage=0&externalHelpers=true',
28+
loader: 'babel-loader?stage=0',
3629
exclude: [
3730
'node_modules',
3831
'./helpers.js',
@@ -41,7 +34,7 @@ module.exports = {
4134
},
4235

4336
plugins: [new webpack.ProvidePlugin({
44-
babelHelpers: HELPERS_PATH,
37+
'Object.create': __dirname + '/helpers/object-create.js',
4538
Map: __dirname + '/helpers/map.js',
4639
WeakMap: __dirname + '/helpers/weak-map.js',
4740
Set: __dirname + '/helpers/set.js',

test/example/sink.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66
</head>
77
<body>
88
<script src="build/sink.js"></script>
9+
<script>
10+
Object.create = null;
11+
Map = null;
12+
Set = null;
13+
WeakMap = null;
14+
</script>
915
</body>
1016
</html>
1117

0 commit comments

Comments
 (0)