Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: only apply enable package exports selectively #621

Merged
merged 2 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions examples/expo-example/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "expo-example",
"version": "8.3.7",
"version": "8.3.8-alpha.0",
"private": true,
"main": "index.js",
"scripts": {
Expand Down Expand Up @@ -28,19 +28,19 @@
"@storybook/addon-essentials": "^8.3.5",
"@storybook/addon-interactions": "^8.3.5",
"@storybook/addon-links": "^8.3.5",
"@storybook/addon-ondevice-actions": "^8.3.7",
"@storybook/addon-ondevice-backgrounds": "^8.3.7",
"@storybook/addon-ondevice-controls": "^8.3.7",
"@storybook/addon-ondevice-notes": "^8.3.7",
"@storybook/addon-ondevice-actions": "^8.3.8-alpha.0",
"@storybook/addon-ondevice-backgrounds": "^8.3.8-alpha.0",
"@storybook/addon-ondevice-controls": "^8.3.8-alpha.0",
"@storybook/addon-ondevice-notes": "^8.3.8-alpha.0",
"@storybook/addon-react-native-server": "0.0.6",
"@storybook/addon-react-native-web": "^0.0.22",
"@storybook/addon-webpack5-compiler-babel": "^3.0.3",
"@storybook/blocks": "^8.3.5",
"@storybook/builder-webpack5": "^8.3.5",
"@storybook/global": "^5.0.0",
"@storybook/react": "^8.3.5",
"@storybook/react-native": "^8.3.7",
"@storybook/react-native-theming": "^8.3.7",
"@storybook/react-native": "^8.3.8-alpha.0",
"@storybook/react-native-theming": "^8.3.8-alpha.0",
"@storybook/react-webpack5": "^8.3.5",
"@storybook/test": "^8.3.5",
"expo": "^51.0.34",
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"npmClient": "yarn",
"registry": "https://registry.npmjs.org",
"version": "8.3.7"
"version": "8.3.8-alpha.0"
}
2 changes: 1 addition & 1 deletion packages/ondevice-actions/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@storybook/addon-ondevice-actions",
"version": "8.3.7",
"version": "8.3.8-alpha.0",
"description": "Action Logger addon for react-native storybook",
"keywords": [
"storybook"
Expand Down
4 changes: 2 additions & 2 deletions packages/ondevice-backgrounds/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@storybook/addon-ondevice-backgrounds",
"version": "8.3.7",
"version": "8.3.8-alpha.0",
"description": "A react-native storybook addon to show different backgrounds for your preview",
"keywords": [
"addon",
Expand Down Expand Up @@ -33,7 +33,7 @@
},
"dependencies": {
"@storybook/core": "^8.3.5",
"@storybook/react-native-theming": "^8.3.7"
"@storybook/react-native-theming": "^8.3.8-alpha.0"
},
"devDependencies": {
"typescript": "^5.3.3"
Expand Down
6 changes: 3 additions & 3 deletions packages/ondevice-controls/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@storybook/addon-ondevice-controls",
"version": "8.3.7",
"version": "8.3.8-alpha.0",
"description": "Display storybook controls on your device.",
"keywords": [
"addon",
Expand Down Expand Up @@ -32,8 +32,8 @@
"dependencies": {
"@storybook/addon-controls": "^8.3.5",
"@storybook/core": "^8.3.5",
"@storybook/react-native-theming": "^8.3.7",
"@storybook/react-native-ui": "^8.3.7",
"@storybook/react-native-theming": "^8.3.8-alpha.0",
"@storybook/react-native-ui": "^8.3.8-alpha.0",
"deep-equal": "^1.0.1",
"prop-types": "^15.7.2",
"react-native-modal-datetime-picker": "^14.0.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/ondevice-notes/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@storybook/addon-ondevice-notes",
"version": "8.3.7",
"version": "8.3.8-alpha.0",
"description": "Write notes for your react-native Storybook stories.",
"keywords": [
"addon",
Expand Down Expand Up @@ -30,7 +30,7 @@
},
"dependencies": {
"@storybook/core": "^8.3.5",
"@storybook/react-native-theming": "^8.3.7",
"@storybook/react-native-theming": "^8.3.8-alpha.0",
"react-native-markdown-display": "^7.0.2"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native-theming/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@storybook/react-native-theming",
"version": "8.3.7",
"version": "8.3.8-alpha.0",
"description": "A wrapper library around emotion 11 to provide theming support for react-native storybook",
"keywords": [
"react",
Expand Down
4 changes: 2 additions & 2 deletions packages/react-native-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@storybook/react-native-ui",
"version": "8.3.7",
"version": "8.3.8-alpha.0",
"description": "ui components for react native storybook",
"keywords": [
"react",
Expand Down Expand Up @@ -59,7 +59,7 @@
"dependencies": {
"@storybook/core": "^8.3.5",
"@storybook/react": "^8.3.5",
"@storybook/react-native-theming": "^8.3.7",
"@storybook/react-native-theming": "^8.3.8-alpha.0",
"fuse.js": "^7.0.0",
"memoizerific": "^1.11.3",
"polished": "^4.3.1",
Expand Down
21 changes: 15 additions & 6 deletions packages/react-native/metro/withStorybook.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,29 @@ module.exports = (
},
resolver: {
...config.resolver,
unstable_enablePackageExports: true,
resolveRequest: (context, moduleName, platform) => {
const defaultResolveResult = config?.resolver?.resolveRequest
? config?.resolver?.resolveRequest?.(context, moduleName, platform)
: context.resolveRequest(context, moduleName, platform);
const resolveFunction = config?.resolver?.resolveRequest
? config?.resolver?.resolveRequest
: context.resolveRequest;

const isStorybookModule =
moduleName.startsWith('storybook') || moduleName.startsWith('@storybook');

if (isStorybookModule) {
context.unstable_enablePackageExports = true;
context.unstable_conditionNames = ['import'];
}

const resolveResult = resolveFunction(context, moduleName, platform);

// workaround for template files with invalid imports
if (defaultResolveResult?.filePath?.includes?.('@storybook/react/template/cli')) {
if (resolveResult?.filePath?.includes?.('@storybook/react/template/cli')) {
return {
type: 'empty',
};
}

return defaultResolveResult;
return resolveResult;
},
},
};
Expand Down
6 changes: 3 additions & 3 deletions packages/react-native/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@storybook/react-native",
"version": "8.3.7",
"version": "8.3.8-alpha.0",
"description": "A better way to develop React Native Components for your app",
"keywords": [
"react",
Expand Down Expand Up @@ -43,8 +43,8 @@
"@storybook/csf": "^0.1.1",
"@storybook/global": "^5.0.0",
"@storybook/react": "^8.3.5",
"@storybook/react-native-theming": "^8.3.7",
"@storybook/react-native-ui": "^8.3.7",
"@storybook/react-native-theming": "^8.3.8-alpha.0",
"@storybook/react-native-ui": "^8.3.8-alpha.0",
"chokidar": "^3.5.1",
"commander": "^8.2.0",
"dedent": "^1.5.1",
Expand Down
40 changes: 20 additions & 20 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4549,7 +4549,7 @@ __metadata:
languageName: node
linkType: hard

"@storybook/addon-ondevice-actions@npm:^8.3.7, @storybook/addon-ondevice-actions@workspace:packages/ondevice-actions":
"@storybook/addon-ondevice-actions@npm:^8.3.8-alpha.0, @storybook/addon-ondevice-actions@workspace:packages/ondevice-actions":
version: 0.0.0-use.local
resolution: "@storybook/addon-ondevice-actions@workspace:packages/ondevice-actions"
dependencies:
Expand All @@ -4564,27 +4564,27 @@ __metadata:
languageName: unknown
linkType: soft

"@storybook/addon-ondevice-backgrounds@npm:^8.3.7, @storybook/addon-ondevice-backgrounds@workspace:packages/ondevice-backgrounds":
"@storybook/addon-ondevice-backgrounds@npm:^8.3.8-alpha.0, @storybook/addon-ondevice-backgrounds@workspace:packages/ondevice-backgrounds":
version: 0.0.0-use.local
resolution: "@storybook/addon-ondevice-backgrounds@workspace:packages/ondevice-backgrounds"
dependencies:
"@storybook/core": "npm:^8.3.5"
"@storybook/react-native-theming": "npm:^8.3.7"
"@storybook/react-native-theming": "npm:^8.3.8-alpha.0"
typescript: "npm:^5.3.3"
peerDependencies:
react: "*"
react-native: "*"
languageName: unknown
linkType: soft

"@storybook/addon-ondevice-controls@npm:^8.3.7, @storybook/addon-ondevice-controls@workspace:packages/ondevice-controls":
"@storybook/addon-ondevice-controls@npm:^8.3.8-alpha.0, @storybook/addon-ondevice-controls@workspace:packages/ondevice-controls":
version: 0.0.0-use.local
resolution: "@storybook/addon-ondevice-controls@workspace:packages/ondevice-controls"
dependencies:
"@storybook/addon-controls": "npm:^8.3.5"
"@storybook/core": "npm:^8.3.5"
"@storybook/react-native-theming": "npm:^8.3.7"
"@storybook/react-native-ui": "npm:^8.3.7"
"@storybook/react-native-theming": "npm:^8.3.8-alpha.0"
"@storybook/react-native-ui": "npm:^8.3.8-alpha.0"
cross-env: "npm:^7.0.3"
deep-equal: "npm:^1.0.1"
prop-types: "npm:^15.7.2"
Expand All @@ -4601,12 +4601,12 @@ __metadata:
languageName: unknown
linkType: soft

"@storybook/addon-ondevice-notes@npm:^8.3.7, @storybook/addon-ondevice-notes@workspace:packages/ondevice-notes":
"@storybook/addon-ondevice-notes@npm:^8.3.8-alpha.0, @storybook/addon-ondevice-notes@workspace:packages/ondevice-notes":
version: 0.0.0-use.local
resolution: "@storybook/addon-ondevice-notes@workspace:packages/ondevice-notes"
dependencies:
"@storybook/core": "npm:^8.3.5"
"@storybook/react-native-theming": "npm:^8.3.7"
"@storybook/react-native-theming": "npm:^8.3.8-alpha.0"
react-native-markdown-display: "npm:^7.0.2"
typescript: "npm:^5.3.3"
peerDependencies:
Expand Down Expand Up @@ -4927,7 +4927,7 @@ __metadata:
languageName: node
linkType: hard

"@storybook/react-native-theming@npm:^8.3.7, @storybook/react-native-theming@workspace:packages/react-native-theming":
"@storybook/react-native-theming@npm:^8.3.8-alpha.0, @storybook/react-native-theming@workspace:packages/react-native-theming":
version: 0.0.0-use.local
resolution: "@storybook/react-native-theming@workspace:packages/react-native-theming"
dependencies:
Expand All @@ -4941,13 +4941,13 @@ __metadata:
languageName: unknown
linkType: soft

"@storybook/react-native-ui@npm:^8.3.7, @storybook/react-native-ui@workspace:packages/react-native-ui":
"@storybook/react-native-ui@npm:^8.3.8-alpha.0, @storybook/react-native-ui@workspace:packages/react-native-ui":
version: 0.0.0-use.local
resolution: "@storybook/react-native-ui@workspace:packages/react-native-ui"
dependencies:
"@storybook/core": "npm:^8.3.5"
"@storybook/react": "npm:^8.3.5"
"@storybook/react-native-theming": "npm:^8.3.7"
"@storybook/react-native-theming": "npm:^8.3.8-alpha.0"
"@types/jest": "npm:^29.4.3"
"@types/react": "npm:~18.2.79"
babel-jest: "npm:^29.4.3"
Expand All @@ -4970,16 +4970,16 @@ __metadata:
languageName: unknown
linkType: soft

"@storybook/react-native@npm:^8.3.7, @storybook/react-native@workspace:packages/react-native":
"@storybook/react-native@npm:^8.3.8-alpha.0, @storybook/react-native@workspace:packages/react-native":
version: 0.0.0-use.local
resolution: "@storybook/react-native@workspace:packages/react-native"
dependencies:
"@storybook/core": "npm:^8.3.5"
"@storybook/csf": "npm:^0.1.1"
"@storybook/global": "npm:^5.0.0"
"@storybook/react": "npm:^8.3.5"
"@storybook/react-native-theming": "npm:^8.3.7"
"@storybook/react-native-ui": "npm:^8.3.7"
"@storybook/react-native-theming": "npm:^8.3.8-alpha.0"
"@storybook/react-native-ui": "npm:^8.3.8-alpha.0"
"@types/jest": "npm:^29.4.3"
"@types/react": "npm:~18.2.79"
babel-jest: "npm:^29.4.3"
Expand Down Expand Up @@ -9693,19 +9693,19 @@ __metadata:
"@storybook/addon-essentials": "npm:^8.3.5"
"@storybook/addon-interactions": "npm:^8.3.5"
"@storybook/addon-links": "npm:^8.3.5"
"@storybook/addon-ondevice-actions": "npm:^8.3.7"
"@storybook/addon-ondevice-backgrounds": "npm:^8.3.7"
"@storybook/addon-ondevice-controls": "npm:^8.3.7"
"@storybook/addon-ondevice-notes": "npm:^8.3.7"
"@storybook/addon-ondevice-actions": "npm:^8.3.8-alpha.0"
"@storybook/addon-ondevice-backgrounds": "npm:^8.3.8-alpha.0"
"@storybook/addon-ondevice-controls": "npm:^8.3.8-alpha.0"
"@storybook/addon-ondevice-notes": "npm:^8.3.8-alpha.0"
"@storybook/addon-react-native-server": "npm:0.0.6"
"@storybook/addon-react-native-web": "npm:^0.0.22"
"@storybook/addon-webpack5-compiler-babel": "npm:^3.0.3"
"@storybook/blocks": "npm:^8.3.5"
"@storybook/builder-webpack5": "npm:^8.3.5"
"@storybook/global": "npm:^5.0.0"
"@storybook/react": "npm:^8.3.5"
"@storybook/react-native": "npm:^8.3.7"
"@storybook/react-native-theming": "npm:^8.3.7"
"@storybook/react-native": "npm:^8.3.8-alpha.0"
"@storybook/react-native-theming": "npm:^8.3.8-alpha.0"
"@storybook/react-webpack5": "npm:^8.3.5"
"@storybook/test": "npm:^8.3.5"
"@testing-library/react-native": "npm:12.4.3"
Expand Down