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

Uncaught ReferenceError: module is not defined at story loading #160

Open
rafagarcia opened this issue Feb 13, 2023 · 0 comments
Open

Uncaught ReferenceError: module is not defined at story loading #160

rafagarcia opened this issue Feb 13, 2023 · 0 comments

Comments

@rafagarcia
Copy link

Hello,
when i try to add a specific story to my storybook, browser console outputs the following error:

error_module_storybook

The component i am trying to display into the storybook is a web-component class made with lit that extends a visual component, wrapping it in order to perform an api request.

These are my settings:

OS: Windows 10 Enterprise
Node version (nvm): v16.13.0
storybook-addon-mock version: ^3.2.0

And these are the files:

index.stories.js

import { html } from 'lit-html';

import {
  balances,
} from '../../mocks/mocks.js';
import { defineElement } from '../../../.web-dev-storybook/utils.js';
import { ApiRequesterComponent as ApiRequesterComponentClass } from '../index.js';

defineElement('api-requester-component', ApiRequesterComponentClass);

export default {
  title: 'Layers 2/Api requester component',
  parameters: {
    viewport: {
      defaultViewport: 'Mobile',
    },
    actions: { disable: true },
    controls: { disable: true },
    mockData: [
      {
        url: 'http://localhost:8000/api/rest/reports/data?timeResolution=Month&projection=NoProjection&fromDate=xx/xx/xxxx&toDate=xx/xx/xxxx',
        method: 'GET',
        status: 200,
        response: balances,
      },
    ],
  },
};

export const Template = () => 
  html`
    <api-requester-component></api-requester-component>
  `;

utils.js

...

export const defineElement = (name, el) =>
  !customElements.get(name) && customElements.define(name, el);

...

ApiRequesterComponent.js

import { dataAPI } from '../../core/src/DataAPI.js';
import { DataDisplayerComponent } from '../../data-displayer-component/index.js';

...

export class ApiRequesterComponent extends DataDisplayerComponent {
  constructor() {
    super();
    this.loading = true;
  }

  /** @override from DataDisplayerComponent */
  async connectedCallback() {
    super.connectedCallback();
    this.loading = true;

    ...
  }
}

DataDisplayerComponent.js

import { LitElement, html, nothing } from 'lit-html';

export class DataDisplayerComponent extends LitElement {
    ....

    render() {
        return html`<p>template content</p>`;
     }

    ....
}

Thanks in advance for the help.

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

No branches or pull requests

2 participants