Open dustinbolton opened 4 years ago
@dustinbolton Thanks for posting! We'll take a look as soon as possible.
In the mean time, there are a few ways you can help speed things along:
Please remember: never post in a public forum if you believe you've found a genuine security vulnerability. Instead, disclose it responsibly.
For help with questions about Sails, click here.
I have a possible workaround (see code below). Disabling modules for babel seems to fix it, though ideally I would only be disabling modules for ES2015 specifically. I was unable to figure out how to specifically disable ES2015 modules though.
I narrowed down the problem to babel transpiling "this" to "undefined" in some scripts, including modern ones like bootstrap-bundle. It seems the ES2015 preset for the modules option now defaults to true in babel-preset-env which is a change from past defaults. Since this is front-end browser code it seems like SailsJS should be defaults to disabling ES2015 modules to prevent this problem.
tasks/config/babel.js:
presets: [
[
require('sails-hook-grunt/accessible/babel-preset-env'),
{ "modules": false }
]
]
References: https://github.com/babel/babel/issues/4720 https://github.com/babel/babel/issues/5455 https://babeljs.io/docs/en/env/ https://stackoverflow.com/questions/34973442/how-to-stop-babel-from-transpiling-this-to-undefined-and-inserting-use-str
Hey @dustinbolton,
Thanks for letting us know about this.
Are you getting this error when running the buildProd task (aka sails www
)?
Yes @eashaw, that's correct. It indeed happens with the buildProd task.
Node version: v10.15.0 Sails version (sails): v1.2.4 Sockets hook version (sails-hook-sockets): 2.0.0 Grunt hook version (sails-hook-grunt): 4.0.1
When compiled through Grunt in production mode sails.io.js fails with: Uncaught TypeError: Cannot set property 'io' of undefined at production.min.js:1