Skip to content

NXT-4206: Updated storybook to version 10#850

Open
daniel-stoian-lgp wants to merge 11 commits intodevelopfrom
feature/NXT-4206
Open

NXT-4206: Updated storybook to version 10#850
daniel-stoian-lgp wants to merge 11 commits intodevelopfrom
feature/NXT-4206

Conversation

@daniel-stoian-lgp
Copy link
Contributor

@daniel-stoian-lgp daniel-stoian-lgp commented Dec 15, 2025

Checklist

  • I have read and understand the contribution guide
  • A CHANGELOG entry is included
  • At least one test case is included for this feature or bug fix
  • Documentation was added or is not needed
  • This is an API breaking change

Issue Resolved / Feature Added

Latest storybook is 10.x

Resolution

Updated storybook to version 10
Update configuration to work with ESM
Changed custom addon configuration to work in ESM
In the release notes for storybook 10 it denotes as the only breaking change that Storybook is now ESM only:
https://github.com/storybookjs/storybook/releases/tag/v10.0.0

Additional Considerations

Migration guide made by storybook team: https://storybook.js.org/docs/releases/migration-guide

fileURLToPath has been imported from url and dirname has been imported from path. This imports will be used to create similar files in ESM as we had in commonJS thus minimizing the changes made to this repo. fileURLToPath will be used to create the __filename we use as a parameter for dirname (const __filename = fileURLToPath(import.meta.url)).
We use dirname to create the variable __dirname which used to be a global variable and pass it to the webpack function as a parameter (const __dirname = dirname(__filename)).
This is the node documentation for this functions:
https://nodejs.org/api/url.html#urlfileurltopathurl-options
https://nodejs.org/api/path.html#pathdirnamepath

When it comes to our custom addons, it is recommended to switch from exportEntries to managerEntries (https://storybook.js.org/docs/addons/addon-migration-guide). For this reason we added a new property in our export object called managerEntries such: managerEntries: [resolve(__dirname, '../custom-addon/manager.js')].

We also needed to change syntax from JSX to React.createComponent because, since the change to ESM, storybook does not permit use of JSX in addons. This components are used in the same way as before, just the return statement was changed from return () => <Component {...props} /> to return React.createElement(Component, {...props}).

Links

NXT-4206

Comments

Enact-DCO-1.0-Signed-off-by: Daniel Stoian (daniel.stoian@lgepartner.com)

# Conflicts:
#	samples/sampler/npm-shrinkwrap.json
#	samples/sampler/package.json
@codecov
Copy link

codecov bot commented Dec 15, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.08%. Comparing base (279e37a) to head (cb49c8a).

Additional details and impacted files
@@           Coverage Diff            @@
##           develop     #850   +/-   ##
========================================
  Coverage    85.08%   85.08%           
========================================
  Files          118      118           
  Lines         4491     4491           
  Branches      1226     1226           
========================================
  Hits          3821     3821           
  Misses         517      517           
  Partials       153      153           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@hong6316
Copy link
Contributor

hong6316 commented Mar 6, 2026

Please list the breaking changes between Storybook v9 -> v10 in Resolution.

/* global __dirname */
import webpack from '@enact/storybook-utils/configs/webpack.js';
import {readFileSync} from 'fs';
import {dirname, resolve} from 'path';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a change log and related link into Additional consideration.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import {dirname, resolve} from 'path';

The code has been added, but you need to write in Additional consideration why it was added and where it is used.

import {readFileSync} from 'fs';
import {dirname, resolve} from 'path';
import {loadCsf} from 'storybook/internal/csf-tools';
import {fileURLToPath} from 'url';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a change log and related link into Additional consideration.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import {fileURLToPath} from 'url';

The code has been added, but you need to write in Additional consideration why it was added and where it is used.

const webpack = require('@enact/storybook-utils/configs/webpack');
const {loadCsf} = require('storybook/internal/csf-tools');
const {readFileSync} = require('fs');
const __filename = fileURLToPath(import.meta.url);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a change log and related link into Additional consideration.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const __filename = fileURLToPath(import.meta.url);

The code has been added, but you need to write in Additional consideration why it was added and where it is used.

const {loadCsf} = require('storybook/internal/csf-tools');
const {readFileSync} = require('fs');
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a change log and related link into Additional consideration.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const __dirname = dirname(__filename);

The code has been added, but you need to write in Additional consideration why it was added and where it is used.

'../custom-addon/manager.js'
'@storybook/addon-docs'
],
managerEntries: [resolve(__dirname, '../custom-addon/manager.js')],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a change log and related link into Additional consideration.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

managerEntries: [resolve(__dirname, '../custom-addon/manager.js')],

The code has been added, but you need to write in Additional consideration why it was added and where it is used.

toolbarParamKey={toolbarParamKey}
/>
);
return React.createElement(ToolbarTab, {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a change log and related link into Additional consideration.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return React.createElement(ToolbarTab, {

The code has been changed, but you need to write in Additional consideration why it was changed and where it is used.

const renderHighlightColorPickerTab = () => <Toolbar param={HIGHLIGHT_PARAM_KEY} isColorPicker />;
const renderDefaultSkinsTab = () => <Toolbar param={DEFAULTSKINS_PARAM_KEY} isColorPicker={false} />;
const renderAccentColorPickerTab = () =>
React.createElement(Toolbar, {param: ACCENT_PARAM_KEY, isColorPicker: true});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a change log and related link into Additional consideration.

React.createElement(Toolbar, {param: ACCENT_PARAM_KEY, isColorPicker: true});

const renderHighlightColorPickerTab = () =>
React.createElement(Toolbar, {param: HIGHLIGHT_PARAM_KEY, isColorPicker: true});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a change log and related link into Additional consideration.

React.createElement(Toolbar, {param: HIGHLIGHT_PARAM_KEY, isColorPicker: true});

const renderDefaultSkinsTab = () =>
React.createElement(Toolbar, {param: DEFAULTSKINS_PARAM_KEY, isColorPicker: false});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a change log and related link into Additional consideration.

if (isColorPicker) {
return {
center: <ColorPicker colorPickerType={colorPickerType} />,
center: React.createElement(ColorPicker, {colorPickerType: colorPickerType}),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a change log and related link into Additional consideration.

>
<ToolbarTab toolbarParamKey={toolbarParamKey} />
</WithTooltip>
return React.createElement(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a change log and related link into Additional consideration.

if (globals['show all skins'] === "true") return null;

return <DefaultSkinToolbarTab toolbarParamKey={toolbarParamKey} />;
return React.createElement(DefaultSkinToolbarTab, {toolbarParamKey: toolbarParamKey});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a change log and related link into Additional consideration.

{toolbarParamKey}
</IconButton>
const ToolbarTab = ({isActive, toggleState, toolbarParamKey}) => {
return React.createElement(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a change log and related link into Additional consideration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants