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

JavaScript library is not included in bundle #10372

Open
skartknet opened this issue Jun 2, 2021 · 18 comments
Open

JavaScript library is not included in bundle #10372

skartknet opened this issue Jun 2, 2021 · 18 comments
Labels
project/v9 state/needs-investigation This requires input from HQ or community to proceed state/needs-more-info We don't have enough information to give a good reply type/bug

Comments

@skartknet
Copy link
Contributor

Which Umbraco version are you using?

9.0.0-beta003

Bug summary

JavaScript library is not included in umbraco-backoffice-extensions-js when added through the package manifest.

Specifics

I am trying to use a js library into a new dashboard. This is how I'm including the files:

{
 "javascript": [
      "/App_Plugins/uDashboard/webix/webix/codebase/webix.js",
      "/App_Plugins/uDashboard/webix/webix-angularjs.js",
      "/App_Plugins/uDashboard/js/dashboard.controller.js",
      "/App_Plugins/uDashboard/js/dashboard.services.js"
 ],
 "css": [ "/App_Plugins/uDashboard/webix/webix/codebase/webix.min.css"] 
}

The problem I have is that the script on the 'webix-angularjs.js' file complains because 'webix' is not defined. Webix is defined in the file before 'webix.js'.

I can see that these files are concatenated by Umbraco in a custom file called 'umbraco-backoffice-extensions-js.js'.

If I inspect that file, I can see that the content of webix.js is not there, but it includes the rest of my js: webix-angularjs.js, dashboard.controller.js and dashboard.services.js

If I type 'webix' on the Dev console I can in fact see that webix is not defined.

For some reason, the file is not being bundled. Maybe the bug is on the Smidge package?

The content of webix-angularjs.js is here

The content of webix.js is here

Steps to reproduce

Add the package.manifest including the webix.js library as a dependency:

{
    "javascript": [
        "/App_Plugins/uDashboard/webix/webix/codebase/webix.js"        
   ]    
}

Go to the Umbraco backoffice and open the dev tools. Unders Sources, find the umbraco-backoffice-extensions-js.js.* file in the sb folder. You will see that the file doesn't contain any code.

image

Expected result / actual result

The webis.js file should be included in the bundled file.

@nul800sebastiaan
Copy link
Member

Could be that there's a minification error preventing it from being bundled? I don't know if there's logging when that happens? I'll ping @Shazwazza on this one.

Does it help to turn Debug to true (in appsettings.json) so it does less processing of those files?

image

@nul800sebastiaan nul800sebastiaan added project/v9 state/needs-investigation This requires input from HQ or community to proceed labels Jun 2, 2021
@skartknet
Copy link
Contributor Author

I tried the debug mode and it didn't make any difference. I have made it work using the already minimized version of the file.

I reckon it's something to do with the comments on the file, Client Dependency used to also have some issues with removing comments when minimizing too.

@enkelmedia
Copy link
Contributor

I had the same problem, first i used the App_Plugins-folder in "root" of the project, then the backoffice-js file throws, but i copied the App_Plugins folder into wwwroot and after this it works.

It like the manifest.json-file is loaded from the "root"-App_Plugins and the client files from wwwroot.

@mjpraxis
Copy link

mjpraxis commented Sep 8, 2021

@nul800sebastiaan @Shazwazza

Have you looked at this issue?

I have the same problem running 9-rc2

And as @enkelmedia comments. It works if you make a copy of App_Plugins folder into wwwroot folder.

The problem for me is when working with blocklist views/controllers.

So the solution right now is making a copy of App_Plugins folder before deploying to the server.

@viktor-knowit
Copy link

Same error here. We have a problem on our server when trying to get an extension Contentment to work.

I have posted a post in the forums as well: https://our.umbraco.com/forum/using-umbraco-and-getting-started/108316-frontend-error-the-file-umbraco-backoffice-extensions-js-does-not-contain-any-reference-to-the-extension

The file /sb/umbraco-backoffice-extensions-js.js.vc48... does not contain any reference to Contentment. But, if I change Debug to true in the server appsettings-file, it works:

"Umbraco": {
  "CMS": {
    "Hosting": {
      "Debug": false //If I change this to "true" it works
    }
  }
}

But we want to keep it as Debug=false in that environment.

Versions:

  • Our.Umbraco.Community.Contentment" Version="3.0.1"
  • Umbraco.Cms.Core" Version="9.2.0"

@IainMartin-Ayr
Copy link

I'll echo the above comments - I too have JS files in APP_PLUGINS that are not being loaded if Hosting Debug is set to false, only if it is true.

I've also deleted the Smidge folder and it makes no difference to the back end, and I cannot see where they are being saved (if at all) nor does it make any difference where the APP_PLUGINS folder is, root of the directory, or in the wwwroot directory.

I'm using V10-RC4, but I know that the Smidge DLL's are not built by Umbraco direct.

It's a pain, but now that I have found out what the issue is, at least there is a workaround, but like the above poster, I want to keep Debug=false on my live environment.

@Pauldubbya
Copy link

Pauldubbya commented Jun 29, 2022

This needs attention (still present on 9.5.2 and it's present on v10 as well), we're having to delete the smidge folder to get UmbracoForms running and having similar issues with Usync.

Can we get a fix for this from someone who knows how Smidge interacts with the rest of Umbraco etc? Is it a @Shazwazza creation?

Turning debug=true on is not a fix.

@darrenm-dwl
Copy link

Just to confirm this issue is still present in umbraco 10.0.1

@nul800sebastiaan
Copy link
Member

Hey all, thanks for confirming this is still a problem for some of you.

I am honestly not sure what is going on here! On Umbraco Cloud we set all projects to "Debug": false and I'm not aware of any problems with deploying to Cloud. This leads me to think you might have some files missing in your deploy pipeline or something else going wrong.

Additionally, it feels like some of you have different problems than others, but I can't really tell for sure. What we really need to progress this is to have reproduction steps on a clean v9/v10 install, adding some App_Plugins, a description of how exactly you deploy it and what is going wrong.

As soon as we have good reproduction steps we can look further into it, currently I am not able to proceed with reproducing. If anyone wants to attach their whole App_Plugins/MyPlugin folder and confirm that it no longer works when you set debug to false, even locally, then that would be the easiest I think?

@nul800sebastiaan nul800sebastiaan added state/needs-more-info We don't have enough information to give a good reply state/needs-investigation This requires input from HQ or community to proceed and removed state/needs-investigation This requires input from HQ or community to proceed labels Jul 18, 2022
@darrenm-dwl
Copy link

darrenm-dwl commented Jul 19, 2022

@nul800sebastiaan I have been able to resolve the issue.

In visual studio make sure the App_Plugins folder is excluded from the project.

image

During the publish I believe Umbrao.Core will take all the files in the App_Plugins folder, work its magic to minify it and include the files in the publish (even though they are excluded from the project)

If the App_Plugins folder is included in the project they will override the files Umbraco has generated so it will then not work on the server unless Hosting is set to Debug in which case it will look for the files that have been included... That's just my theory though... who knows! but at least it is now working for me :-)

Also you might need to clear the cache / hard refresh on the website to see the changes take effect

I hope this helps.

@TomSearle
Copy link

I tried the above solutions but still couldn't load the backoffice. I managed to fix it by removing any fully qualified URLs from the package.manifests. For example, https://www.gstatic.com/charts/loader.js in the following snippet.

{
  "dashboards": [
    {
      "alias": "formReports",
      "view": "/App_Plugins/Reporting/FormReport/formReport.html",
      "sections": [ "reporting" ],
      "access": [
        { "deny": "translator" },
        { "grant": "admin" }
      ],
      "weight": 1
    }
  ],
  "javascript": [
    "/App_Plugins/Reporting/FormReport/formReportController.js",
    "/App_Plugins/Reporting/FormReport/formsController.js",
    "https://www.gstatic.com/charts/loader.js",
    "/App_Plugins/Reporting/vendor/simple-datatables.js"
  ],
  "css": [
    "/App_Plugins/Reporting/FormReport/forms.css",
    "/App_Plugins/Reporting/vendor/simple-datatables.css"
  ]
}

@argentini
Copy link

Experimenting in Umbraco 10.1 I found that it also exhibits the problem when runtime mode is set to Production. It appears to not be able to bundle multiple JS files that reside in a single plugin. My solution was to break out the separate JS files as separate plugins and that fixed the issue.

@Borc92
Copy link

Borc92 commented Sep 6, 2022

We have the same problem!

Is there any solution except, "debug=true" ?

@viktor-knowit
Copy link

Hi again.

I am not sure if this is the fix but I got a similar issue when working with UmbracoForms. (Error: $controller:ctrlreg") I fixed this on the server by deleting the "/Smidge"-folder. It contained old cache-files that did not include the new added plugin. After deleting that folder and after a page reload, Umbraco generated new cache-files, containing the new plugin.

And now UmbracoForms works great!

@Shazwazza
Copy link
Contributor

You should bump the Version number: https://our.umbraco.com/Documentation/Reference/Configuration/RuntimeMinificationSettings/#manually-changing-the-cache-buster-version

@eliranrefael
Copy link

that what seems to fix it for me. will update if this issue will return on itself. took me much time to figure this one out, all because of you.
image

@Sven883
Copy link

Sven883 commented Jul 25, 2023

@Shazwazza We've tried manually changing the cache buster version and using AppDomain / Timestamp.
None of the option work except for using debug = true.

Any idea how to fix this?

@Sven883
Copy link

Sven883 commented Jul 25, 2023

@Shazwazza problem is fixed by following this guide: https://dev.to/kevinjump/smidge-and-umbraco-frontends-dp1
Thanks @KevinJump ! --> Ignore what i said ! Problem not solved yet :-(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
project/v9 state/needs-investigation This requires input from HQ or community to proceed state/needs-more-info We don't have enough information to give a good reply type/bug
Projects
None yet
Development

No branches or pull requests