Skip to content

Commit

Permalink
Resolve issue with importing addon inside package examples
Browse files Browse the repository at this point in the history
  • Loading branch information
xeho91 committed May 25, 2024
1 parent 66739c8 commit 4349e20
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 19 deletions.
8 changes: 1 addition & 7 deletions src/parser/walkers/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,7 @@ export async function walkOnModule(module: Script): Promise<AddonASTNodes> {
ImportDeclaration(node, { state }) {
const { source, specifiers } = node;

if (
source.value === pkg.name ||
// FIXME:
// This should be for this package testing purpose only.
// Need a condition to prevent it running outside this package
(typeof source.value === 'string' && source.value.includes('src/index'))
) {
if (source.value === pkg.name) {
for (const specifier of specifiers) {
if (specifier.type !== 'ImportSpecifier') {
throw new Error(`Don't use the default/namespace import from "${pkg.name}"`);
Expand Down
3 changes: 1 addition & 2 deletions stories/Actions.stories.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<script context="module">
import { action } from '@storybook/addon-actions';
import { defineMeta } from '../src/index';
import { defineMeta } from '@storybook/addon-svelte-csf';
const { Story } = defineMeta({
title: 'Addon/Actions',
Expand Down
2 changes: 1 addition & 1 deletion stories/Controls.stories.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script context="module">
import { defineMeta } from '../src/index';
import { defineMeta } from '@storybook/addon-svelte-csf';
import Controls from './Controls.svelte';
Expand Down
3 changes: 1 addition & 2 deletions stories/Example.stories.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<script context="module" lang="ts">
import { action } from '@storybook/addon-actions';
import { defineMeta, setTemplate, type Args, type StoryContext } from "../src/index.js";
import { defineMeta, setTemplate, type Args, type StoryContext } from '@storybook/addon-svelte-csf';
import Example from './Example.svelte';
Expand Down
7 changes: 3 additions & 4 deletions stories/Interactions.stories.svelte
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
<script context="module">
import Interactions from './Interactions.svelte';
import { expect } from '@storybook/test';
import { userEvent, within } from '@storybook/test';
import { defineMeta } from '@storybook/addon-svelte-csf';
import { expect, userEvent, within } from '@storybook/test';
import { tick } from 'svelte';
import { defineMeta } from '../src/index';
import Interactions from './Interactions.svelte';
const { Story } = defineMeta({
title: 'Addon/Interactions',
Expand Down
2 changes: 1 addition & 1 deletion stories/TestOverrides.stories.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script context="module">
import { defineMeta as d } from '../src/index';
import { defineMeta as d } from '@storybook/addon-svelte-csf';
const { Story: S, meta: m } = d({
title: 'Test overrides',
Expand Down
2 changes: 1 addition & 1 deletion stories/context.stories.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script context="module">
import { defineMeta } from '../src/index';
import { defineMeta } from '@storybook/addon-svelte-csf';
const { Story } = defineMeta({
title: 'StoryContext',
Expand Down
2 changes: 1 addition & 1 deletion stories/templates.stories.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script context="module" lang="ts">
import { defineMeta, type Args } from '../src/index.js';
import { defineMeta, type Args } from '@storybook/addon-svelte-csf';
import Text from './Text.svelte';
Expand Down

0 comments on commit 4349e20

Please sign in to comment.