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 63db40d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
2 changes: 2 additions & 0 deletions packages/cli/global.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
declare var __webpack_public_path__: string;

declare global {
namespace jest {
interface Matchers<R> {
Expand Down
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

0 comments on commit 63db40d

Please sign in to comment.