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

IE11: Symbol is undefined #26

Closed
doctyper opened this issue Jan 12, 2017 · 7 comments
Closed

IE11: Symbol is undefined #26

doctyper opened this issue Jan 12, 2017 · 7 comments

Comments

@doctyper
Copy link

Hi, great tool! I get this error when running flow-runtime on IE11:

'Symbol' is undefined
	ReferenceError: 'Symbol' is undefined
	   at Anonymous function (eval code:40:3)
	   at Anonymous function (eval code:34:1)
	   at Anonymous function (eval code:1:31)
	   at eval code (eval code:1:2)
	Evaluating flow-runtime@0.0.6/lib/types/Type.js
	Evaluating flow-runtime@0.0.6/lib/types/AnyType.js
	Evaluating flow-runtime@0.0.6/lib/types/index.js
	Evaluating flow-runtime@0.0.6/lib/registerPrimitiveTypes.js
	Evaluating flow-runtime@0.0.6/lib/globalContext.js
	Evaluating flow-runtime@0.0.6/flow-runtime.js
	Evaluating flow-runtime@0.0.6.js
	Evaluating main.js
	Error loading main.js

Perhaps adding babel-polyfill as a dependency would fix it?

@phpnode
Copy link
Collaborator

phpnode commented Jan 12, 2017

hey, thanks for reporting this. I don't want to include babel polyfill as a direct dependency because I think that decision should be left to the library consumers. It would be good to add a note about use of Symbol in the readme though.

@doctyper
Copy link
Author

@phpnode So that's the thing. I'm adding babel-polyfill at the root of my app but this error is still thrown. I'm guessing flow-runtime is adding references to Symbol before the polyfill is applied, and an error is thrown. Does that make sense?

@doctyper
Copy link
Author

I think that's what's happening. Here's a look at the transpiled output of my entry file:

Object.defineProperty(exports, "__esModule", {
    value: true
});

var _flowRuntime = require("flow-runtime");

var _flowRuntime2 = _interopRequireDefault(_flowRuntime);

require("babel-polyfill");

var _domainsConfig = require("./domains.config.js");

var domains = _interopRequireWildcard(_domainsConfig);

// etc

flow-runtime is injected at the top of the file. It subsequently imports ./lib/symbols.js, which defines Symbols, which throws an error in browsers that don't natively support them.

@phpnode
Copy link
Collaborator

phpnode commented Jan 13, 2017

ok, a couple of work arounds for now:

  1. do your require to babel polyfill in a separate file, and mark that file with /* @flow-runtime ignore */, and then require the rest of your app:
/* @flow */
/* @flow-runtime ignore */
import 'babel-polyfill';
import './entryPoint';

or:

  1. import flow-runtime yourself in your entry file, after the import 'babel-polyfill';:
/* @flow */
import 'babel-polyfill';
import t from 'flow-runtime'; // the babel plugin will detect this and not import another copy.

// rest of your code goes here

The problem is that we're attaching the import to flow-runtime right at the top of each file, really we should do it after the last possible import statement.

@phpnode
Copy link
Collaborator

phpnode commented Jan 17, 2017

@doctyper did the work around work for you out of interest?

@doctyper
Copy link
Author

I'm not sure. It's still throwing an error, but I think it's because of the use of another unsupported API (generators). I think there's a larger need for a polyfilled, browser-friendly version of this plugin.

@phpnode
Copy link
Collaborator

phpnode commented Jan 18, 2017

Fixed import ordering and added rollup and browser / commonjs / es2015 builds in v0.2.0

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