BabelHelpers is not defined using Polymer - polymer

I'm using Polymer and its build process. The bundled files are generated throughmy polymer.json file.
I'm not explicitely using Babel, I've just seen it's used by "paper-autocomplete".
When going to the website, I have a js error stating the BabelHelpers is not defined.
When I use MAJ+F5, it works !
When I use F5, it doesn't work
(BabelHelpers is not defined)
When running it locally it works fine. When I deploy it to my server, I face this issue.
I'm running it as a standalone Java application as it has a Spring backend.
The website as multiple entry points, it works fine for all other ones.
The stacktrace :
Command :
polymer build --js-minify --css-minify --html-minify
The polymer.json file
{
"entrypoint": "pt.html",
"builds": [{
"bundle": true,
"js": {"compile": true, "minify": true},
"css": {"minify": true},
"html": {"minify": false},
"addServiceWorker": true
}],
"shell": "resources/elements-platform.html",
"fragments": [
"resources/html/lazy-resources.html",
"resources/html/ym-dashboard.html",
"resources/html/ym-partners.html",
"resources/html/ym-favorite.html",
"resources/html/ym-agenda.html",
"resources/html/ym-todos.html",
"resources/html/ym-profile.html",
"resources/html/ym-messages.html",
"resources/html/shop-list.html",
"resources/html/shop-detail.html"
],
"sources": [
"resources/src/**/*",
"resources/css/**/*",
"resources/data/**/*",
"resources/images/**/*",
"resources/img/**/*",
"resources/js/*",
"resources/js/cal/*",
"resources/js/countdown/*",
"resources/bower.json"
],
"extraDependencies": [
"resources/bower_components/webcomponentsjs/webcomponents-lite.min.js"
]
}

I run into the same issue few days ago after I updated Polymer-cli to newest version. But in my case my application throwed same error on local virtual host (with self-sign certificate). On production website it was fine.
Actually, babelHelpers are injected into file that is selected as entrypoint inside your polymer.json file. Maybe try to look there, if you have correct existing file.
there are few existing issues on github with this problem. Unfortunately there is no verified answer (Polymer team does not really care about github issues)
https://github.com/Polymer/polymer-cli/issues/787
https://github.com/Polymer/polymer-cli/issues/765
There is also same question on stackoverflow with answer:
polymer-cli - getting "Can’t find variable: babelHelpers" when I set compile to true

I too am seeing 'babelHelpers' is undefined. In my case it's coming from redux.js:
q='object'==('undefined'===typeof self?'undefined':babelHelpers
.typeof(self))&&self&&self.Object===Object&&self,r=p||q||
Function('return this')(),s=r.Symbol,t=Object.prototype,
Babel helpers is also raised as in Issue #606, which says that it's resolved and closed. But it or something similar is back.

I made a few changes, but I don't know which one solved the issue. The problem came from paper-autocomplete. When I stopped using it I didn't have the issue anymore.
I'm still using it, but I made several changes :
I made sure I was using the generated service-worker
I stopped using the version of JQuery that was in my bower (3.2.1) and used it from JQuery CDN (2.3.1) as I've seen it caused issues sometimes
Added manifest.json in the polymer.json file

Related

Access Polymer3.0 custom elements from static html

I created a custom Polymer3.0 element. And it works fine when I do ploymer serve.
We have an internal enterprise NPM registry, to which I published my element.
Now I want to use this element in a completely different project (which has only static HTML/JS) and is served by NGNIX server.
Is this possible ? If so how to approach it ?
Do I need to server my custom element via node or http-server for me to use in a static html in a completely different project ?
Can we server the polymer3.0 elements like CDN, I saw some posts with unpkg, but for that I need to publish to global NPM. R there any other options ?
I was able to solve the issue (in-fact it was me not looking at all the options in polymer.json).
If anyone is interested following is what I did..
In my ploymer.json I added the following
shell property of json to point to my custom element js file
I also added to the js property, "compile":true..
Following is what my polymer.json looks like
...
"shell": "xxxxx.js",
"builds":[
{
"name": "prod",
"preset": "es6-bundled",
"bundle":true,
"moduleResolution": "node",
"addServiceWorker": true,
"inlineCss": true,
"inlineScripts": true,
"rewriteUrlsInTemplates": true,
"sourcemaps": true,
"stripComments": true,
"js": {"minify":true, "compile":true},
"css": {"minify":true},
"html":{"minify":true}
},
...
I copied my files in build/ folder to my nginx server and hosted them as regular folder. Of course I add add_header Access-Control-Allow-Origin *; to my conf file
In my static HTML to import my component all I had to do is
<script src="https://unpkg.com/#webcomponents/webcomponentsjs#2.4.3/webcomponents-loader.js"></script>
<script type="module" src="http://XXX_MY_NGINX_VIRTUAL_HOST_XXXX/my-custom-element.js"></script>

artifactory flag artifacts as 'integration' not working so far

I am using artifactory to store my artifacts, using a generic repo (I named it 'generic-local') and a layout that I have customized based on the maven2 layout (I believe one of the default layouts)
unchanged layout
[orgPath]/[module]/baseRev/[module]-baseRev(-[classifier]).[ext]
my version are of the following format
myartifact-1.0.0
myartifact-1.0.0-develop
myartifact-1.0.0-branch1234
to detect and flag release artifact.. I understand artifactory relies on certain regex
the Folder Integration Revision RegExp and File Integration Revision RegExp
for both I have set this regexp to 'branch.*|develop.*'
I would expect artifactory to now flag as 'integration' any artifact following the two last artifacts in my list above but it isn't working so far..
http://myrepo.com/artifactory/api/search/versions?g=My.Applications&a=myartifact&repos=generic-local
returns
{
"results": [
{
"version": "1.0.267-branch1234",
"integration": false
},
{
"version": "1.0.266-branch1234",
"integration": false
},
{
"version": "1.0.265-branch1234",
"integration": false
}
}
I tested the Test Artifact Path Resolution form in artifactory .. for each artifacts above, it returned :
Folder Integration Revision: branch1234
File Integration Revision: branch1234
Which makes me think my regex is valid. thus the artifacts are seen as integration .. however the api returns false..
What am I doing wrong
The above is working. I can see artifacts finally flagged with the flag integration=true.
I can use this to, for example, run 'deploy latest stable version'.
The fix was to wait. Seems artifactory does not apply the rule right away. even for new artifacts added after the rule change. Confusing and wished their documentation would mentioned it.

All of my .json files have problems loading reference/schema from schemastore.azurewebsites.net

I'm working in VS Code and started getting this error yesterday. All of my json files have this error, not just a few. If I remember right there was an update to the program yesterday or the day before. Did the update break something or reset a setting that I forgot I had set?
When looking this up, people are talking about downloading the schema and using it locally, but I would prefer not to have to do that and would instead like to find out why this broke?
I am using a proxy, but as far as I know that hasn't changed. Here's the exact error I'm getting.
Problems loading reference 'https://schemastore.azurewebsites.net/schemas/json/package.json': Unable to load schema from 'https://schemastore.azurewebsites.net/schemas/json/package.json': Unable to connect to https://schemastore.azurewebsites.net/schemas/json/package.json. Error: connect ECONNREFUSED 168.62.224.13:443
I'm behind my company's proxy which I don't know the details because it's everything automatic, and this problem have bug me for some time.
I'm not sure whether this is an universal solution but according to this issue, the http.proxySupport setting is defaulting to "override".
I turn this setting off and the errors disappeared:
"http.proxySupport": "off"
Open User settings of visual studio code through the command palette:
Press F1
Type user settings.
Select Preferences:Open User Settings from drop down
Put below code and modify accordingly:
"http.proxy": "http://username:password#hostname:port/",
"http.proxyAuthorization": null,
"http.proxyStrictSSL": true
Just close your VsCode Editor and open it again. That should fix the error.
I just turned off checkbox schema download and error gone.
Press F1 and follow open user settings/user/extentions/JSON
I was facing following issue with Angular 6:
Problems loading reference 'https://schemastore.azurewebsites.net/schemas/json/package.json': Unable to load schema from 'https://schemastore.azurewebsites.net/schemas/json/package.json': Unable to connect to https://schemastore.azurewebsites.net/schemas/json/package.json. Error: unable to get local issuer certificate
I added following properties at the end of the User Settings File and worked for me:
"http.proxy": "",
"http.proxyAuthorization": null,
"http.proxyStrictSSL": false
Add this to your setting.json. Your problem will be solved! Plus this works for me.
"json.schemas": [
{
"fileMatch": ["/package.json"],
"url": "https://json.schemastore.org/package",
"schema": true
}
]
Well i didnt like the idea to set "http.proxyStrictSSL": false, so i started searching, and i found this Issue on SchemaStore site from azure. After seeing this i concluded that my proxy was getting some problem with the certificate and authentication. What i did was change all "https" to "http" in the following session of package.json file(Mine was on this path: C:\Program Files\Microsoft VS Code\resources\app\extensions\typescript-basics\package.json).
"jsonValidation": [
{
"fileMatch": "tsconfig.json",
"url": "http://schemastore.azurewebsites.net/schemas/json/tsconfig.json"
},
{
"fileMatch": "tsconfig.json",
"url": "./schemas/tsconfig.schema.json"
},
{
"fileMatch": "tsconfig.*.json",
"url": "http://schemastore.azurewebsites.net/schemas/json/tsconfig.json"
},
{
"fileMatch": "tsconfig.*.json",
"url": "./schemas/tsconfig.schema.json"
},
{
"fileMatch": "typings.json",
"url": "http://schemastore.azurewebsites.net/schemas/json/typings.json"
}
]
I solved this issue by turning off proxy support in VS Code.
Open Settings and search for proxy support at the top. The only option shown should then be the one you want to switch from Override (which is the default) to off:
PS: You can also locate settings by pressing F1 and entering user settings.
please follow the step below to solve this problem:
Open the folder where package.json file present
Type npm install from cmd
restart VS code or any IDE that you use.
I tried every setting - the only one which works is adding this to settings.json:
"json.schemas": [
{
"fileMatch": [
"/package.json"
],
"url": "https://json.schemastore.org/package",
"schema": true
},
]
}
Note, using the HTTP URL doesn't work - it just ignores the URL.
If you still want the proxy support to work, just disable the proxyStrictSSL. Don't need to adjust other settings.
After banging my head against this for longer than I care to admit, I just needed to add the proxyAuthorization value for my Base64 encoded credentials, and did not need the proxy or proxyStrictSSL values.
I already had my proxy correctly configured in my environment variables. It only has the domain and port, not my credentials, ex. "HTTP_PROXY" "http://example.com:port/".
I used this C# code in LINQPad to get the proxyAuthorization value from my credentials:
var pw = "user#example.com:password";
var base64Encoded = Convert.ToBase64String(Encoding.UTF8.GetBytes(pw));
base64Encoded.Dump();
This is what I have in my user settings.json, using the encoded string from the above code dump.
"http.proxyAuthorization": "BASE64_ENCODED_VALUE"
Note: I believe that if I didn't need the full username with email address in the credentials for our proxy to let me out, I could have used an above solution. But since I did, this was the only way I could get it to work.
I`ve just delete this setting 😃
"http.proxy": "http://.......",
For me this works the Azure Storage Emulator stopped working ;-(
To start the Azure Storage Emulator:
Select the Start button or press the Windows key.
Begin typing Azure Storage Emulator.
Select the emulator from the list of displayed applications.
https://learn.microsoft.com/en-us/azure/storage/common/storage-use-emulator
just do the 3
in CMD
AzureStorageEmulator.exe init
AzureStorageEmulator.exe start
AzureStorageEmulator.exe status
BAM all worked
It's issue of opening the vs code using command line or any type of terminal
for avoid this issue.
Just restart the vs code or close the vs code and open again
Add following code in setting.json file
"http.proxy": "",
"http.proxyStrictSSL": false
To Open setting.json file use the below step
Press F1
Type User Setting and then select Preferences:Open User Settings
Then click on Edit Setting.json link
for me turns out that the problem was due to terminal.integrated.shell.windows being deprecated in VSCode.
these are the steps i followed to fix it :
Open command palette (CTRL + Shift + P)
Search "Preferences: Open "User Settings" (the JSON file)"
find this field => terminal.integrated.shell.windows delete it and type this instead inside of "terminal.integrated.profiles.windows":
"PowerShell": {
"source": "PowerShell",
"icon": "terminal-powershell"
},
"Command Prompt": {
"path": [
"${env:windir}\\Sysnative\\cmd.exe",
"${env:windir}\\System32\\cmd.exe"
],
"args": [],
"icon": "terminal-cmd"
},
"Git Bash": {
"source": "Git Bash"
}
},```
if you want to disable PowerShell, just set its value to null

How do I get rid of composer-asset-plugin in yii2

Since the fxp\composer-asset-plugin broke last year, I am continuously experiencing problems installing yii2.
whenever I run a composer update command it fails due to this composer asset plugin. Everyday a new error pops up. I have read number of articles, github issues, with Sam and Alexander (maintainers of Yii Framework) continuously replying to the same problem then would close the topic. none of the updates to this plugin seem to be a fool-proof solution.
Now instead of asking how to solve the errors caused by this plugin (assuming that no one has a 100% working solution till date, only workarounds that work only 'sometimes'),
how do I get rid of this plugin and can't I manually install the packages through bower or npm?
In short, I mean,
In Yii 2.0, is life possible without this plugin, which has become a problem creator instead of solving problems.
You can use https://asset-packagist.org instead. Add this in composer.json:
"repositories": [
{
"type": "composer",
"url": "https://asset-packagist.org"
}
],
Only problem is assets are installed in the different folder so you need to change the aliases. Add this in some common config file:
'aliases' => [
'#bower' => '#vendor/bower-asset',
'#npm' => '#vendor/npm-asset',
],

Grunt doesn't run json_server task from grunt-json-server

I am using the configuration the npm page gives an example for, yet when I try to run the task using either grunt.run.task (['json_server']) or in concurrent: { server: { tasks [ 'json_server'] } }, grunt doesn't even print out the task name in the console. It doesn't even give me an error if I remove the db file it tries to point to.
See: https://github.com/tfiwm/grunt-json-server/issues/4
The library uses registerMultiTask; when changed to registerTask, it worked fine for me.