generator-esri-appbuilder-js icon indicating copy to clipboard operation
generator-esri-appbuilder-js copied to clipboard

Problem: arguments is a reserved word in strict mode

Open hhkaos opened this issue 5 years ago • 2 comments

Hi there!,

First of all, thanks for this awesome generator, I ❤️ it 😄.

I'm writing because the other day I had an issue developing a widget when I tried to use a third-party library within my widget.

When I copied the code of tinysoap-browser-min.js to a folder I noticed Grunt sent a message to the console:

Running "babel:main" (babel) task Warning: widgets/CustomTinySoap/libs/tinysoap-browser-min.js: arguments is a reserved word in strict mode (499:50)

SInce the message showed up, grunt is not running the tasks after babel:main (copy and sync), and since then no modification made to any file triggers all tasks, which means that no file is being copied the server/apps/ID/widgets folder.

In the first place I tried to do a find & replace the word arguments within the tinysoap-browser, but that broke the code because it wasn't variable called arguments, it was using the argument object of JS.

Is there any way to bypass that warning message from babel task?

You can download the code of the widget I was using: CustomTinySoap.zip

Thanks in advance!

hhkaos avatar Aug 10 '20 10:08 hhkaos

It seems like the babel task does not like the contents of the tinySoap library. I think a workaround is to have the grunt task skip the two files in the libs directory and just copy over the file directly instead, like this:

Gruntfile.js: image

Could you try this and see if it works for you?

gavinr avatar Aug 10 '20 21:08 gavinr

Thank you Gavin and sorry for the delay!

It makes total sense what you're saying but for some reason (maybe I'm still asleep) it isn't working:

widgetSave

Any thoughts?

This is the code I used:

babel: {
            'options': { 'sourceMap': true },
            'main': {
                'files': [{
                        'expand': true,
                        'src': [
                            'widgets/*.js',
                            'widgets/**/*.js',
                            'widgets/**/**/*.js',
                            '!widgets/**/libs/**',
                            'widgets/!**/**/nls/*.js',
                            'themes/*.js',
                            'themes/**/*.js',
                            'themes/**/**/*.js',
                            'themes/!**/**/nls/*.js'
                        ],
                        'dest': 'dist/'
                    }]
            }
        }
        copy: {
            'main': {
                'src': [
                    'widgets/**/**.html',
                    'widgets/**/**.json',
                    'widgets/**/**.css',
                    'widgets/**/images/**',
                    'widgets/**/nls/**',
                    'widgets/**/libs/**',
                    'themes/**/**.html',
                    'themes/**/**.json',
                    'themes/**/**.css',
                    'themes/**/images/**',
                    'themes/**/nls/**',
                    'themes/**/layouts/**/*.*'
                ],
                'dest': 'dist/',
                'expand': true
            }
        },

hhkaos avatar Sep 10 '20 08:09 hhkaos