Skip to content

Commit d104aa4

Browse files
authored
Explore Page & Embed Upgrades (#1366)
Explore Page & Embed Upgrades
1 parent 2ad901d commit d104aa4

File tree

138 files changed

+6047
-3284
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

138 files changed

+6047
-3284
lines changed

.babelrc

-21
This file was deleted.

babel.config.js

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
module.exports = {
2+
presets: ['@babel/preset-env', '@babel/preset-flow', '@babel/preset-react'],
3+
plugins: [
4+
'@babel/plugin-transform-async-to-generator',
5+
'@babel/plugin-proposal-object-rest-spread',
6+
'@babel/plugin-proposal-class-properties',
7+
'@babel/plugin-transform-runtime',
8+
'@babel/plugin-syntax-dynamic-import',
9+
'babel-plugin-lodash',
10+
'babel-plugin-system-import-transformer',
11+
'babel-plugin-macros',
12+
],
13+
};

package.json

+3-4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"scripts": {
77
"build": "NODE_OPTIONS=\"--max-old-space-size=4096\" yarn build:deps && yarn build:prod",
88
"build:prod": "lerna run build --scope homepage --stream && lerna run build --scope app --stream && gulp",
9+
"build:embed": "lerna run build:embed --scope app --stream && gulp",
910
"build:clean": "lerna run build:clean --scope app --scope homepage && rimraf www",
1011
"build:deps": "lerna run build:dev --scope codesandbox-api --scope codesandbox-browserfs --scope node-services && lerna run build:dev --scope sse-hooks",
1112
"start": "yarn build:deps && lerna run start --scope app --stream",
@@ -21,7 +22,7 @@
2122
"add-contributor": "all-contributors add",
2223
"generate": "all-contributors generate",
2324
"precommit": "lint-staged",
24-
"postinstall": "rimraf packages/app/node_modules/styled-components && yarn lerna run install-dependencies --scope codesandbox-browserfs --scope sse-loading-screen --stream && opencollective postinstall"
25+
"postinstall": "rimraf packages/app/node_modules/styled-components && cp -R node_modules/uglify-es node_modules/terser && yarn lerna run install-dependencies --scope codesandbox-browserfs --scope sse-loading-screen --stream && opencollective postinstall"
2526
},
2627
"lint-staged": {
2728
"*.{js,css,json}": [
@@ -32,19 +33,17 @@
3233
"workspaces": {
3334
"packages": [
3435
"packages/app",
36+
"packages/homepage",
3537
"packages/common",
3638
"packages/codesandbox-api",
3739
"packages/sandpack",
3840
"packages/react-sandpack",
39-
"packages/homepage",
4041
"packages/node-services",
4142
"packages/sandbox-hooks",
4243
"packages/sse-hooks",
4344
"packages/react-embed"
4445
],
4546
"nohoist": [
46-
"**/gatsby",
47-
"**/gatsby/**",
4847
"**/@types",
4948
"**/@types/**"
5049
]

packages/app/config/webpack.common.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');
77
const CopyWebpackPlugin = require('copy-webpack-plugin');
88
const HappyPack = require('happypack');
99
const WatchMissingNodeModulesPlugin = require('../scripts/utils/WatchMissingNodeModulesPlugin');
10-
const env = require('./env');
11-
const getHost = require('./host');
10+
const env = require('common/config/env');
11+
const getHost = require('common/utils/host');
1212

1313
const babelDev = require('./babel.dev');
1414
const babelProd = require('./babel.prod');

packages/app/config/webpack.embed.js

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
const merge = require('webpack-merge');
2+
const webpack = require('webpack');
3+
const path = require('path');
4+
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
5+
6+
const paths = require('./paths');
7+
8+
const commonConfig = require('./webpack.common');
9+
10+
module.exports = merge(
11+
// these go first, because "react-hot-loader/patch" has to be the first entry
12+
{
13+
...commonConfig,
14+
entry: {
15+
embed: [path.join(paths.embedSrc, 'library.js')],
16+
},
17+
},
18+
{
19+
mode: 'production',
20+
stats: 'verbose',
21+
devtool: 'source-map',
22+
output: {
23+
libraryTarget: 'commonjs',
24+
library: 'CodeSandboxEmbed',
25+
},
26+
externals: ['react', 'react-dom', 'styled-components'],
27+
optimization: {
28+
// splitChunks: {
29+
// // include all types of chunks
30+
// chunks: 'all',
31+
// },
32+
minimizer: [
33+
new UglifyJSPlugin({
34+
cache: true,
35+
parallel: true,
36+
sourceMap: true,
37+
uglifyOptions: {
38+
mangle: {
39+
safari10: true,
40+
},
41+
output: {
42+
comments: false,
43+
},
44+
},
45+
}),
46+
],
47+
concatenateModules: true, // ModuleConcatenationPlugin
48+
namedModules: true, // NamedModulesPlugin()
49+
noEmitOnErrors: true, // NoEmitOnErrorsPlugin
50+
},
51+
plugins: [
52+
new webpack.NormalModuleReplacementPlugin(
53+
new RegExp('app/components/CodeEditor$'),
54+
'app/components/CodeEditor/CodeMirror'
55+
),
56+
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
57+
],
58+
}
59+
);

packages/app/package.json

+5-3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"start:dev_api": "node scripts/start.js",
1313
"start:test": "cross-env LOCAL_SERVER=1 SANDBOX_ONLY=true node scripts/start.js",
1414
"build": "cross-env NODE_ENV=production node scripts/build.js",
15+
"build:embed": "cross-env NODE_ENV=production webpack --config config/webpack.embed.js",
1516
"build:sandbox": "cross-env NODE_ENV=production SANDBOX_ONLY=true node scripts/build.js",
1617
"build:clean": "rimraf www",
1718
"test": "jest --env=jsdom",
@@ -43,7 +44,7 @@
4344
"babel-loader": "8.0.2",
4445
"babel-plugin-codegen": "^1.2.0",
4546
"babel-plugin-lodash": "^3.3.4",
46-
"babel-plugin-styled-components": "1.7.1",
47+
"babel-plugin-styled-components": "^1.9.2",
4748
"babel-plugin-syntax-dynamic-import": "^6.18.0",
4849
"babel-plugin-transform-class-properties": "^6.24.1",
4950
"babel-plugin-transform-object-rest-spread": "^6.23.0",
@@ -102,6 +103,7 @@
102103
"url-loader": "1.0.1",
103104
"webpack": "^4.10.2",
104105
"webpack-bundle-analyzer": "^2.13.1",
106+
"webpack-cli": "^3.1.2",
105107
"webpack-dev-middleware": "^3.1.3",
106108
"webpack-dev-server": "^3.1.4",
107109
"webpack-manifest-plugin": "^2.0.3",
@@ -217,7 +219,7 @@
217219
"react-inspector": "^2.2.0",
218220
"react-instantsearch": "^5.3.2",
219221
"react-loadable": "^3.3.1",
220-
"react-modal": "^3.3.2",
222+
"react-modal": "^3.6.1",
221223
"react-motion": "^0.5.0",
222224
"react-router-dom": "^4.2.2",
223225
"react-show": "^2.0.0",
@@ -231,7 +233,7 @@
231233
"socket.io-client": "^2.1.1",
232234
"store": "^2.0.12",
233235
"string-replace-loader": "^2.1.1",
234-
"styled-components": "^3.2.1",
236+
"styled-components": "^4.1.2",
235237
"subworkers": "^1.0.1",
236238
"svg-react-loader": "^0.4.4",
237239
"tern": "^0.21.0",

packages/app/scripts/start.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,12 @@ function addMiddleware(devServer, index) {
196196
if (process.env.LOCAL_SERVER) {
197197
devServer.use(
198198
cors({
199-
origin: ['http://localhost:3000', 'http://localhost:3002'],
199+
origin: [
200+
'http://localhost:3000',
201+
'http://localhost:3002',
202+
'http://localhost:8000',
203+
'http://localhost:8001',
204+
],
200205
credentials: true,
201206
})
202207
);

packages/app/src/app/components/CodeEditor/ImageViewer/elements.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import styled from 'styled-components';
22
import Centered from 'common/components/flex/Centered';
33

4-
export const Container = Centered.extend`
4+
export const Container = styled(Centered)`
55
height: 100%;
66
color: ${props =>
77
props.theme['editor.foreground'] || 'rgba(255, 255, 255, 0.9)'};

packages/app/src/app/components/CodeEditor/ImageViewer/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export default class ImageViewer extends React.Component<Props>
4040

4141
<MaxWidth onSubmit={this.onSubmit}>
4242
<Input
43-
innerRef={el => {
43+
ref={el => {
4444
this.input = el;
4545
}}
4646
onChange={this.doChangeCode}

packages/app/src/app/components/ContextMenu/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as React from 'react';
22
import { Spring } from 'react-spring';
3+
import Portal from 'common/components/Portal';
34

4-
import Portal from '../Portal';
55
import { Container, Item, ItemContainer } from './elements';
66

77
class ContextMenu extends React.PureComponent {

0 commit comments

Comments
 (0)