@salesforce/pwa-kit-dev 4.0.0-extensibility-preview.2 → 4.0.0-extensibility-preview.4
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.
package/bin/pwa-kit-dev.js
CHANGED
|
@@ -299,7 +299,7 @@ const main = async () => {
|
|
|
299
299
|
? projectWebpack
|
|
300
300
|
: p.join(__dirname, '..', 'configs', 'webpack', 'config.js')
|
|
301
301
|
fse.emptyDirSync(buildDirectory)
|
|
302
|
-
execSync(
|
|
302
|
+
execSync(`"${webpack}" --config "${webpackConf}"`, {
|
|
303
303
|
env: {
|
|
304
304
|
NODE_ENV: 'production',
|
|
305
305
|
...process.env,
|
|
@@ -473,6 +473,13 @@ const main = async () => {
|
|
|
473
473
|
)
|
|
474
474
|
})
|
|
475
475
|
|
|
476
|
+
program
|
|
477
|
+
.command('list-overrides')
|
|
478
|
+
.description('List all overridable files in the project')
|
|
479
|
+
.action(() => {
|
|
480
|
+
execSync(p.join('node_modules', '.bin', 'pwa-kit-extension-sdk'))
|
|
481
|
+
})
|
|
482
|
+
|
|
476
483
|
managedRuntimeCommand('tail-logs')
|
|
477
484
|
.description(`continuously stream environment logs`)
|
|
478
485
|
.addOption(
|
|
@@ -6,6 +6,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _utils = require("@salesforce/pwa-kit-extension-sdk/shared/utils");
|
|
8
8
|
var _ssrConfig = require("@salesforce/pwa-kit-runtime/utils/ssr-config");
|
|
9
|
+
var _path = _interopRequireDefault(require("path"));
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
11
|
/*
|
|
10
12
|
* Copyright (c) 2021, salesforce.com, inc.
|
|
11
13
|
* All rights reserved.
|
|
@@ -17,7 +19,8 @@ var _default = exports.default = {
|
|
|
17
19
|
sourceType: 'unambiguous',
|
|
18
20
|
presets: [[require('@babel/preset-env'), {
|
|
19
21
|
targets: {
|
|
20
|
-
node
|
|
22
|
+
// The _minimum_ Node version supported. See https://developer.salesforce.com/docs/commerce/pwa-kit-managed-runtime/guide/upgrade-node-version.html#supported-node-versions
|
|
23
|
+
node: '18'
|
|
21
24
|
}
|
|
22
25
|
}], require('@babel/preset-typescript'), require('@babel/preset-react')],
|
|
23
26
|
plugins: [[require('@salesforce/pwa-kit-extension-sdk/configs/babel/plugin-application-extensions'), {
|
|
@@ -34,5 +37,22 @@ var _default = exports.default = {
|
|
|
34
37
|
presets: [require('@babel/preset-env'), require('@babel/preset-react')],
|
|
35
38
|
plugins: [require('babel-plugin-dynamic-import-node-babel-7')]
|
|
36
39
|
}
|
|
37
|
-
}
|
|
40
|
+
},
|
|
41
|
+
ignore: [function (filepath) {
|
|
42
|
+
const normalizedPath = _path.default.normalize(filepath);
|
|
43
|
+
const extensionRegex = new RegExp(`node_modules\\${_path.default.sep}[^\\${_path.default.sep}]+\\${_path.default.sep}(pwa-kit-extension-sdk|@[^\\${_path.default.sep}]+\\${_path.default.sep}extension-|extension-)`);
|
|
44
|
+
|
|
45
|
+
// Return false if it's an allowed extension package @salesforce/pwa-kit-extension-sdk and extension-*
|
|
46
|
+
if (extensionRegex.test(normalizedPath)) {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Return true if it's in node_modules (excluding allowed packages handled above)
|
|
51
|
+
if (/node_modules/.test(normalizedPath)) {
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Return false for all other files
|
|
56
|
+
return false;
|
|
57
|
+
}]
|
|
38
58
|
};
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.SUPPORTED_FILE_EXTENSIONS = exports.EXTENIONS_NAMESPACE = exports.DEPS_TO_DEDUPE = void 0;
|
|
7
7
|
var _webpackBundleAnalyzer = require("webpack-bundle-analyzer");
|
|
8
|
-
var _path = require("path");
|
|
8
|
+
var _path = _interopRequireWildcard(require("path"));
|
|
9
9
|
var _fsExtra = _interopRequireDefault(require("fs-extra"));
|
|
10
10
|
var _webpack = _interopRequireDefault(require("webpack"));
|
|
11
11
|
var _copyWebpackPlugin = _interopRequireDefault(require("copy-webpack-plugin"));
|
|
@@ -14,12 +14,15 @@ var _reactRefreshWebpackPlugin = _interopRequireDefault(require("@pmmmwh/react-r
|
|
|
14
14
|
var _speedMeasureWebpackPlugin = _interopRequireDefault(require("speed-measure-webpack-plugin"));
|
|
15
15
|
var _webpackNotifier = _interopRequireDefault(require("webpack-notifier"));
|
|
16
16
|
var _applicationExtensionsConfigPlugin = _interopRequireDefault(require("@salesforce/pwa-kit-extension-sdk/configs/webpack/application-extensions-config-plugin"));
|
|
17
|
+
var _overrideStatsPlugin = _interopRequireDefault(require("@salesforce/pwa-kit-extension-sdk/configs/webpack/override-stats-plugin"));
|
|
17
18
|
var _plugins = require("./plugins");
|
|
18
19
|
var _configNames = require("./config-names");
|
|
19
20
|
var _webpack2 = require("@salesforce/pwa-kit-extension-sdk/configs/webpack");
|
|
20
21
|
var _ssrConfig = require("@salesforce/pwa-kit-runtime/utils/ssr-config");
|
|
21
22
|
var _utils = require("@salesforce/pwa-kit-extension-sdk/shared/utils");
|
|
22
23
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
24
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
25
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
23
26
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
24
27
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
25
28
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
@@ -39,6 +42,7 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
|
|
|
39
42
|
const projectDir = process.cwd();
|
|
40
43
|
const pkg = _fsExtra.default.readJsonSync((0, _path.resolve)(projectDir, 'package.json'));
|
|
41
44
|
const buildDir = process.env.PWA_KIT_BUILD_DIR ? (0, _path.resolve)(process.env.PWA_KIT_BUILD_DIR) : (0, _path.resolve)(projectDir, 'build');
|
|
45
|
+
const isMonoRepo = _fsExtra.default.existsSync((0, _path.resolve)(projectDir, '..', '..', 'lerna.json'));
|
|
42
46
|
const production = 'production';
|
|
43
47
|
const development = 'development';
|
|
44
48
|
const analyzeBundle = process.env.MOBIFY_ANALYZE === 'true';
|
|
@@ -95,10 +99,32 @@ const findDepInStack = pkg => {
|
|
|
95
99
|
}
|
|
96
100
|
return candidate;
|
|
97
101
|
};
|
|
102
|
+
|
|
103
|
+
// Helper function to detect extensions
|
|
104
|
+
const detectExtensions = ({
|
|
105
|
+
dependencies,
|
|
106
|
+
projectDir
|
|
107
|
+
} = {}) => {
|
|
108
|
+
const extensions = [];
|
|
109
|
+
|
|
110
|
+
// Use provided dependencies or get them from package.json
|
|
111
|
+
const allDependencies = dependencies || [...Object.keys(pkg.dependencies || {}), ...Object.keys(pkg.devDependencies || {})];
|
|
112
|
+
for (const dependency of allDependencies) {
|
|
113
|
+
const packagePath = _path.default.join(projectDir || process.cwd(), 'node_modules', dependency);
|
|
114
|
+
if ((0, _utils.isExtensionPackage)(packagePath)) {
|
|
115
|
+
extensions.push(dependency);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return extensions;
|
|
119
|
+
};
|
|
120
|
+
const detectedExtensions = detectExtensions({
|
|
121
|
+
projectDir
|
|
122
|
+
});
|
|
98
123
|
const baseConfig = target => {
|
|
99
124
|
if (!['web', 'node'].includes(target)) {
|
|
100
125
|
throw Error(`The value "${target}" is not a supported webpack target`);
|
|
101
126
|
}
|
|
127
|
+
const extensions = (0, _utils.getConfiguredExtensions)((0, _ssrConfig.getConfig)());
|
|
102
128
|
class Builder {
|
|
103
129
|
constructor() {
|
|
104
130
|
this.config = _objectSpread(_objectSpread({
|
|
@@ -140,11 +166,7 @@ const baseConfig = target => {
|
|
|
140
166
|
extensions: SUPPORTED_FILE_EXTENSIONS,
|
|
141
167
|
alias: _objectSpread(_objectSpread({}, _extends(...DEPS_TO_DEDUPE.map(dep => ({
|
|
142
168
|
[dep]: findDepInStack(dep)
|
|
143
|
-
})))),
|
|
144
|
-
// TODO: This alias is temporary. When we investigate turning the retail template into an application extension
|
|
145
|
-
// we'll have to decide if we want to continue using an alias, or change back to using relative paths.
|
|
146
|
-
'@salesforce/retail-react-app': projectDir
|
|
147
|
-
}, (0, _utils.buildAliases)(Object.keys((pkg === null || pkg === void 0 ? void 0 : pkg.devDependencies) || {}).filter(dependency => dependency.match(_utils.nameRegex))))
|
|
169
|
+
})))), (0, _utils.buildAliases)(detectedExtensions))
|
|
148
170
|
}, target === 'web' ? {
|
|
149
171
|
fallback: {
|
|
150
172
|
crypto: false
|
|
@@ -156,13 +178,13 @@ const baseConfig = target => {
|
|
|
156
178
|
}
|
|
157
179
|
},
|
|
158
180
|
plugins: [new _applicationExtensionsConfigPlugin.default({
|
|
159
|
-
extensions
|
|
181
|
+
extensions
|
|
160
182
|
}), new _webpack.default.DefinePlugin({
|
|
161
183
|
DEBUG,
|
|
162
184
|
NODE_ENV: `'${process.env.NODE_ENV}'`,
|
|
163
185
|
WEBPACK_TARGET: `'${target}'`,
|
|
164
186
|
['global.GENTLY']: false
|
|
165
|
-
}),
|
|
187
|
+
}), process.env.RECORD_OVERRIDES === 'true' && new _overrideStatsPlugin.default(),
|
|
166
188
|
// new SharedStatePlugin(),
|
|
167
189
|
mode === development && new _webpack.default.NoEmitOnErrorsPlugin(), (0, _plugins.sdkReplacementPlugin)(),
|
|
168
190
|
// Don't chunk if it's a node target – faster Lambda startup.
|
|
@@ -190,14 +212,20 @@ const baseConfig = target => {
|
|
|
190
212
|
}
|
|
191
213
|
}, (0, _webpack2.ruleForApplicationExtensibility)({
|
|
192
214
|
loaderOptions: {
|
|
193
|
-
configured:
|
|
215
|
+
configured: extensions,
|
|
194
216
|
target: 'web'
|
|
195
217
|
}
|
|
196
218
|
}), (0, _webpack2.ruleForApplicationExtensibility)({
|
|
197
219
|
loaderOptions: {
|
|
198
|
-
configured:
|
|
220
|
+
configured: extensions,
|
|
199
221
|
target: 'node'
|
|
200
222
|
}
|
|
223
|
+
}), (0, _webpack2.ruleForOverrideResolver)({
|
|
224
|
+
extensions,
|
|
225
|
+
resolveExtensions: SUPPORTED_FILE_EXTENSIONS,
|
|
226
|
+
isMonoRepo,
|
|
227
|
+
projectDir,
|
|
228
|
+
target
|
|
201
229
|
})].filter(Boolean)
|
|
202
230
|
}
|
|
203
231
|
});
|
|
@@ -238,22 +266,66 @@ const staticFolderCopyPlugin = new _copyWebpackPlugin.default({
|
|
|
238
266
|
patterns: [{
|
|
239
267
|
from: 'app/static/',
|
|
240
268
|
to: 'static/'
|
|
241
|
-
}, ...
|
|
242
|
-
const packageName = extension[0];
|
|
269
|
+
}, ...detectedExtensions.map(extension => {
|
|
243
270
|
return {
|
|
244
|
-
from: `${projectDir}/node_modules/${
|
|
245
|
-
to: `static/${EXTENIONS_NAMESPACE}/${
|
|
271
|
+
from: `${projectDir}/node_modules/${extension}/static`,
|
|
272
|
+
to: `static/${EXTENIONS_NAMESPACE}/${extension}`,
|
|
246
273
|
// Add exclude for readme file.
|
|
247
274
|
noErrorOnMissing: true
|
|
248
275
|
};
|
|
249
276
|
})]
|
|
250
277
|
});
|
|
251
278
|
const ruleForBabelLoader = babelPlugins => {
|
|
279
|
+
// Handle the case when no extensions are detected
|
|
280
|
+
if (!detectedExtensions.length) {
|
|
281
|
+
return {
|
|
282
|
+
id: 'babel-loader',
|
|
283
|
+
test: /(\.js(x?)|\.ts(x?))$/,
|
|
284
|
+
exclude: /node_modules/,
|
|
285
|
+
use: [{
|
|
286
|
+
loader: findDepInStack('thread-loader'),
|
|
287
|
+
options: {
|
|
288
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
289
|
+
workers: Math.min(4, require('os').cpus().length),
|
|
290
|
+
workerParallelJobs: 100
|
|
291
|
+
}
|
|
292
|
+
}, {
|
|
293
|
+
loader: findDepInStack('babel-loader'),
|
|
294
|
+
options: _objectSpread({
|
|
295
|
+
rootMode: 'upward',
|
|
296
|
+
cacheDirectory: true
|
|
297
|
+
}, babelPlugins ? {
|
|
298
|
+
plugins: babelPlugins
|
|
299
|
+
} : {})
|
|
300
|
+
}]
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
// Pre-compute the paths to extensions for performance
|
|
305
|
+
const extensionPaths = detectedExtensions.map(ext => _path.default.normalize(`node_modules${_path.default.sep}${ext}${_path.default.sep}`));
|
|
252
306
|
return {
|
|
253
307
|
id: 'babel-loader',
|
|
254
308
|
test: /(\.js(x?)|\.ts(x?))$/,
|
|
255
|
-
|
|
309
|
+
exclude: modulePath => {
|
|
310
|
+
// Not in node_modules. Include it (don't exclude)
|
|
311
|
+
if (!modulePath.includes('node_modules')) {
|
|
312
|
+
return false;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
// Normalize path for consistent comparison
|
|
316
|
+
const normalizedPath = _path.default.normalize(modulePath);
|
|
317
|
+
|
|
318
|
+
// Check if the path includes any of our extension paths
|
|
319
|
+
return !extensionPaths.some(extPath => normalizedPath.includes(extPath));
|
|
320
|
+
},
|
|
256
321
|
use: [{
|
|
322
|
+
loader: findDepInStack('thread-loader'),
|
|
323
|
+
options: {
|
|
324
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
325
|
+
workers: Math.min(4, require('os').cpus().length),
|
|
326
|
+
workerParallelJobs: 100
|
|
327
|
+
}
|
|
328
|
+
}, {
|
|
257
329
|
loader: findDepInStack('babel-loader'),
|
|
258
330
|
options: _objectSpread({
|
|
259
331
|
rootMode: 'upward',
|
|
@@ -299,7 +371,7 @@ const client = entryPointExists(['app', 'main']) && baseConfig('web').extend(wit
|
|
|
299
371
|
// Must be named "client". See - https://www.npmjs.com/package/webpack-hot-server-middleware#usage
|
|
300
372
|
name: _configNames.CLIENT,
|
|
301
373
|
// use source map to make debugging easier
|
|
302
|
-
devtool: mode === development ? 'source-map' : false,
|
|
374
|
+
devtool: mode === development || process.env.PWA_KIT_SOURCE_MAP === 'true' ? 'source-map' : false,
|
|
303
375
|
entry: {
|
|
304
376
|
main: getAppEntryPoint()
|
|
305
377
|
},
|
|
@@ -320,9 +392,9 @@ const optional = (name, path) => {
|
|
|
320
392
|
const clientOptional = baseConfig('web').extend(config => {
|
|
321
393
|
return _objectSpread(_objectSpread({}, config), {}, {
|
|
322
394
|
name: _configNames.CLIENT_OPTIONAL,
|
|
323
|
-
entry: _objectSpread(_objectSpread(_objectSpread(
|
|
395
|
+
entry: _objectSpread(_objectSpread(_objectSpread({}, optional('loader', (0, _path.resolve)(projectDir, 'app', 'loader.js'))), optional('worker', (0, _path.resolve)(projectDir, 'worker', 'main.js'))), optional('fetch-polyfill', (0, _path.resolve)(projectDir, 'node_modules', 'whatwg-fetch'))),
|
|
324
396
|
// use source map to make debugging easier
|
|
325
|
-
devtool: mode === development ? 'source-map' : false,
|
|
397
|
+
devtool: mode === development || process.env.PWA_KIT_SOURCE_MAP === 'true' ? 'source-map' : false,
|
|
326
398
|
plugins: [...config.plugins, analyzeBundle && getBundleAnalyzerPlugin(_configNames.CLIENT_OPTIONAL)].filter(Boolean)
|
|
327
399
|
});
|
|
328
400
|
}).build();
|
|
@@ -332,7 +404,7 @@ const renderer = _fsExtra.default.existsSync((0, _path.resolve)(projectDir, 'nod
|
|
|
332
404
|
name: _configNames.SERVER,
|
|
333
405
|
entry: '@salesforce/pwa-kit-react-sdk/ssr/server/react-rendering.js',
|
|
334
406
|
// use eval-source-map for server-side debugging
|
|
335
|
-
devtool: mode === development && INSPECT ? 'eval-source-map' : false,
|
|
407
|
+
devtool: mode === development && INSPECT || process.env.PWA_KIT_SOURCE_MAP === 'true' ? 'eval-source-map' : false,
|
|
336
408
|
output: {
|
|
337
409
|
path: buildDir,
|
|
338
410
|
// We want to split the build on local development to reduce memory usage.
|
|
@@ -354,7 +426,7 @@ const ssr = (() => {
|
|
|
354
426
|
// Only compile the ssr file when we're building for prod.
|
|
355
427
|
if (mode === production) {
|
|
356
428
|
return baseConfig('node').extend(config => {
|
|
357
|
-
return _objectSpread(_objectSpread(_objectSpread({}, config), process.env.
|
|
429
|
+
return _objectSpread(_objectSpread(_objectSpread({}, config), process.env.PWA_KIT_SOURCE_MAP === 'true' ? {
|
|
358
430
|
devtool: 'source-map'
|
|
359
431
|
} : {}), {}, {
|
|
360
432
|
// Must *not* be named "server". See - https://www.npmjs.com/package/webpack-hot-server-middleware#usage
|
|
@@ -382,7 +454,7 @@ const requestProcessor = entryPointExists(['app', 'request-processor']) && baseC
|
|
|
382
454
|
libraryTarget: 'commonjs2'
|
|
383
455
|
},
|
|
384
456
|
// use eval-source-map for server-side debugging
|
|
385
|
-
devtool: mode === development && INSPECT ? 'eval-source-map' : false,
|
|
457
|
+
devtool: mode === development && INSPECT || process.env.PWA_KIT_SOURCE_MAP === 'true' ? 'eval-source-map' : false,
|
|
386
458
|
plugins: [...config.plugins, analyzeBundle && getBundleAnalyzerPlugin(_configNames.REQUEST_PROCESSOR)].filter(Boolean)
|
|
387
459
|
});
|
|
388
460
|
}).build();
|
|
@@ -7,7 +7,6 @@ exports.sdkReplacementPlugin = void 0;
|
|
|
7
7
|
var _webpack = _interopRequireDefault(require("webpack"));
|
|
8
8
|
var _path = _interopRequireWildcard(require("path"));
|
|
9
9
|
var _glob = _interopRequireDefault(require("glob"));
|
|
10
|
-
var _config = require("./config");
|
|
11
10
|
var _utils = require("./utils");
|
|
12
11
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
13
12
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -24,23 +23,7 @@ const projectDir = process.cwd();
|
|
|
24
23
|
const pkg = require((0, _path.resolve)(projectDir, 'package.json'));
|
|
25
24
|
const OVERRIDES_EXTENSIONS = '.+(js|jsx|ts|tsx)';
|
|
26
25
|
const getOverridePath = relativePath => {
|
|
27
|
-
|
|
28
|
-
const extendPath = pkg !== null && pkg !== void 0 && (_pkg$ccExtensibility = pkg.ccExtensibility) !== null && _pkg$ccExtensibility !== void 0 && _pkg$ccExtensibility.extends ? `node_modules/${_config.EXT_EXTENDS}` : '';
|
|
29
|
-
const overridePath = _config.EXT_OVERRIDES_DIR === null || _config.EXT_OVERRIDES_DIR === void 0 ? void 0 : _config.EXT_OVERRIDES_DIR.replace(/^\//, '');
|
|
30
|
-
|
|
31
|
-
// order matters here, we perform look ups starting in the following order:
|
|
32
|
-
// pkg.ccExtensibility.overridesDir => pkg.ccExtensibility.extends => current projectDir
|
|
33
|
-
if (_config.EXT_EXTENDS && _config.EXT_OVERRIDES_DIR) {
|
|
34
|
-
const filePath = `${(0, _path.resolve)(projectDir, overridePath, ...relativePath)}${OVERRIDES_EXTENSIONS}`;
|
|
35
|
-
const overrideFile = _glob.default.sync(filePath);
|
|
36
|
-
if (overrideFile !== null && overrideFile !== void 0 && overrideFile.length) {
|
|
37
|
-
return overrideFile === null || overrideFile === void 0 ? void 0 : overrideFile[0];
|
|
38
|
-
}
|
|
39
|
-
const extendFile = _glob.default.sync(`${(0, _path.resolve)(projectDir, extendPath, ...relativePath)}${OVERRIDES_EXTENSIONS}`);
|
|
40
|
-
if (extendFile !== null && extendFile !== void 0 && extendFile.length) {
|
|
41
|
-
return extendFile === null || extendFile === void 0 ? void 0 : extendFile[0];
|
|
42
|
-
}
|
|
43
|
-
}
|
|
26
|
+
// Perform lookups starting in the current projectDir
|
|
44
27
|
const generatedProjectOverride = _glob.default.sync(`${(0, _path.resolve)(projectDir, ...relativePath)}${OVERRIDES_EXTENSIONS}`);
|
|
45
28
|
return generatedProjectOverride !== null && generatedProjectOverride !== void 0 && generatedProjectOverride.length ? generatedProjectOverride === null || generatedProjectOverride === void 0 ? void 0 : generatedProjectOverride[0] : (0, _path.resolve)('node_modules', '@salesforce', 'pwa-kit-react-sdk', 'ssr', 'universal', ...relativePath.filter(item => item !== 'app'));
|
|
46
29
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/pwa-kit-dev",
|
|
3
|
-
"version": "4.0.0-extensibility-preview.
|
|
3
|
+
"version": "4.0.0-extensibility-preview.4",
|
|
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,15 +58,15 @@
|
|
|
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-extension-sdk": "4.0.0-extensibility-preview.
|
|
62
|
-
"@salesforce/pwa-kit-runtime": "4.0.0-extensibility-preview.
|
|
61
|
+
"@salesforce/pwa-kit-extension-sdk": "4.0.0-extensibility-preview.4",
|
|
62
|
+
"@salesforce/pwa-kit-runtime": "4.0.0-extensibility-preview.4",
|
|
63
63
|
"@typescript-eslint/eslint-plugin": "^5.57.0",
|
|
64
64
|
"@typescript-eslint/parser": "^5.57.0",
|
|
65
65
|
"archiver": "1.3.0",
|
|
66
66
|
"babel-jest": "^27.1.0",
|
|
67
67
|
"babel-loader": "^8.3.0",
|
|
68
68
|
"babel-plugin-dynamic-import-node-babel-7": "^2.0.7",
|
|
69
|
-
"babel-plugin-formatjs": "10.
|
|
69
|
+
"babel-plugin-formatjs": "10.5.36",
|
|
70
70
|
"babel-plugin-module-resolver": "^5.0.2",
|
|
71
71
|
"chalk": "^4.1.2",
|
|
72
72
|
"commander": "^9.5.0",
|
|
@@ -105,6 +105,7 @@
|
|
|
105
105
|
"source-map-loader": "^4.0.1",
|
|
106
106
|
"speed-measure-webpack-plugin": "^1.5.0",
|
|
107
107
|
"svg-sprite-loader": "^6.0.11",
|
|
108
|
+
"thread-loader": "^4.0.4",
|
|
108
109
|
"validator": "^13.9.0",
|
|
109
110
|
"webpack": "^5.76.3",
|
|
110
111
|
"webpack-bundle-analyzer": "^4.8.0",
|
|
@@ -123,7 +124,7 @@
|
|
|
123
124
|
"@types/node": "~16.0.3",
|
|
124
125
|
"@types/node-fetch": "~2.6.3",
|
|
125
126
|
"@types/validator": "~13.7.14",
|
|
126
|
-
"internal-lib-build": "4.0.0-extensibility-preview.
|
|
127
|
+
"internal-lib-build": "4.0.0-extensibility-preview.4",
|
|
127
128
|
"nock": "^13.3.0",
|
|
128
129
|
"nodemon": "^2.0.22",
|
|
129
130
|
"superagent": "^6.1.0",
|
|
@@ -143,11 +144,11 @@
|
|
|
143
144
|
}
|
|
144
145
|
},
|
|
145
146
|
"engines": {
|
|
146
|
-
"node": "^16.11.0 || ^18.0.0 || ^20.0.0",
|
|
147
|
-
"npm": "^8.0.0 || ^9.0.0 || ^10.0.0"
|
|
147
|
+
"node": "^16.11.0 || ^18.0.0 || ^20.0.0 || ^22.0.0",
|
|
148
|
+
"npm": "^8.0.0 || ^9.0.0 || ^10.0.0 || ^11.0.0"
|
|
148
149
|
},
|
|
149
150
|
"publishConfig": {
|
|
150
151
|
"directory": "dist"
|
|
151
152
|
},
|
|
152
|
-
"gitHead": "
|
|
153
|
+
"gitHead": "5ad3b1f0e598cfe0fbdec5b1212b4dabc0a8733c"
|
|
153
154
|
}
|
|
@@ -43,7 +43,10 @@ const DevServerMixin = exports.DevServerMixin = {
|
|
|
43
43
|
* @private
|
|
44
44
|
*/
|
|
45
45
|
_logStartupMessage(options) {
|
|
46
|
-
|
|
46
|
+
const {
|
|
47
|
+
startPath = '/'
|
|
48
|
+
} = options;
|
|
49
|
+
_loggerInstance.default.log(`Starting the DevServer on ${_chalk.default.cyan(this._getDevServerURL(options) + startPath)}`);
|
|
47
50
|
},
|
|
48
51
|
/**
|
|
49
52
|
* @private
|
|
@@ -210,6 +213,11 @@ const DevServerMixin = exports.DevServerMixin = {
|
|
|
210
213
|
next();
|
|
211
214
|
});
|
|
212
215
|
},
|
|
216
|
+
/**
|
|
217
|
+
* Serve static files from the app directory.
|
|
218
|
+
* @param filePath - The path to the file to serve.
|
|
219
|
+
* @param opts - Additional options.
|
|
220
|
+
*/
|
|
213
221
|
serveStaticFile(filePath, opts = {}) {
|
|
214
222
|
// Warning: Ugly part of the Bundle spec that we need to maintain.
|
|
215
223
|
//
|
|
@@ -233,8 +241,7 @@ const DevServerMixin = exports.DevServerMixin = {
|
|
|
233
241
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
234
242
|
const pkg = require(_path.default.resolve(process.cwd(), 'package.json'));
|
|
235
243
|
return (req, res) => {
|
|
236
|
-
|
|
237
|
-
const baseDir = _path.default.resolve(req.app.options.projectDir, pkg !== null && pkg !== void 0 && (_pkg$ccExtensibility = pkg.ccExtensibility) !== null && _pkg$ccExtensibility !== void 0 && _pkg$ccExtensibility.overridesDir ? pkg === null || pkg === void 0 ? void 0 : (_pkg$ccExtensibility2 = pkg.ccExtensibility) === null || _pkg$ccExtensibility2 === void 0 ? void 0 : (_pkg$ccExtensibility3 = _pkg$ccExtensibility2.overridesDir) === null || _pkg$ccExtensibility3 === void 0 ? void 0 : _pkg$ccExtensibility3.replace(/^\//, '') : '', 'app');
|
|
244
|
+
const baseDir = _path.default.resolve(req.app.options.projectDir, 'app');
|
|
238
245
|
return this._serveStaticFile(req, res, baseDir, filePath, opts);
|
|
239
246
|
};
|
|
240
247
|
},
|
|
@@ -306,7 +313,8 @@ const DevServerMixin = exports.DevServerMixin = {
|
|
|
306
313
|
_createHandler(app) {
|
|
307
314
|
const {
|
|
308
315
|
protocol,
|
|
309
|
-
sslFilePath
|
|
316
|
+
sslFilePath,
|
|
317
|
+
startPath = '/'
|
|
310
318
|
} = app.options;
|
|
311
319
|
const {
|
|
312
320
|
hostname,
|
|
@@ -330,7 +338,9 @@ const DevServerMixin = exports.DevServerMixin = {
|
|
|
330
338
|
}, () => {
|
|
331
339
|
/* istanbul ignore next */
|
|
332
340
|
if (process.env.NODE_ENV !== 'test') {
|
|
333
|
-
|
|
341
|
+
const targetPath = encodeURIComponent(startPath);
|
|
342
|
+
const loadingPage = `${this._getDevServerURL(app.options)}/__mrt/loading-screen/index.html?loading=1&path=${targetPath}`;
|
|
343
|
+
(0, _open.default)(loadingPage);
|
|
334
344
|
}
|
|
335
345
|
});
|
|
336
346
|
return {
|
package/utils/script-utils.js
CHANGED
|
@@ -378,18 +378,9 @@ const createBundle = exports.createBundle = /*#__PURE__*/function () {
|
|
|
378
378
|
})).then(/*#__PURE__*/_asyncToGenerator(function* () {
|
|
379
379
|
const {
|
|
380
380
|
dependencies = {},
|
|
381
|
-
devDependencies = {}
|
|
382
|
-
ccExtensibility = {
|
|
383
|
-
extends: '',
|
|
384
|
-
overridesDir: ''
|
|
385
|
-
}
|
|
381
|
+
devDependencies = {}
|
|
386
382
|
} = yield getProjectPkg();
|
|
387
|
-
const
|
|
388
|
-
let cc_overrides = [];
|
|
389
|
-
if (ccExtensibility.overridesDir) {
|
|
390
|
-
const overrides_files = yield _walkDir(ccExtensibility.overridesDir, ccExtensibility.overridesDir);
|
|
391
|
-
cc_overrides = Array.from(overrides_files).filter(item => (0, _fsExtra.existsSync)(_path.default.join(extendsTemplate, item)));
|
|
392
|
-
}
|
|
383
|
+
const cc_overrides = [];
|
|
393
384
|
const dependencyTree = yield getProjectDependencyTree();
|
|
394
385
|
// If we can't load the dependency tree, pretend that it's empty.
|
|
395
386
|
// TODO: Should we report an error?
|