@salesforce/pwa-kit-dev 3.8.0-preview.1-basepath → 3.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -13,7 +13,6 @@ var _webpackBundleAnalyzer = require("webpack-bundle-analyzer");
|
|
|
13
13
|
var _webpackPlugin = _interopRequireDefault(require("@loadable/webpack-plugin"));
|
|
14
14
|
var _reactRefreshWebpackPlugin = _interopRequireDefault(require("@pmmmwh/react-refresh-webpack-plugin"));
|
|
15
15
|
var _speedMeasureWebpackPlugin = _interopRequireDefault(require("speed-measure-webpack-plugin"));
|
|
16
|
-
var _ssrPaths = require("@salesforce/pwa-kit-runtime/utils/ssr-paths");
|
|
17
16
|
var _overridesPlugin = _interopRequireDefault(require("./overrides-plugin"));
|
|
18
17
|
var _plugins = require("./plugins");
|
|
19
18
|
var _configNames = require("./config-names");
|
|
@@ -92,6 +91,9 @@ const entryPointExists = segments => {
|
|
|
92
91
|
const getAppEntryPoint = () => {
|
|
93
92
|
return (0, _path.resolve)('./', EXT_OVERRIDES_DIR_NO_SLASH, 'app', 'main');
|
|
94
93
|
};
|
|
94
|
+
const getPublicPathEntryPoint = () => {
|
|
95
|
+
return (0, _path.resolve)(projectDir, 'node_modules', '@salesforce', 'pwa-kit-dev', 'ssr', 'server', 'public-path');
|
|
96
|
+
};
|
|
95
97
|
const findDepInStack = pkg => {
|
|
96
98
|
// Look for the SDK node_modules in two places because in CI,
|
|
97
99
|
// pwa-kit-dev is published under a 'dist' directory, which
|
|
@@ -290,16 +292,12 @@ const enableReactRefresh = config => {
|
|
|
290
292
|
}
|
|
291
293
|
const newRule = ruleForBabelLoader([require.resolve('react-refresh/babel')]);
|
|
292
294
|
const rules = findAndReplace(config.module.rules, rule => rule.id === 'babel-loader', newRule);
|
|
293
|
-
const hmrBasePath = `${(0, _ssrPaths.getBundlePath)()}/development/`;
|
|
294
295
|
return _objectSpread(_objectSpread({}, config), {}, {
|
|
295
296
|
module: _objectSpread(_objectSpread({}, config.module), {}, {
|
|
296
297
|
rules
|
|
297
298
|
}),
|
|
298
299
|
entry: _objectSpread(_objectSpread({}, config.entry), {}, {
|
|
299
|
-
main: ['webpack-hot-middleware/client?path=/__mrt/hmr', getAppEntryPoint()]
|
|
300
|
-
}),
|
|
301
|
-
output: _objectSpread(_objectSpread({}, config.output), {}, {
|
|
302
|
-
publicPath: hmrBasePath
|
|
300
|
+
main: ['webpack-hot-middleware/client?path=/__mrt/hmr', getPublicPathEntryPoint(), getAppEntryPoint()]
|
|
303
301
|
}),
|
|
304
302
|
plugins: [...config.plugins, new _webpack.default.HotModuleReplacementPlugin(), new _reactRefreshWebpackPlugin.default({
|
|
305
303
|
overlay: false
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/pwa-kit-dev",
|
|
3
|
-
"version": "3.8.0
|
|
3
|
+
"version": "3.8.0",
|
|
4
4
|
"description": "Build tools for pwa-kit",
|
|
5
5
|
"homepage": "https://github.com/SalesforceCommerceCloud/pwa-kit/tree/develop/packages/pwa-kit-dev#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"@loadable/server": "^5.15.3",
|
|
59
59
|
"@loadable/webpack-plugin": "^5.15.2",
|
|
60
60
|
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.10",
|
|
61
|
-
"@salesforce/pwa-kit-runtime": "3.8.0
|
|
61
|
+
"@salesforce/pwa-kit-runtime": "3.8.0",
|
|
62
62
|
"@typescript-eslint/eslint-plugin": "^5.57.0",
|
|
63
63
|
"@typescript-eslint/parser": "^5.57.0",
|
|
64
64
|
"archiver": "1.3.0",
|
|
@@ -121,7 +121,7 @@
|
|
|
121
121
|
"@types/node": "~16.0.3",
|
|
122
122
|
"@types/node-fetch": "~2.6.3",
|
|
123
123
|
"@types/validator": "~13.7.14",
|
|
124
|
-
"internal-lib-build": "3.8.0
|
|
124
|
+
"internal-lib-build": "3.8.0",
|
|
125
125
|
"nock": "^13.3.0",
|
|
126
126
|
"nodemon": "^2.0.22",
|
|
127
127
|
"superagent": "^6.1.0",
|
|
@@ -147,5 +147,5 @@
|
|
|
147
147
|
"publishConfig": {
|
|
148
148
|
"directory": "dist"
|
|
149
149
|
},
|
|
150
|
-
"gitHead": "
|
|
150
|
+
"gitHead": "d6ed7107a4087093442b125f8cc212302046ab7e"
|
|
151
151
|
}
|
|
@@ -19,7 +19,7 @@ var _open = _interopRequireDefault(require("open"));
|
|
|
19
19
|
var _requireFromString = _interopRequireDefault(require("require-from-string"));
|
|
20
20
|
var _buildRemoteServer = require("@salesforce/pwa-kit-runtime/ssr/server/build-remote-server");
|
|
21
21
|
var _ssrShared = require("@salesforce/pwa-kit-runtime/utils/ssr-shared");
|
|
22
|
-
var
|
|
22
|
+
var _ssrNamespacePaths = require("@salesforce/pwa-kit-runtime/utils/ssr-namespace-paths");
|
|
23
23
|
var _configNames = require("../../configs/webpack/config-names");
|
|
24
24
|
var _crypto = require("crypto");
|
|
25
25
|
var _chalk = _interopRequireDefault(require("chalk"));
|
|
@@ -151,7 +151,7 @@ const DevServerMixin = exports.DevServerMixin = {
|
|
|
151
151
|
if (config.some(cnf => cnf.name === _configNames.SERVER)) {
|
|
152
152
|
app.__hotServerMiddleware = (0, _webpackHotServerMiddleware.default)(app.__compiler);
|
|
153
153
|
}
|
|
154
|
-
app.use(`${
|
|
154
|
+
app.use(`${_ssrNamespacePaths.bundleBasePath}/development`, app.__devMiddleware);
|
|
155
155
|
app.__hmrMiddleware = (_, res) => res.status(501).send('Hot Module Reloading is disabled.');
|
|
156
156
|
const clientCompiler = app.__compiler.compilers.find(compiler => compiler.name === _configNames.CLIENT);
|
|
157
157
|
if (clientCompiler && process.env.HMR !== 'false') {
|
|
@@ -184,7 +184,7 @@ const DevServerMixin = exports.DevServerMixin = {
|
|
|
184
184
|
_addStaticAssetServing(app) {
|
|
185
185
|
// Proxy bundle asset requests to the local
|
|
186
186
|
// build directory.
|
|
187
|
-
app.use(`${
|
|
187
|
+
app.use(`${_ssrNamespacePaths.bundleBasePath}/development`, _express.default.static(_path.default.resolve(process.cwd(), 'src'), {
|
|
188
188
|
dotFiles: 'deny',
|
|
189
189
|
setHeaders: setLocalAssetHeaders,
|
|
190
190
|
fallthrough: true
|
|
@@ -60,32 +60,31 @@ const insecureFetch = (url, opts) => {
|
|
|
60
60
|
agent: _parsedURL => _parsedURL.protocol === 'https:' ? httpsAgent : httpAgent
|
|
61
61
|
}));
|
|
62
62
|
};
|
|
63
|
-
const mobifyConfig = {
|
|
64
|
-
ssrEnabled: true,
|
|
65
|
-
ssrOnly: ['main.js.map', 'ssr.js', 'ssr.js.map'],
|
|
66
|
-
ssrShared: ['main.js', 'ssr-loader.js', 'worker.js'],
|
|
67
|
-
ssrParameters: {
|
|
68
|
-
proxyConfigs: [{
|
|
69
|
-
protocol: 'https',
|
|
70
|
-
host: 'test.proxy.com',
|
|
71
|
-
path: 'base'
|
|
72
|
-
}, {
|
|
73
|
-
protocol: 'https',
|
|
74
|
-
// This is intentionally an unreachable host
|
|
75
|
-
host: '0.0.0.0',
|
|
76
|
-
path: 'base2'
|
|
77
|
-
}, {
|
|
78
|
-
protocol: 'https',
|
|
79
|
-
host: 'test.proxy.com',
|
|
80
|
-
path: 'base3',
|
|
81
|
-
caching: true
|
|
82
|
-
}]
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
63
|
const opts = (overrides = {}) => {
|
|
86
64
|
const defaults = {
|
|
87
65
|
buildDir: _path.default.join(testFixtures, 'build'),
|
|
88
|
-
mobify:
|
|
66
|
+
mobify: {
|
|
67
|
+
ssrEnabled: true,
|
|
68
|
+
ssrOnly: ['main.js.map', 'ssr.js', 'ssr.js.map'],
|
|
69
|
+
ssrShared: ['main.js', 'ssr-loader.js', 'worker.js'],
|
|
70
|
+
ssrParameters: {
|
|
71
|
+
proxyConfigs: [{
|
|
72
|
+
protocol: 'https',
|
|
73
|
+
host: 'test.proxy.com',
|
|
74
|
+
path: 'base'
|
|
75
|
+
}, {
|
|
76
|
+
protocol: 'https',
|
|
77
|
+
// This is intentionally an unreachable host
|
|
78
|
+
host: '0.0.0.0',
|
|
79
|
+
path: 'base2'
|
|
80
|
+
}, {
|
|
81
|
+
protocol: 'https',
|
|
82
|
+
host: 'test.proxy.com',
|
|
83
|
+
path: 'base3',
|
|
84
|
+
caching: true
|
|
85
|
+
}]
|
|
86
|
+
}
|
|
87
|
+
},
|
|
89
88
|
quiet: true,
|
|
90
89
|
port: TEST_PORT,
|
|
91
90
|
protocol: 'http',
|
|
@@ -93,11 +92,6 @@ const opts = (overrides = {}) => {
|
|
|
93
92
|
};
|
|
94
93
|
return _objectSpread(_objectSpread({}, defaults), overrides);
|
|
95
94
|
};
|
|
96
|
-
jest.mock('@salesforce/pwa-kit-runtime/utils/ssr-config', () => {
|
|
97
|
-
return {
|
|
98
|
-
getConfig: () => mobifyConfig
|
|
99
|
-
};
|
|
100
|
-
});
|
|
101
95
|
describe('DevServer error handlers', () => {
|
|
102
96
|
const expectServerErrorHandled = (error, times) => {
|
|
103
97
|
const proc = {
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _ssrNamespacePaths = require("@salesforce/pwa-kit-runtime/utils/ssr-namespace-paths");
|
|
4
|
+
/*
|
|
5
|
+
* Copyright (c) 2024, salesforce.com, inc.
|
|
6
|
+
* All rights reserved.
|
|
7
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
8
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* This file is used to dynamically set the webpack public path used by HMR via the global webpack variable
|
|
13
|
+
* __webpack_public_path__
|
|
14
|
+
* See https://webpack.js.org/guides/public-path/
|
|
15
|
+
*
|
|
16
|
+
* Previously, we hard coded the public path in our webpack config to '/mobify/bundle/development/'
|
|
17
|
+
* but we need something more dynamic to support namespaced /mobify paths.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/* global __webpack_public_path__: writable */
|
|
21
|
+
__webpack_public_path__ = `${_ssrNamespacePaths.bundleBasePath}/development/`;
|