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

Addon-Docs: source-loader has non-ES5-friendly template literals in output #7388

Closed
adamdoyle opened this issue Jul 11, 2019 · 8 comments
Closed

Comments

@adamdoyle
Copy link
Contributor

The output file @storybook/source-loader/dist/events.js is below:

(comment mine)

"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.STORY_EVENT_ID = exports.ADDON_ID = void 0;
const ADDON_ID = 'storybook/source-loader';
exports.ADDON_ID = ADDON_ID;
const STORY_EVENT_ID = `${ADDON_ID}/set`;  // <-- template literal
exports.STORY_EVENT_ID = STORY_EVENT_ID;

Consequently, in IE11, the stories don't load and it logs this error:

SCRIPT1014: Invalid character
File: vendors~main.fedb7751a9c76d1fa4ef.bundle.js, Line: 201390, Column: 24

Line 201390:24 is the first backtick in `${ADDON_ID}/set`

System:

  • Browser: IE11
  • Framework: polymer
  • Version: 5.2.0-alpha.40

@libetl @shilman

@adamdoyle
Copy link
Contributor Author

There's also some arrow functions, etc. throughout.

Haven't seen that with the other @storybook-scoped packages.

I notice that tsconfig.json sets its target to es5 and that .babelrc.js sets an override for the (otherwise ES5) target for source-loader (and a few others) to be node: '8.11'. According to node.green, version 8.11 supports template literals, so it would make sense that preset-env would leave them in.

I suspect that the general strategy in the .babelrc.js is to target browser-exposed code against ES5 and target node-only code against node-v8.11.

What I don't know is whether @storybook/source-loader was intentionally added as a Node target (because maybe[?] it needs to be ES6 for some reason) or whether it was just an oversight.

@libetl
Copy link
Member

libetl commented Jul 12, 2019

Well source-loader is almost nodejs only. We need to rethink the way storysource uses the source-loader to completely get rid of it in the frontend

@libetl
Copy link
Member

libetl commented Jul 12, 2019

Unfortunately it seems that this task is more urgent than expected. Michael ? @shilman

@shilman
Copy link
Member

shilman commented Jul 12, 2019

@libetl I think migrating Storysource to use parameters & removing decorators from source-loader is important from a code hygiene standpoint. I'm hoping this issue can get solved in the process.

@libetl
Copy link
Member

libetl commented Jul 12, 2019

makes sense

@libetl
Copy link
Member

libetl commented Jul 12, 2019

Maybe I will find some time during the week end to help.

@shilman
Copy link
Member

shilman commented Jul 12, 2019

That would be 💯💯💯

@shilman
Copy link
Member

shilman commented Jul 21, 2019

Fixed in 5.2.0-beta.5?

@shilman shilman closed this as completed Jul 21, 2019
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

3 participants