@adobe-commerce/elsie 3.1.0-alpha-20261109140213 → 3.1.0-beta.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.
package/CHANGELOG.md CHANGED
@@ -1,30 +1,9 @@
1
1
  # @adobe-commerce/elsie
2
2
 
3
- ## 3.1.0-alpha-20261109140213
3
+ ## 3.1.0-beta.0
4
4
 
5
5
  ### Minor Changes
6
6
 
7
- - 19d9b59: Add a consolidated `containers.js` entry to `elsie build`. It exports
8
- every container by name, so a storefront page can load all the containers it
9
- needs with a single request instead of one request per container. This reduces
10
- request pressure on EDS. The per-container entry points
11
- (`containers/<Name>.js`) remain available for backwards compatibility, and
12
- both entries share the same `api.js`, `components.js`, `fragments.js`, and
13
- `render.js` modules.
14
-
15
- Only named imports are supported from `containers.js`:
16
-
17
- ```diff
18
- - import SignIn from '@dropins/storefront-auth/containers/SignIn.js';
19
- + import { SignIn } from '@dropins/storefront-auth/containers.js';
20
- ```
21
-
22
- `containers.js` is built from `src/containers/index.ts`. `elsie build` now
23
- fails before building if that file does not export every container directory,
24
- because a missing container would be absent from `containers.js` and could
25
- break its per-container entry. Use `export * from '<path to container>';`
26
- statements.
27
-
28
7
  - 0d54094: feat: add `StarRating` component that displays a 0-5 rating with
29
8
  partial star fill, optional value, review count and accessible label
30
9
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe-commerce/elsie",
3
- "version": "3.1.0-alpha-20261109140213",
3
+ "version": "3.1.0-beta.0",
4
4
  "license": "SEE LICENSE IN LICENSE.md",
5
5
  "description": "Domain Package SDK",
6
6
  "engines": {
@@ -1,7 +1,4 @@
1
- import fs from 'fs';
2
- import path from 'path';
3
1
  import createLocalRequire from '../../lib/create-require.cjs';
4
- import { assertContainersBarrel } from './check-containers-barrel.js';
5
2
 
6
3
  const require = createLocalRequire();
7
4
  const DEFAULT_CONFIG =
@@ -13,38 +10,12 @@ export default async function generateResourceBuilder({ argv } = {}) {
13
10
  const outDir = argv?.outDir ?? 'dist';
14
11
 
15
12
  const isProd = process.env.NODE_ENV !== 'development';
16
- const configFile = argv?.config ?? DEFAULT_CONFIG;
17
13
 
18
- // `containers.js` is built from the hand-maintained containers barrel. Fail
19
- // before building if it would leave out a container that the per-container
20
- // entries still emit: the second build pass rewrites the shared chunks to
21
- // match the barrel, which can break those per-container entries at load time.
22
- const containersBarrel = path.resolve(
23
- process.cwd(),
24
- './src/containers/index.ts',
25
- );
26
- const hasContainersBarrel = fs.existsSync(containersBarrel);
27
- if (hasContainersBarrel) {
28
- assertContainersBarrel(path.dirname(containersBarrel));
29
- }
30
-
31
- process.env.ELSIE_CONTAINERS_PASS = 'legacy';
32
14
  await build({
33
15
  mode: isProd ? 'production' : 'development',
34
16
  build: { emptyOutDir: true, outDir },
35
17
  clearScreen: true,
36
- configFile,
18
+ configFile: argv?.config ?? DEFAULT_CONFIG,
37
19
  });
38
-
39
- if (hasContainersBarrel) {
40
- process.env.ELSIE_CONTAINERS_PASS = 'consolidated';
41
- await build({
42
- mode: isProd ? 'production' : 'development',
43
- build: { emptyOutDir: false, outDir },
44
- clearScreen: false,
45
- configFile,
46
- });
47
- }
48
-
49
20
  process.exit(0);
50
21
  }
@@ -94,12 +94,26 @@ export default async function () {
94
94
  ),
95
95
  };
96
96
 
97
- // Loading this config directly retains the historic per-container output.
98
- // The CLI explicitly selects the consolidated second pass when appropriate.
99
- const containersPass = process.env.ELSIE_CONTAINERS_PASS ?? 'legacy';
100
97
  const input = {
101
98
  // render.js
102
99
  render: path.resolve(process.cwd(), './src/render/index.ts'),
100
+
101
+ // containers/*.js
102
+ ...(paths.containers
103
+ ? glob
104
+ .sync(path.resolve(paths.containers, '**/*/index.ts'))
105
+ .reduce((entries, entry) => {
106
+ const containerRegEx = new RegExp(
107
+ `${paths.containers}/(.*)/index.ts`,
108
+ );
109
+ const key = RegExp(containerRegEx).exec(entry)[1];
110
+
111
+ return {
112
+ ...entries,
113
+ [`containers/${key}`]: entry,
114
+ };
115
+ }, {})
116
+ : {}),
103
117
  };
104
118
 
105
119
  if (paths.api) {
@@ -110,24 +124,6 @@ export default async function () {
110
124
  input.fragments = path.resolve(paths.fragments);
111
125
  }
112
126
 
113
- if (paths.containers) {
114
- if (containersPass !== 'legacy') {
115
- input.containers = path.resolve(paths.containers, 'index.ts');
116
- }
117
-
118
- if (containersPass !== 'consolidated') {
119
- glob
120
- .sync(path.resolve(paths.containers, '**/*/index.ts'))
121
- .forEach((entry) => {
122
- const containerRegEx = new RegExp(
123
- `${paths.containers}/(.*)/index.ts`,
124
- );
125
- const key = RegExp(containerRegEx).exec(entry)[1];
126
- input[`containers/${key}`] = entry;
127
- });
128
- }
129
- }
130
-
131
127
  return defineConfig({
132
128
  preview: {
133
129
  port: env.PORT ?? 3002,
@@ -146,12 +142,6 @@ export default async function () {
146
142
  input,
147
143
 
148
144
  output: {
149
- // `elsie build` emits legacy per-container entries and, when present,
150
- // a consolidated containers.js barrel in separate additive passes.
151
- // Both passes write shared chunks, so their internal export names must
152
- // remain stable for cross-pass imports to stay valid.
153
- minifyInternalExports: false,
154
-
155
145
  manualChunks: (id, { getModuleInfo }) => {
156
146
  // Fragments barrel entry does not accept chunking
157
147
  if (paths.fragments && id.includes(paths.fragments))
@@ -171,7 +161,7 @@ export default async function () {
171
161
  return 'api';
172
162
  }
173
163
 
174
- // components → chunks/components.js, shared by both build passes.
164
+ // components → chunks/components.js
175
165
  if (paths.components?.some((component) => id.includes(component)))
176
166
  return 'components';
177
167
 
@@ -252,7 +242,6 @@ export default async function () {
252
242
  return (
253
243
  // for dropins
254
244
  asset.fileName.endsWith('render.js') ||
255
- asset.fileName.endsWith('containers.js') ||
256
245
  // for storybook
257
246
  asset.fileName.startsWith('assets/UIProvider')
258
247
  );
@@ -267,13 +256,8 @@ export default async function () {
267
256
  ) {
268
257
  try {
269
258
  if (typeof document != 'undefined') {
270
- const name = options.styleId;
271
-
272
- if (document.querySelector(`style[data-dropin="${name}"]`)) {
273
- return;
274
- }
275
-
276
259
  const elem = document.createElement('style');
260
+ const name = options.styleId;
277
261
 
278
262
  // SET ALL ATTRIBUTES
279
263
  for (const attribute in options.attributes) {
@@ -22,7 +22,6 @@ export function injectDropinMetadataPlugin(paths) {
22
22
  if (!paths.containers) return null;
23
23
  if (!id.startsWith(paths.containers) || !id.endsWith('/index.ts'))
24
24
  return null;
25
- if (id === path.resolve(paths.containers, 'index.ts')) return null;
26
25
 
27
26
  const name = path.relative(paths.containers, path.dirname(id));
28
27
  const ast = this.parse(code);
@@ -1,125 +0,0 @@
1
- /********************************************************************
2
- * Copyright 2026 Adobe
3
- * All Rights Reserved.
4
- *
5
- * NOTICE: Adobe permits you to use, modify, and distribute this
6
- * file in accordance with the terms of the Adobe license agreement
7
- * accompanying it.
8
- *******************************************************************/
9
-
10
- import fs from 'fs';
11
- import path from 'path';
12
-
13
- const EXPORT_ALL = /export\s*\*\s*from\s*['"]([^'"]+)['"]\s*;?/g;
14
-
15
- /**
16
- * Lists the container directories the per-container build emits: every
17
- * directory below `containersRoot` that has an `index.ts`. This mirrors the
18
- * `**\/*\/index.ts` glob used by the dropin Vite config.
19
- */
20
- function listContainerDirs(containersRoot, dir = containersRoot) {
21
- return fs
22
- .readdirSync(dir, { withFileTypes: true })
23
- .filter((entry) => entry.isDirectory() && !entry.name.startsWith('.'))
24
- .flatMap((entry) => {
25
- const full = path.join(dir, entry.name);
26
- const nested = listContainerDirs(containersRoot, full);
27
- return fs.existsSync(path.join(full, 'index.ts'))
28
- ? [path.relative(containersRoot, full), ...nested]
29
- : nested;
30
- });
31
- }
32
-
33
- /**
34
- * Converts the path of an `export * from '<path>'` statement into a path
35
- * relative to the containers folder. Accepts `./X` and `<alias>/containers/X`.
36
- * Returns undefined for any other form.
37
- */
38
- function toContainersRelative(specifier) {
39
- const aliased = /\/containers\/(.+?)(?:\/index)?$/.exec(specifier);
40
- if (aliased) return aliased[1];
41
- const relative = /^\.\/(.+?)(?:\/index)?$/.exec(specifier);
42
- return relative ? relative[1] : undefined;
43
- }
44
-
45
- /**
46
- * Checks that `src/containers/index.ts` (the source of `containers.js`) exports
47
- * every container that the per-container build emits.
48
- *
49
- * @param {string} containersRoot absolute path of `src/containers`
50
- * @returns {{ missing: string[], unsupported: string[] }}
51
- * `missing`: container directories that the barrel does not export.
52
- * `unsupported`: statements in the barrel this check cannot interpret.
53
- */
54
- export function checkContainersBarrel(containersRoot) {
55
- const containerDirs = new Set(listContainerDirs(containersRoot));
56
-
57
- // Comments (including the license header) are not statements.
58
- const source = fs
59
- .readFileSync(path.join(containersRoot, 'index.ts'), 'utf8')
60
- .replace(/\/\*[\s\S]*?\*\//g, '')
61
- .replace(/\/\/.*$/gm, '');
62
-
63
- const covered = new Set();
64
- const unsupported = [];
65
-
66
- for (const [, specifier] of source.matchAll(EXPORT_ALL)) {
67
- const target = toContainersRelative(specifier);
68
- if (target === undefined) {
69
- unsupported.push(`export * from '${specifier}'`);
70
- continue;
71
- }
72
-
73
- // `X/X` points at a file inside container `X`. Walk up to the nearest
74
- // container directory.
75
- let current = target;
76
- while (current && current !== '.' && !containerDirs.has(current)) {
77
- current = path.dirname(current);
78
- }
79
- if (containerDirs.has(current)) covered.add(current);
80
- }
81
-
82
- // Whatever is left after removing `export * from` statements is a form this
83
- // check does not understand.
84
- const leftover = source
85
- .replace(EXPORT_ALL, '')
86
- .split(';')
87
- .map((statement) => statement.replace(/\s+/g, ' ').trim())
88
- .filter(Boolean);
89
- unsupported.push(...leftover);
90
-
91
- return {
92
- missing: [...containerDirs].filter((dir) => !covered.has(dir)).sort(),
93
- unsupported,
94
- };
95
- }
96
-
97
- /**
98
- * Throws a descriptive error when the barrel is incomplete or uses an
99
- * unsupported form.
100
- *
101
- * @param {string} containersRoot absolute path of `src/containers`
102
- */
103
- export function assertContainersBarrel(containersRoot) {
104
- const { missing, unsupported } = checkContainersBarrel(containersRoot);
105
-
106
- if (unsupported.length > 0) {
107
- throw new Error(
108
- [
109
- 'src/containers/index.ts contains statements that `elsie build` cannot verify.',
110
- "Use only `export * from '<path to container>';` statements:",
111
- ...unsupported.map((statement) => ` - ${statement}`),
112
- ].join('\n'),
113
- );
114
- }
115
-
116
- if (missing.length > 0) {
117
- throw new Error(
118
- [
119
- 'src/containers/index.ts does not export every container, so containers.js would not include them:',
120
- ...missing.map((dir) => ` - ${dir}`),
121
- "Add an `export * from '<path to container>';` line for each one.",
122
- ].join('\n'),
123
- );
124
- }
125
- }