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

Aurelia with storybook #905

Open
bemon opened this issue Jul 14, 2018 · 27 comments
Open

Aurelia with storybook #905

bemon opened this issue Jul 14, 2018 · 27 comments

Comments

@bemon
Copy link

bemon commented Jul 14, 2018

Hi,

Im trying to make aurelia work with storybook. I tried to initialize aurelia with webpack, but when storybook triest to load aurelia app i get this message:

 in D:/SourceCodes/storybook/node_modules/aurelia-bootstrapper-webpack/node_modules/aurelia-loader-webpack/dist/commonjs/aurelia-loader-webpack.js
Module not found: Error: Can't resolve 'aurelia-loader-context' in 'D:\SourceCodes\storybook\node_modules\aurelia-bootstrapper-webpack\node_modules\aurelia-loader-webpack\dist\commonjs'
 @ D:/SourceCodes/storybook/node_modules/aurelia-bootstrapper-webpack/node_modules/aurelia-loader-webpack/dist/commonjs/aurelia-loader-webpack.js 154:23-64
 @ D:/SourceCodes/storybook/node_modules/aurelia-bootstrapper-webpack/dist/commonjs/aurelia-bootstrapper-webpack.js
 @ D:/SourceCodes/storybook/app/aurelia/dist/client/preview/render.js
 @ D:/SourceCodes/storybook/app/aurelia/dist/client/preview/index.js
 @ D:/SourceCodes/storybook/app/aurelia/dist/client/index.js
 @ ./.storybook/config.js
 @ multi D:/SourceCodes/storybook/lib/core/dist/server/config/polyfills.js D:/SourceCodes/storybook/lib/core/dist/server/config/globals.js ./.storybook/config.js (webpack)-hot-middleware/client.js?reload=true

Webpack config file:

const path = require('path');
const AureliaWebPackPlugin = require('aurelia-webpack-plugin');

module.exports = {
  entry: {
    app: [],
    aurelia: [
      'aurelia-bootstrapper-webpack',
      'aurelia-polyfills',
      'aurelia-pal',
      'aurelia-pal-browser',
      'aurelia-binding',
      'aurelia-dependency-injection',
      'aurelia-event-aggregator',
      'aurelia-framework',
      'aurelia-history',
      'aurelia-history-browser',
      'aurelia-loader',
      'aurelia-loader-webpack',
      'aurelia-logging',
      'aurelia-logging-console',
      'aurelia-metadata',
      'aurelia-path',
      'aurelia-route-recognizer',
      'aurelia-router',
      'aurelia-task-queue',
      'aurelia-templating',
      'aurelia-templating-binding',
      'aurelia-templating-router',
      'aurelia-templating-resources',
    ],
  },

  output: {
    // (2)
    path: path.resolve(__dirname, 'dist'),
    publicPath: 'dist',
    filename: '[name].js',
    chunkFilename: '[name].js',
  },

  resolve: {
    // (3)
    extensions: ['.ts', '.js'],
    modules: ['src', 'node_modules'],
  },

  module: {
    // (4)
    rules: [
      { test: /\.less$/i, use: ['style-loader', 'css-loader', 'less-loader'] },
      { test: /\.ts$/i, use: 'ts-loader' },
      { test: /\.html$/i, use: 'html-loader' },
    ],
  },

  plugins: [
    new AureliaWebPackPlugin({ noWebpackLoader: true, aureliaApp: undefined }), // (5)
  ],
};

Full repo source code to clone is at https://github.com/bemon/storybook if anyone wants to take a look and try run.

I dont know how exacly configure webpack to proper load aurelia modules.

@doktordirk
Copy link

seems to be in there plain aurelia project. so, just use aurelia-cli do make one for you, same as some other frameworks there

@bemon
Copy link
Author

bemon commented Jul 14, 2018

I've configured storybook webpack.config.js to add aurelia webpack plugin like this

  plugins: [...config.plugins, new AureliaWebPackPlugin.AureliaPlugin()]

But now when building webpack i got this error:

ERROR in ./node_modules/aurelia-webpack-plugin/runtime/empty-entry.js
Module not found: Error: Can't resolve 'main' in 'D:\SourceCodes\storybook\examples\aurelia-kitchen-sink\node_modules\aurelia-webpack-plugin\runtime'
 @ ./node_modules/aurelia-webpack-plugin/runtime/empty-entry.js
 @ multi aurelia-webpack-plugin/runtime/empty-entry aurelia-webpack-plugin/runtime/pal-loader-entry D:/SourceCodes/storybook/lib/core/dist/server/config/polyfills.js D:/SourceCodes/storybook/lib/core/dist/server/config/globals.js ./.storybook/config.js (webpack)-hot-middleware/client.js?reload=true

Should I add any additional config info ? Default aurelia webpack config dont have any specific stuff. I think this error is only thing that prevents me to run aurelia app inside storybook. Any ideas ?

@doktordirk
Copy link

try .AureliaPlugin({includeAll: "src"}) https://github.com/aurelia/webpack-plugin/wiki/AureliaPlugin-options

@baerrach
Copy link

Is anyone actively working on this?

@EisenbergEffect
Copy link
Contributor

Not on our core team at least. We'd love someone to help out with this, particularly for Aurelia 2.

@brandonseydel
Copy link
Member

Au2 storybook is actively getting worked on. Prototype should be done this week.

@bemon
Copy link
Author

bemon commented Aug 28, 2019

@brandonseydel can you give link to repo ?

@brandonseydel
Copy link
Member

https://github.com/brandonseydel/storybook it is working actually. Just needs some cleanup to make everything nicer.

@brandonseydel
Copy link
Member

I pushed another version which handles global container/registration/component registration. This also allows adhoc registration per story past the original. One could register a plugin in the config.ts and then register custom component in story for HMR.

@romain-preston
Copy link

@brandonseydel We are really interested in your branch ! Any update :) ?

@brandonseydel
Copy link
Member

I will nudge storybook authors some more. We want it for our alpha release, so it should be rtm soon.

@brandonseydel
Copy link
Member

I think i will actually open a PR into them so the back and forth will become public. I will link it when complete.

@romain-preston
Copy link

Looking forward to reading these back and fourth!

@brandonseydel
Copy link
Member

storybookjs/storybook#8199

@bemon
Copy link
Author

bemon commented Dec 1, 2019

@brandonseydel any progress with storybook ?

@weoreference
Copy link

@brandonseydel any progress with storybook ?

@brandonseydel

@brandonseydel
Copy link
Member

It is out already on NPM (au2). https://www.npmjs.com/package/@storybook/aurelia

@elimt
Copy link

elimt commented Aug 12, 2020

It is out already on NPM (au2). https://www.npmjs.com/package/@storybook/aurelia

@brandonseydel Any instructions on how to set this up?

@jljabben
Copy link

@brandonseydel Any instructions on how to set this up?

@elimt I found an example on https://github.com/storybookjs/storybook/tree/master/examples/aurelia-kitchen-sink that I'll try out.

But some type of guide on how to set this up would be helpful. The npx -p @storybook/cli sb init command cannot detect the project type and manually setting the project type with npx -p @storybook/cli sb init --type aurelia doesn't work too.

In https://github.com/storybookjs/storybook/blob/next/lib/cli/src/project_types.ts, there is no type for aurelia. Aurelia is only a "supported framework". What type should it be? @brandonseydel

@brandonseydel
Copy link
Member

@jenslw I will try to get a small guide set up and I will investigate the --type not working with SB

@jljabben
Copy link

@jenslw I will try to get a small guide set up and I will investigate the --type not working with SB

After experimenting a bit with the example aurelia-kitchen-sink, I found out that @storybook/aurelia works only with Aurelia 2 applications because it depends on the aurelia npm package used in new Aurelia 2 apps only. Is this correct?

@weoreference
Copy link

@jenslw I will try to get a small guide set up and I will investigate the --type not working with SB

Thank you @brandonseydel

@brandonseydel
Copy link
Member

Yes this is au2 only.

Au2 storybook is actively getting worked on. Prototype should be done this week.

@vkiranmaniya
Copy link

@brandonseydel Any updates on Aurelia's storybook. I made few changes and it's opening storybook. unfortunately, It doesn't show up the example button component.

@Infuser
Copy link

Infuser commented Mar 4, 2021

I am also interested in this.

I have managed to get the go ahead to use AU2 at my work against all odds but we need it working with storybook

@Infuser
Copy link

Infuser commented Mar 29, 2021

@EisenbergEffect anyone have information on this I am trying to get storybook Aurelia2 working but it looks broken to me.

issues with typings and something about reflect metadata being imported twice

@bigopon
Copy link
Member

bigopon commented Apr 6, 2021

A commit that relax the strictness around metadata has been merged. Can you try again @Infuser

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

No branches or pull requests