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

Cannot convert a Symbol value to a string #361

Closed
chatbox-inc-hoge opened this issue Sep 24, 2015 · 2 comments
Closed

Cannot convert a Symbol value to a string #361

chatbox-inc-hoge opened this issue Sep 24, 2015 · 2 comments

Comments

@chatbox-inc-hoge
Copy link

es6-loader 経由でwebpackを実行すると、下記エラーが起きます。

TypeError: Cannot convert a Symbol value to a string
    at RegExp.test (native)
    at assertNotName (/Users/mkkn/mine/chatbox.site/node_modules/es6-loader/node_modules/es6-module-transpiler/dist/es6-module-transpiler.js:200:16)
    at Function.defineProperty (/Users/mkkn/mine/chatbox.site/node_modules/es6-loader/node_modules/es6-module-transpiler/dist/es6-module-transpiler.js:256:7)
    at defineProperty (/Users/mkkn/mine/chatbox.site/node_modules/es6-loader/node_modules/es6-transpiler/node_modules/es6-shim/es6-shim.js:86:14)
    at addIterator (/Users/mkkn/mine/chatbox.site/node_modules/es6-loader/node_modules/es6-transpiler/node_modules/es6-shim/es6-shim.js:286:5)
    at /Users/mkkn/mine/chatbox.site/node_modules/es6-loader/node_modules/es6-transpiler/node_modules/es6-shim/es6-shim.js:730:3
    at /Users/mkkn/mine/chatbox.site/node_modules/es6-loader/node_modules/es6-transpiler/node_modules/es6-shim/es6-shim.js:22:22
    at Object.<anonymous> (/Users/mkkn/mine/chatbox.site/node_modules/es6-loader/node_modules/es6-transpiler/node_modules/es6-shim/es6-shim.js:27:2)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (/Users/mkkn/mine/chatbox.site/node_modules/es6-loader/node_modules/es6-transpiler/build/es5/es6-transpiler.js:5:1)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (/Users/mkkn/mine/chatbox.site/node_modules/es6-loader/index.js:10:15)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at DependenciesBlock.loadPitch (/Users/mkkn/mine/chatbox.site/node_modules/webpack/node_modules/webpack-core/lib/NormalModuleMixin.js:193:17)
    at DependenciesBlock.doBuild (/Users/mkkn/mine/chatbox.site/node_modules/webpack/node_modules/webpack-core/lib/NormalModuleMixin.js:241:4)

このエラーは

https://github.com/paulmillr/es6-shim/blob/master/es6-shim.js#L278

var $iterator$ = Type.symbol(Symbol.iterator) ? Symbol.iterator.toString() : '_es6-shim iterator_'

とすると治ったのですが、これってマージされますか?

node v0.12.7
es6-shim version: "0.33.3",

@martinheidegger
Copy link

I was asked to translate this to english:

When using es6-loader with webpack the following error occurred:

TypeError: Cannot convert a Symbol value to a string
    at RegExp.test (native)
    at assertNotName (/Users/mkkn/mine/chatbox.site/node_modules/es6-loader/node_modules/es6-module-transpiler/dist/es6-module-transpiler.js:200:16)
    at Function.defineProperty (/Users/mkkn/mine/chatbox.site/node_modules/es6-loader/node_modules/es6-module-transpiler/dist/es6-module-transpiler.js:256:7)
    at defineProperty (/Users/mkkn/mine/chatbox.site/node_modules/es6-loader/node_modules/es6-transpiler/node_modules/es6-shim/es6-shim.js:86:14)
    at addIterator (/Users/mkkn/mine/chatbox.site/node_modules/es6-loader/node_modules/es6-transpiler/node_modules/es6-shim/es6-shim.js:286:5)
    at /Users/mkkn/mine/chatbox.site/node_modules/es6-loader/node_modules/es6-transpiler/node_modules/es6-shim/es6-shim.js:730:3
    at /Users/mkkn/mine/chatbox.site/node_modules/es6-loader/node_modules/es6-transpiler/node_modules/es6-shim/es6-shim.js:22:22
    at Object.<anonymous> (/Users/mkkn/mine/chatbox.site/node_modules/es6-loader/node_modules/es6-transpiler/node_modules/es6-shim/es6-shim.js:27:2)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (/Users/mkkn/mine/chatbox.site/node_modules/es6-loader/node_modules/es6-transpiler/build/es5/es6-transpiler.js:5:1)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (/Users/mkkn/mine/chatbox.site/node_modules/es6-loader/index.js:10:15)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at DependenciesBlock.loadPitch (/Users/mkkn/mine/chatbox.site/node_modules/webpack/node_modules/webpack-core/lib/NormalModuleMixin.js:193:17)
    at DependenciesBlock.doBuild (/Users/mkkn/mine/chatbox.site/node_modules/webpack/node_modules/webpack-core/lib/NormalModuleMixin.js:241:4)

This error would be fixed by changing the following line:

https://github.com/paulmillr/es6-shim/blob/master/es6-shim.js#L278

to

var $iterator$ = Type.symbol(Symbol.iterator) ? Symbol.iterator.toString() : '_es6-shim iterator_'

Would that be a problem to merge?

@ljharb
Copy link
Collaborator

ljharb commented Sep 24, 2015

No, that will not fix it. By the spec, stringifying a Symbol throws in all but two cases. The only ways to stringify a symbol safely is String(Symbol()), or Symbol().toString(). This is a node 0.12 bug specifically, where String(x) throws (however, Symbol.prototype.toString.call(x) doesn't, as you pointed out).

The entire purpose of symbols is to be used as non-string object keys - so why would we want to stringify it?

This node 0.12 v8 bug is impossible to fix in JS-land, and is fixed in io.js and node v4.0 and later.

It seems that es6-module-transpiler is attempting to stringify a symbol, and is unaware of this node bug - please file the issue there, as that's something they need to fix.

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

3 participants