Skip to content

Commit 075ee62

Browse files
lbogdanCompuIves
authored andcommitted
Build IE11 fixes and other small improvements (codesandbox#832)
* Added build:clean step. * Webpack: disabled 'output.pathinfo'. * Webpack: refactored path separator regex. * Webpack: transpile 'vue-template-es2015-compiler' and 'babel-plugin-transform-vue-jsx' modules. * Babel worker: add missing Promise polyfill. * .dockerignore everything except 'www' folder.
1 parent 4d89661 commit 075ee62

File tree

6 files changed

+24
-22
lines changed

6 files changed

+24
-22
lines changed

.dockerignore

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,2 @@
1-
node_modules
2-
.vscode
3-
deploy.sh
4-
Dockerfile
5-
Dockerfile.prod
1+
*
2+
!www

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"private": true,
66
"scripts": {
77
"build": "yarn build:deps && yarn build:prod",
8-
"build:prod": "lerna run build --scope app --scope homepage --parallel && gulp",
8+
"build:prod": "yarn build:clean && lerna run build --scope app --scope homepage --parallel && gulp",
9+
"build:clean": "lerna run build:clean --scope app --scope homepage && rimraf www",
910
"build:deps": "lerna run build:dev --scope codesandbox-api --scope codesandbox-browserfs",
1011
"start": "yarn build:deps && lerna run start --scope app --stream",
1112
"start:fast": "lerna run start --scope app --stream",

packages/app/config/webpack.common.js

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ const ESLINT_PLUGIN_VUE_INDEX = `module.exports = {
3838
}
3939
}`;
4040

41+
const sepRe = `\\${path.sep}`; // path separator regex
42+
4143
module.exports = {
4244
entry: SANDBOX_ONLY
4345
? {
@@ -72,7 +74,6 @@ module.exports = {
7274

7375
output: {
7476
path: paths.appBuild,
75-
pathinfo: true,
7677
publicPath,
7778
},
7879

@@ -84,17 +85,23 @@ module.exports = {
8485
exclude: [
8586
/eslint\.4\.1\.0\.min\.js$/,
8687
/typescriptServices\.js$/,
87-
new RegExp('babel-runtime\\' + path.sep),
88+
new RegExp(`babel-runtime${sepRe}`),
8889
],
8990
loader: 'happypack/loader',
9091
},
9192

9293
// Transpile node dependencies, node deps are often not transpiled for IE11
9394
{
9495
test: [
95-
/\/node_modules\/.*ansi-styles/,
96-
/\/node_modules\/.*chalk/,
97-
/\/node_modules\/.*jest/,
96+
new RegExp(`${sepRe}node_modules${sepRe}.*ansi-styles`),
97+
new RegExp(`${sepRe}node_modules${sepRe}.*chalk`),
98+
new RegExp(`${sepRe}node_modules${sepRe}.*jest`),
99+
new RegExp(
100+
`${sepRe}node_modules${sepRe}vue-template-es2015-compiler`
101+
),
102+
new RegExp(
103+
`${sepRe}node_modules${sepRe}babel-plugin-transform-vue-jsx`
104+
),
98105
],
99106
loader: 'babel-loader',
100107
query: {
@@ -120,9 +127,7 @@ module.exports = {
120127

121128
// `eslint-plugin-vue/lib/index.js` depends on `fs` module we cannot use in browsers, so needs shimming.
122129
{
123-
test: new RegExp(
124-
`eslint-plugin-vue\\${path.sep}lib\\${path.sep}index\\.js$`
125-
),
130+
test: new RegExp(`eslint-plugin-vue${sepRe}lib${sepRe}index\\.js$`),
126131
loader: 'string-replace-loader',
127132
options: {
128133
search: '[\\s\\S]+', // whole file.
@@ -133,9 +138,7 @@ module.exports = {
133138
// `eslint` has some dynamic `require(...)`.
134139
// Delete those.
135140
{
136-
test: new RegExp(
137-
`eslint\\${path.sep}lib\\${path.sep}(?:linter|rules)\\.js$`
138-
),
141+
test: new RegExp(`eslint${sepRe}lib${sepRe}(?:linter|rules)\\.js$`),
139142
loader: 'string-replace-loader',
140143
options: {
141144
search: '(?:\\|\\||(\\())\\s*require\\(.+?\\)',
@@ -156,9 +159,7 @@ module.exports = {
156159
},
157160
// Patch for `babel-eslint`
158161
{
159-
test: new RegExp(
160-
`babel-eslint\\${path.sep}lib\\${path.sep}index\\.js$`
161-
),
162+
test: new RegExp(`babel-eslint${sepRe}lib${sepRe}index\\.js$`),
162163
loader: 'string-replace-loader',
163164
options: {
164165
search: '[\\s\\S]+', // whole file.
@@ -169,7 +170,7 @@ module.exports = {
169170
},
170171
{
171172
test: new RegExp(
172-
`babel-eslint\\${path.sep}lib\\${path.sep}patch-eslint-scope\\.js$`
173+
`babel-eslint${sepRe}lib${sepRe}patch-eslint-scope\\.js$`
173174
),
174175
loader: 'string-replace-loader',
175176
options: {
@@ -388,7 +389,7 @@ module.exports = {
388389
// us from using eslint in the browser, therefore we need to stop it!
389390
!SANDBOX_ONLY &&
390391
new webpack.NormalModuleReplacementPlugin(
391-
new RegExp(['eslint', 'lib', 'load-rules'].join(`\\${path.sep}`)),
392+
new RegExp(['eslint', 'lib', 'load-rules'].join(sepRe)),
392393
path.join(paths.config, 'stubs/load-rules.compiled.js')
393394
),
394395

packages/app/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"start:test": "cross-env LOCAL_SERVER=1 NODE_ENV=test SANDBOX_ONLY=true node scripts/start.js",
1111
"build": "cross-env NODE_ENV=production node scripts/build.js",
1212
"build:sandbox": "cross-env NODE_ENV=production SANDBOX_ONLY=true node scripts/build.js",
13+
"build:clean": "rimraf www",
1314
"test": "jest --env=jsdom",
1415
"test:watch": "jest --watch --env=jsdom",
1516
"test:integrations": "jest --config integration-tests/jest.config.json --maxWorkers=2",

packages/app/src/sandbox/eval/transpilers/babel/worker/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
require('core-js/fn/string/starts-with');
22
require('core-js/fn/string/ends-with');
33
require('core-js/fn/array/find');
4+
require('core-js/fn/promise');
45

56
self.importScripts(
67
`${process.env.CODESANDBOX_HOST}/static/browserfs/browserfs.min.js`

packages/homepage/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"main": "n/a",
3939
"scripts": {
4040
"build": "gatsby build && yarn remove-styles",
41+
"build:clean": "rimraf public",
4142
"remove-styles": "rimraf public/styles.css",
4243
"start": "gatsby develop",
4344
"lint": "echo TODO && exit 0",

0 commit comments

Comments
 (0)