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

middleware.js is not loaded by webpack and thus not transpiled by babel #641

Closed
ndelangen opened this issue Dec 6, 2016 · 2 comments
Closed

Comments

@ndelangen
Copy link
Member

I just attempted to load a middleware.js.

From the commit it would appear to be meant to support ES6 modules, but it doesn't.

This is my middleware.js:

const routes = (req, res, next) => {
  console.log('Hello world!');
  next();
};

export { routes as default };

When I run storybook this is the error I get:

> start-storybook -p 9009 -s public

@kadira/storybook v2.34.0

=> Loading static files from: /Users/dev/Projects/Playground/styled-components/public .
=> Loading custom addons config.
=> Loading custom webpack config.
/Users/dev/Projects/Playground/styled-components/.storybook/middleware.js:6
export { routes as default };
^^^^^^
SyntaxError: Unexpected token export
    at Object.exports.runInThisContext (vm.js:76:16)
    at Module._compile (module.js:542:28)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at getMiddleware (/Users/dev/Projects/Playground/styled-components/node_modules/@kadira/storybook/dist/server/utils.js:53:28)
    at exports.default (/Users/dev/Projects/Playground/styled-components/node_modules/@kadira/storybook/dist/server/middleware.js:11:47)
@arunoda
Copy link
Member

arunoda commented Dec 6, 2016

For now, you need to use ES5 and whatever the features supported by your node environment.
It's not going through webpack and we don't have plans either to do something similar.

Anyway, it's better if we document that.

@arunoda arunoda closed this as completed Dec 6, 2016
@ndelangen
Copy link
Member Author

Ok, I understand, it's just that addons.js actually is transpiled and so is config.js. So I was expeciting all files in the config folder to be transpiled.

Would you be interested in a PR that would allow ES6 in middleware.js?
Thanks.

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

2 participants