Skip to content

Commit d3a414b

Browse files
committed
Remove sandbox service worker
1 parent 9147919 commit d3a414b

File tree

4 files changed

+8
-140
lines changed

4 files changed

+8
-140
lines changed

packages/app/config/webpack.prod.js

Lines changed: 2 additions & 137 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const ManifestPlugin = require('webpack-manifest-plugin');
1212
const CopyWebpackPlugin = require('copy-webpack-plugin');
1313
const VERSION = require('@codesandbox/common/lib/version').default;
1414
// const childProcess = require('child_process');
15+
const RemoveServiceWorkerPlugin = require('webpack-remove-serviceworker-plugin');
1516
const commonConfig = require('./webpack.common');
1617

1718
const publicPath = '/';
@@ -201,143 +202,6 @@ module.exports = merge(commonConfig, {
201202
},
202203
],
203204
}),
204-
// Generate a service worker script that will precache, and keep up to date,
205-
// the HTML & assets that are part of the Webpack build.
206-
new SWPrecacheWebpackPlugin({
207-
// By default, a cache-busting query parameter is appended to requests
208-
// used to populate the caches, to ensure the responses are fresh.
209-
// If a URL is already hashed by Webpack, then there is no concern
210-
// about it being stale, and the cache-busting can be skipped.
211-
dontCacheBustUrlsMatching: /\.\w{8}\./,
212-
filename: 'sandbox-service-worker.js',
213-
cacheId: 'code-sandbox-sandbox',
214-
logger(message) {
215-
if (message.indexOf('Total precache size is') === 0) {
216-
// This message occurs for every build and is a bit too noisy.
217-
return;
218-
}
219-
if (message.indexOf('Skipping static resource') === 0) {
220-
// This message obscures real errors so we ignore it.
221-
// https://github.com/facebookincubator/create-react-app/issues/2612
222-
return;
223-
}
224-
// eslint-disable-next-line no-console
225-
console.log(message);
226-
},
227-
minify: true,
228-
// For unknown URLs, fallback to the index page
229-
navigateFallback: 'https://new.codesandbox.io/frame.html',
230-
staticFileGlobs: process.env.SANDBOX_ONLY
231-
? ['www/index.html']
232-
: ['www/frame.html'],
233-
stripPrefix: 'www/',
234-
// Ignores URLs starting from /__ (useful for Firebase):
235-
// https://github.com/facebookincubator/create-react-app/issues/2237#issuecomment-302693219
236-
navigateFallbackWhitelist: [/^(?!\/__).*/],
237-
// Don't precache sourcemaps (they're large) and build asset manifest:
238-
staticFileGlobsIgnorePatterns: [/\.map$/, /asset-manifest\.json$/],
239-
maximumFileSizeToCacheInBytes: 1024 * 1024 * 20, // 20mb
240-
runtimeCaching: [
241-
{
242-
urlPattern: /api\/v1\/sandboxes/,
243-
handler: 'networkFirst',
244-
options: {
245-
cache: {
246-
maxEntries: 50,
247-
name: 'sandboxes-cache',
248-
},
249-
},
250-
},
251-
{
252-
urlPattern: /api\/v1\/dependencies/,
253-
handler: 'fastest',
254-
options: {
255-
cache: {
256-
maxAgeSeconds: 60 * 60 * 24,
257-
name: 'dependency-version-cache',
258-
},
259-
},
260-
},
261-
{
262-
// These should be dynamic, since it's not loaded from this domain
263-
// But from the root domain
264-
urlPattern: /codesandbox\.io\/static\/js\//,
265-
handler: 'fastest',
266-
options: {
267-
cache: {
268-
// A day
269-
maxAgeSeconds: 60 * 60 * 24,
270-
name: 'static-root-cache',
271-
},
272-
},
273-
},
274-
{
275-
urlPattern: /\.amazonaws\.com\/prod\/package/,
276-
handler: 'fastest',
277-
options: {
278-
cache: {
279-
// a week
280-
maxAgeSeconds: 60 * 60 * 24 * 7,
281-
name: 'dependency-url-generator-cache',
282-
},
283-
},
284-
},
285-
{
286-
urlPattern: /prod-packager-packages\.csb\.dev/,
287-
handler: 'fastest',
288-
options: {
289-
cache: {
290-
maxAgeSeconds: 60 * 60 * 24 * 7,
291-
name: 'dependency-files-cache',
292-
},
293-
},
294-
},
295-
{
296-
urlPattern: /^https:\/\/unpkg\.com/,
297-
handler: 'cacheFirst',
298-
options: {
299-
cache: {
300-
maxEntries: 300,
301-
name: 'unpkg-dep-cache',
302-
maxAgeSeconds: 60 * 60 * 24 * 7,
303-
},
304-
},
305-
},
306-
{
307-
urlPattern: /^https:\/\/cdn\.rawgit\.com/,
308-
handler: 'cacheFirst',
309-
options: {
310-
cache: {
311-
maxEntries: 300,
312-
name: 'rawgit-cache',
313-
maxAgeSeconds: 60 * 60 * 24 * 7,
314-
},
315-
},
316-
},
317-
{
318-
urlPattern: /jsdelivr\.(com|net)/,
319-
handler: 'cacheFirst',
320-
options: {
321-
cache: {
322-
maxEntries: 300,
323-
name: 'jsdelivr-dep-cache',
324-
maxAgeSeconds: 60 * 60 * 24 * 7,
325-
},
326-
},
327-
},
328-
{
329-
urlPattern: /cloudflare\.com/,
330-
handler: 'cacheFirst',
331-
options: {
332-
cache: {
333-
maxEntries: 50,
334-
name: 'cloudflare-cache',
335-
maxAgeSeconds: 60 * 60 * 24 * 7,
336-
},
337-
},
338-
},
339-
],
340-
}),
341205
// Moment.js is an extremely popular library that bundles large locale files
342206
// by default due to how Webpack interprets its code. This is a practical
343207
// solution that requires the user to opt into importing specific locales.
@@ -359,6 +223,7 @@ module.exports = merge(commonConfig, {
359223
quality: '95-100',
360224
},
361225
}),
226+
new RemoveServiceWorkerPlugin({ filename: 'sandbox-service-worker.js' }),
362227
// isMaster &&
363228
// new SentryWebpackPlugin({
364229
// include: 'src',

packages/app/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,7 @@
334334
"webpack-dev-server": "^3.7.2",
335335
"webpack-manifest-plugin": "^2.0.3",
336336
"webpack-merge": "^4.1.0",
337+
"webpack-remove-serviceworker-plugin": "^1.0.0",
337338
"webpackbar": "^3.2.0",
338339
"whatwg-fetch": "^2.0.3",
339340
"workbox-webpack-plugin": "^3.6.3",

packages/app/src/sandbox/index.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { isStandalone, listen, dispatch } from 'codesandbox-api';
33
import { activate, initialize } from 'react-devtools-inline/backend';
44
import _debug from '@codesandbox/common/lib/utils/debug';
55

6-
import registerServiceWorker from '@codesandbox/common/lib/registerServiceWorker';
76
import requirePolyfills from '@codesandbox/common/lib/load-dynamic-polyfills';
87
import { getModulePath } from '@codesandbox/common/lib/sandbox/modules';
98
import { generateFileFromSandbox } from '@codesandbox/common/lib/templates/configuration/package-json';
@@ -30,8 +29,6 @@ export const SCRIPT_VERSION =
3029
debug('Booting sandbox');
3130

3231
requirePolyfills().then(() => {
33-
registerServiceWorker('/sandbox-service-worker.js', {});
34-
3532
function sendReady() {
3633
dispatch({ type: 'initialized' });
3734
}

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29064,6 +29064,11 @@ webpack-merge@^4.1.0:
2906429064
dependencies:
2906529065
lodash "^4.17.5"
2906629066

29067+
webpack-remove-serviceworker-plugin@^1.0.0:
29068+
version "1.0.0"
29069+
resolved "https://registry.yarnpkg.com/webpack-remove-serviceworker-plugin/-/webpack-remove-serviceworker-plugin-1.0.0.tgz#63a7604da9a7fd9bae8f9eef87d274a2470dcaa7"
29070+
integrity sha1-Y6dgTamn/Zuuj57vh9J0okcNyqc=
29071+
2906729072
2906829073
version "1.3.0"
2906929074
resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-1.3.0.tgz#2a28dcb9f1f45fe960d8f1493252b5ee6530fa85"

0 commit comments

Comments
 (0)