Skip to content

Commit 63db40d

Browse files
committed
chore: Low-hanging fruit in entry
1 parent 3a2d197 commit 63db40d

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

packages/cli/global.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
declare var __webpack_public_path__: string;
2+
13
declare global {
24
namespace jest {
35
interface Matchers<R> {

packages/cli/lib/lib/entry.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,19 @@ if (process.env.NODE_ENV === 'development') {
1313

1414
// only add a debug sw if webpack service worker is not requested.
1515
if (process.env.ADD_SW === undefined && 'serviceWorker' in navigator) {
16-
// eslint-disable-next-line no-undef
17-
navigator.serviceWorker.register(__webpack_public_path__ + 'sw-debug.js');
16+
navigator.serviceWorker.register(
17+
normalizeURL(__webpack_public_path__) + 'sw-debug.js'
18+
);
1819
} else if (process.env.ADD_SW && 'serviceWorker' in navigator) {
19-
// eslint-disable-next-line no-undef
2020
navigator.serviceWorker.register(
21-
__webpack_public_path__ + (process.env.ES_BUILD ? 'sw-esm.js' : 'sw.js')
21+
normalizeURL(__webpack_public_path__) +
22+
(process.env.ES_BUILD ? 'sw-esm.js' : 'sw.js')
2223
);
2324
}
2425
} else if (process.env.ADD_SW && 'serviceWorker' in navigator) {
25-
// eslint-disable-next-line no-undef
2626
navigator.serviceWorker.register(
27-
__webpack_public_path__ + (process.env.ES_BUILD ? 'sw-esm.js' : 'sw.js')
27+
normalizeURL(__webpack_public_path__) +
28+
(process.env.ES_BUILD ? 'sw-esm.js' : 'sw.js')
2829
);
2930
}
3031

@@ -57,7 +58,7 @@ if (typeof app === 'function') {
5758
hydrate &&
5859
currentURL === normalizeURL(location.pathname);
5960
const doRender = canHydrate ? hydrate : render;
60-
root = doRender(h(app, { CLI_DATA }), document.body, root);
61+
doRender(h(app, { CLI_DATA }), document.body, root);
6162
};
6263

6364
if (module.hot) module.hot.accept('preact-cli-entrypoint', init);

0 commit comments

Comments
 (0)