@salesforce/storefront-next-dev 0.4.0-alpha.0 → 0.4.0-alpha.2
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/dist/commands/dev.js
CHANGED
|
@@ -41,6 +41,40 @@ function getWorkspaceHmrConfig(httpServer) {
|
|
|
41
41
|
//#endregion
|
|
42
42
|
//#region src/lib/dev.ts
|
|
43
43
|
/**
|
|
44
|
+
* Resolve Node.js custom export conditions from process arguments.
|
|
45
|
+
*
|
|
46
|
+
* Reads both `process.execArgv` and `NODE_OPTIONS` so conditions passed through
|
|
47
|
+
* wrapper CLIs are still applied to Vite and SSR resolution.
|
|
48
|
+
*
|
|
49
|
+
* Environment variables:
|
|
50
|
+
* - `NODE_OPTIONS` (optional): Node runtime flags that may include one or more
|
|
51
|
+
* `--conditions` entries.
|
|
52
|
+
*
|
|
53
|
+
* @returns Ordered, de-duplicated list of `--conditions` values.
|
|
54
|
+
*/
|
|
55
|
+
function getNodeResolveConditions() {
|
|
56
|
+
const conditions = [];
|
|
57
|
+
const args = [...process.execArgv];
|
|
58
|
+
const nodeOptions = process.env.NODE_OPTIONS ?? "";
|
|
59
|
+
if (nodeOptions.trim()) args.push(...nodeOptions.split(/\s+/).filter(Boolean));
|
|
60
|
+
for (let i = 0; i < args.length; i += 1) {
|
|
61
|
+
const arg = args[i];
|
|
62
|
+
if (arg.startsWith("--conditions=")) {
|
|
63
|
+
const value = arg.slice(13).trim();
|
|
64
|
+
if (value) conditions.push(value);
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
if (arg === "--conditions") {
|
|
68
|
+
const value = args[i + 1]?.trim();
|
|
69
|
+
if (value) {
|
|
70
|
+
conditions.push(value);
|
|
71
|
+
i += 1;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return [...new Set(conditions)];
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
44
78
|
* Start the development server with Vite in middleware mode
|
|
45
79
|
*/
|
|
46
80
|
async function dev(options = {}) {
|
|
@@ -53,8 +87,17 @@ async function dev(options = {}) {
|
|
|
53
87
|
const config = await loadProjectConfig(projectDir);
|
|
54
88
|
const httpServer = createServer();
|
|
55
89
|
const hmr = getWorkspaceHmrConfig(httpServer);
|
|
90
|
+
const resolveConditions = getNodeResolveConditions();
|
|
56
91
|
const vite = await createServer$1({
|
|
57
92
|
root: projectDir,
|
|
93
|
+
...resolveConditions.length > 0 ? {
|
|
94
|
+
resolve: { conditions: resolveConditions },
|
|
95
|
+
optimizeDeps: { esbuildOptions: { conditions: resolveConditions } },
|
|
96
|
+
ssr: { resolve: {
|
|
97
|
+
conditions: resolveConditions,
|
|
98
|
+
externalConditions: resolveConditions
|
|
99
|
+
} }
|
|
100
|
+
} : {},
|
|
58
101
|
server: {
|
|
59
102
|
middlewareMode: true,
|
|
60
103
|
...hmr && { hmr }
|
package/dist/logger.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/storefront-next-dev",
|
|
3
|
-
"version": "0.4.0-alpha.
|
|
3
|
+
"version": "0.4.0-alpha.2",
|
|
4
4
|
"description": "Dev and build tools for SFCC Storefront Next",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -13,12 +13,6 @@
|
|
|
13
13
|
"default": "./dist/index.js"
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
|
-
"./data-store/local-provider": {
|
|
17
|
-
"import": {
|
|
18
|
-
"types": "./dist/data-store/local-provider.d.ts",
|
|
19
|
-
"default": "./dist/data-store/local-provider.js"
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
16
|
"./logger": {
|
|
23
17
|
"import": {
|
|
24
18
|
"types": "./dist/logger/index.d.ts",
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
//#region src/data-store/local-provider.d.ts
|
|
2
|
-
/**
|
|
3
|
-
* Copyright 2026 Salesforce, Inc.
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
* See the License for the specific language governing permissions and
|
|
15
|
-
* limitations under the License.
|
|
16
|
-
*/
|
|
17
|
-
type DataStoreEntry = {
|
|
18
|
-
value?: unknown;
|
|
19
|
-
};
|
|
20
|
-
type LocalDataStoreProvider = {
|
|
21
|
-
kind: 'local';
|
|
22
|
-
getEntry: (key: string) => Promise<DataStoreEntry | null>;
|
|
23
|
-
};
|
|
24
|
-
type LocalDataStoreProviderOptions = {
|
|
25
|
-
defaults?: Record<string, Record<string, unknown>>;
|
|
26
|
-
warnOnMissing?: boolean;
|
|
27
|
-
};
|
|
28
|
-
/**
|
|
29
|
-
* Create a local data-store provider for development environments.
|
|
30
|
-
*
|
|
31
|
-
* Environment variables:
|
|
32
|
-
* - `SFNEXT_DATA_STORE_DEFAULTS` (optional): JSON map of keys to preference objects.
|
|
33
|
-
* Example: {"custom-global-preferences":{"featureFlag":true}}
|
|
34
|
-
* - `SFNEXT_DATA_STORE_WARN_ON_MISSING` (optional): Set to "false" to silence warnings.
|
|
35
|
-
*
|
|
36
|
-
* @param options - Optional defaults and warning controls for local entries.
|
|
37
|
-
* @returns Local provider that supplies preferences from defaults or empty values.
|
|
38
|
-
*/
|
|
39
|
-
declare function createLocalDataStoreProvider(options?: LocalDataStoreProviderOptions): LocalDataStoreProvider;
|
|
40
|
-
//#endregion
|
|
41
|
-
export { LocalDataStoreProvider, createLocalDataStoreProvider };
|
|
42
|
-
//# sourceMappingURL=local-provider.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"local-provider.d.ts","names":[],"sources":["../../src/data-store/local-provider.ts"],"sourcesContent":[],"mappings":";;;AAoBA;AAGE;AAkBF;;;;;;;;;;;KAzBK,cAAA;;;KAIO,sBAAA;;6BAEmB,QAAQ;;KAGlC,6BAAA;aACU,eAAe;;;;;;;;;;;;;;iBAed,4BAAA,WAAsC,gCAAqC"}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
//#region src/data-store/local-provider.ts
|
|
2
|
-
/**
|
|
3
|
-
* Create a local data-store provider for development environments.
|
|
4
|
-
*
|
|
5
|
-
* Environment variables:
|
|
6
|
-
* - `SFNEXT_DATA_STORE_DEFAULTS` (optional): JSON map of keys to preference objects.
|
|
7
|
-
* Example: {"custom-global-preferences":{"featureFlag":true}}
|
|
8
|
-
* - `SFNEXT_DATA_STORE_WARN_ON_MISSING` (optional): Set to "false" to silence warnings.
|
|
9
|
-
*
|
|
10
|
-
* @param options - Optional defaults and warning controls for local entries.
|
|
11
|
-
* @returns Local provider that supplies preferences from defaults or empty values.
|
|
12
|
-
*/
|
|
13
|
-
function createLocalDataStoreProvider(options = {}) {
|
|
14
|
-
const defaults = options.defaults ?? readDefaultsFromEnv();
|
|
15
|
-
const warnOnMissing = options.warnOnMissing ?? readWarnOnMissingFromEnv();
|
|
16
|
-
const warnedKeys = /* @__PURE__ */ new Set();
|
|
17
|
-
return {
|
|
18
|
-
kind: "local",
|
|
19
|
-
getEntry(key) {
|
|
20
|
-
const value = defaults[key];
|
|
21
|
-
if (value && typeof value === "object") return Promise.resolve({ value });
|
|
22
|
-
if (warnOnMissing && !warnedKeys.has(key)) {
|
|
23
|
-
warnedKeys.add(key);
|
|
24
|
-
console.warn(`Local data-store provider did not find '${key}'. Returning an empty object for development.`);
|
|
25
|
-
}
|
|
26
|
-
return Promise.resolve({ value: {} });
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Read default data-store entries from the environment.
|
|
32
|
-
*
|
|
33
|
-
* Environment variables:
|
|
34
|
-
* - `SFNEXT_DATA_STORE_DEFAULTS` (optional): JSON map of keys to preference objects.
|
|
35
|
-
* Example: {"custom-global-preferences":{"featureFlag":true}}
|
|
36
|
-
*
|
|
37
|
-
* @returns Parsed defaults map or an empty object.
|
|
38
|
-
*/
|
|
39
|
-
function readDefaultsFromEnv() {
|
|
40
|
-
const raw = process.env.SFNEXT_DATA_STORE_DEFAULTS;
|
|
41
|
-
if (!raw) return {};
|
|
42
|
-
try {
|
|
43
|
-
const parsed = JSON.parse(raw);
|
|
44
|
-
if (parsed && typeof parsed === "object") return parsed;
|
|
45
|
-
} catch (error) {
|
|
46
|
-
console.warn("Failed to parse SFNEXT_DATA_STORE_DEFAULTS JSON.", error);
|
|
47
|
-
}
|
|
48
|
-
return {};
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Read warn-on-missing behavior from the environment.
|
|
52
|
-
*
|
|
53
|
-
* Environment variables:
|
|
54
|
-
* - `SFNEXT_DATA_STORE_WARN_ON_MISSING` (optional): Set to "false" to silence warnings.
|
|
55
|
-
*
|
|
56
|
-
* @returns True when warnings should be emitted for missing entries.
|
|
57
|
-
*/
|
|
58
|
-
function readWarnOnMissingFromEnv() {
|
|
59
|
-
const raw = process.env.SFNEXT_DATA_STORE_WARN_ON_MISSING;
|
|
60
|
-
if (!raw) return true;
|
|
61
|
-
return raw.toLowerCase() !== "false";
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
//#endregion
|
|
65
|
-
export { createLocalDataStoreProvider };
|
|
66
|
-
//# sourceMappingURL=local-provider.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"local-provider.js","names":[],"sources":["../../src/data-store/local-provider.ts"],"sourcesContent":["/**\n * Copyright 2026 Salesforce, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\ntype DataStoreEntry = {\n value?: unknown;\n};\n\nexport type LocalDataStoreProvider = {\n kind: 'local';\n getEntry: (key: string) => Promise<DataStoreEntry | null>;\n};\n\ntype LocalDataStoreProviderOptions = {\n defaults?: Record<string, Record<string, unknown>>;\n warnOnMissing?: boolean;\n};\n\n/**\n * Create a local data-store provider for development environments.\n *\n * Environment variables:\n * - `SFNEXT_DATA_STORE_DEFAULTS` (optional): JSON map of keys to preference objects.\n * Example: {\"custom-global-preferences\":{\"featureFlag\":true}}\n * - `SFNEXT_DATA_STORE_WARN_ON_MISSING` (optional): Set to \"false\" to silence warnings.\n *\n * @param options - Optional defaults and warning controls for local entries.\n * @returns Local provider that supplies preferences from defaults or empty values.\n */\nexport function createLocalDataStoreProvider(options: LocalDataStoreProviderOptions = {}): LocalDataStoreProvider {\n const defaults = options.defaults ?? readDefaultsFromEnv();\n const warnOnMissing = options.warnOnMissing ?? readWarnOnMissingFromEnv();\n const warnedKeys = new Set<string>();\n\n return {\n kind: 'local',\n getEntry(key: string) {\n const value = defaults[key];\n if (value && typeof value === 'object') {\n return Promise.resolve({ value });\n }\n\n if (warnOnMissing && !warnedKeys.has(key)) {\n warnedKeys.add(key);\n // eslint-disable-next-line no-console\n console.warn(\n `Local data-store provider did not find '${key}'. Returning an empty object for development.`\n );\n }\n\n return Promise.resolve({ value: {} });\n },\n };\n}\n\n/**\n * Read default data-store entries from the environment.\n *\n * Environment variables:\n * - `SFNEXT_DATA_STORE_DEFAULTS` (optional): JSON map of keys to preference objects.\n * Example: {\"custom-global-preferences\":{\"featureFlag\":true}}\n *\n * @returns Parsed defaults map or an empty object.\n */\nfunction readDefaultsFromEnv(): Record<string, Record<string, unknown>> {\n const raw = process.env.SFNEXT_DATA_STORE_DEFAULTS;\n if (!raw) {\n return {};\n }\n\n try {\n const parsed = JSON.parse(raw);\n if (parsed && typeof parsed === 'object') {\n return parsed as Record<string, Record<string, unknown>>;\n }\n } catch (error) {\n // eslint-disable-next-line no-console\n console.warn('Failed to parse SFNEXT_DATA_STORE_DEFAULTS JSON.', error);\n }\n\n return {};\n}\n\n/**\n * Read warn-on-missing behavior from the environment.\n *\n * Environment variables:\n * - `SFNEXT_DATA_STORE_WARN_ON_MISSING` (optional): Set to \"false\" to silence warnings.\n *\n * @returns True when warnings should be emitted for missing entries.\n */\nfunction readWarnOnMissingFromEnv(): boolean {\n const raw = process.env.SFNEXT_DATA_STORE_WARN_ON_MISSING;\n if (!raw) {\n return true;\n }\n return raw.toLowerCase() !== 'false';\n}\n"],"mappings":";;;;;;;;;;;;AAyCA,SAAgB,6BAA6B,UAAyC,EAAE,EAA0B;CAC9G,MAAM,WAAW,QAAQ,YAAY,qBAAqB;CAC1D,MAAM,gBAAgB,QAAQ,iBAAiB,0BAA0B;CACzE,MAAM,6BAAa,IAAI,KAAa;AAEpC,QAAO;EACH,MAAM;EACN,SAAS,KAAa;GAClB,MAAM,QAAQ,SAAS;AACvB,OAAI,SAAS,OAAO,UAAU,SAC1B,QAAO,QAAQ,QAAQ,EAAE,OAAO,CAAC;AAGrC,OAAI,iBAAiB,CAAC,WAAW,IAAI,IAAI,EAAE;AACvC,eAAW,IAAI,IAAI;AAEnB,YAAQ,KACJ,2CAA2C,IAAI,+CAClD;;AAGL,UAAO,QAAQ,QAAQ,EAAE,OAAO,EAAE,EAAE,CAAC;;EAE5C;;;;;;;;;;;AAYL,SAAS,sBAA+D;CACpE,MAAM,MAAM,QAAQ,IAAI;AACxB,KAAI,CAAC,IACD,QAAO,EAAE;AAGb,KAAI;EACA,MAAM,SAAS,KAAK,MAAM,IAAI;AAC9B,MAAI,UAAU,OAAO,WAAW,SAC5B,QAAO;UAEN,OAAO;AAEZ,UAAQ,KAAK,oDAAoD,MAAM;;AAG3E,QAAO,EAAE;;;;;;;;;;AAWb,SAAS,2BAAoC;CACzC,MAAM,MAAM,QAAQ,IAAI;AACxB,KAAI,CAAC,IACD,QAAO;AAEX,QAAO,IAAI,aAAa,KAAK"}
|