Skip to content

Commit

Permalink
chore: Low-hanging fruit in entry
Browse files Browse the repository at this point in the history
  • Loading branch information
rschristian committed Jan 31, 2022
1 parent 3a2d197 commit 02c19fa
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
6 changes: 5 additions & 1 deletion packages/cli/global.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
declare var __webpack_public_path__: string;

declare global {
namespace jest {
interface Matchers<R> {
toBeCloseInSize(receivedSize: number, expectedSize: number): R;
toFindMatchingKey(receivedKeys: string[]): R;
toFindMatchingKey(receivedKey: string): R;
}
}
}

export {};
15 changes: 8 additions & 7 deletions packages/cli/lib/lib/entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,19 @@ if (process.env.NODE_ENV === 'development') {

// only add a debug sw if webpack service worker is not requested.
if (process.env.ADD_SW === undefined && 'serviceWorker' in navigator) {
// eslint-disable-next-line no-undef
navigator.serviceWorker.register(__webpack_public_path__ + 'sw-debug.js');
navigator.serviceWorker.register(
normalizeURL(__webpack_public_path__) + 'sw-debug.js'
);
} else if (process.env.ADD_SW && 'serviceWorker' in navigator) {
// eslint-disable-next-line no-undef
navigator.serviceWorker.register(
__webpack_public_path__ + (process.env.ES_BUILD ? 'sw-esm.js' : 'sw.js')
normalizeURL(__webpack_public_path__) +
(process.env.ES_BUILD ? 'sw-esm.js' : 'sw.js')
);
}
} else if (process.env.ADD_SW && 'serviceWorker' in navigator) {
// eslint-disable-next-line no-undef
navigator.serviceWorker.register(
__webpack_public_path__ + (process.env.ES_BUILD ? 'sw-esm.js' : 'sw.js')
normalizeURL(__webpack_public_path__) +
(process.env.ES_BUILD ? 'sw-esm.js' : 'sw.js')
);
}

Expand Down Expand Up @@ -57,7 +58,7 @@ if (typeof app === 'function') {
hydrate &&
currentURL === normalizeURL(location.pathname);
const doRender = canHydrate ? hydrate : render;
root = doRender(h(app, { CLI_DATA }), document.body, root);
doRender(h(app, { CLI_DATA }), document.body, root);
};

if (module.hot) module.hot.accept('preact-cli-entrypoint', init);
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/tests/images/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ exports.default = exports.full = Object.assign({}, common, {
'ssr-build/ssr-bundle.77c49.css.map': 2070,
'ssr-build/ssr-bundle.js': 11090,
'ssr-build/ssr-bundle.js.map': 30625,
'bundle.17878.js': 21429,
'bundle.17878.js.map': 111801,
'bundle.32925.js': 21429,
'bundle.32925.js.map': 111801,
'bundle.9bde9.css': 945,
'bundle.9bde9.css.map': 1758,
'favicon.ico': 15086,
Expand Down

0 comments on commit 02c19fa

Please sign in to comment.