BundlerMinifier icon indicating copy to clipboard operation
BundlerMinifier copied to clipboard

Build Fails With Bootstrap 5

Open eat-sleep-code opened this issue 3 years ago • 6 comments

Installed product versions

  • Visual Studio: VS Code
  • This extension: BuildBundlerMinifier 3.2.449, BundlerMinifier.Core 3.2.449

Description

The following error occurs during build:

Microsoft (R) Build Engine version 16.9.0+57a23d249 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

  Determining projects to restore...
  All projects are up-to-date for restore.
  
  Bundler: Begin processing bundleconfig.json
/Volumes/Data/SRC/wwwroot/js/site.min.js : Bundler & Minifier error 0: Object reference not set to an instance of an object. [/Volumes/Data/SRC/TinyURL.csproj]
  Bundler: Done processing bundleconfig.json
The terminal process "dotnet 'build', '/Volumes/Data/SRC/TinyURL.csproj', '/property:GenerateFullPaths=true', '/consoleloggerparameters:NoSummary'" terminated with exit code: 1.

Steps to recreate

  1. Create a project with the following node packages:
"devDependencies": {
		"@fortawesome/fontawesome-free": "5.15.3",
		"bootstrap": "5.0.0",
		"jquery": "3.6.0",
		"jquery-validation": "1.19.3",
		"jquery-validation-unobtrusive": "3.2.12",
		"list.js": "2.3.1",
		"moment-timezone-all": "0.5.5",
		"tempusdominus-bootstrap-4": "5.39.0",
		"tempusdominus-core": "5.19.0"
}
  1. Use the following bundleconfig.json
  [
	    {
		    "outputFileName": "wwwroot/css/site.min.css",
		    "inputFiles": [
			    "wwwroot/css/font.css",
			    "wwwroot/css/bootstrap-absolute.css",
			    "node_modules/@fortawesome/fontawesome-free/css/all.css",
			    "node_modules/bootstrap/dist/css/bootstrap.css",
			    "node_modules/tempusdominus-bootstrap-4/build/css/tempusdominus-bootstrap-4.css",
			    "wwwroot/css/site.css"
		    ],
		    "minify": {
			    "enabled": true,
			    "commentMode": "none",
			    "adjustRelativePaths": false
		    }
	    },
	    {
		    "outputFileName": "wwwroot/js/site.min.js",
		    "inputFiles": [
			    "node_modules/jquery-validation/dist/jquery.validate.js",
			    "node_modules/jquery-validation/dist/additional-methods.js",
			    "node_modules/@fortawesome/fontawesome-free/js/all.js",
			    "node_modules/bootstrap/dist/js/bootstrap.bundle.js",
			    "node_modules/moment/moment.js",
			    "node_modules/tempusdominus-bootstrap-4/build/js/tempusdominus-bootstrap-4.js",
			    "node_modules/list.js/dist/list.js",
			    "wwwroot/js/site.js"
		    ],
		    "minify": {
			    "enabled": true,
			    "commentMode": "none",
			    "sourceMap": false
		    }
	    }
  ]
  1. Attempt to build with VS Code (most recent version), using .NET 5.0.5. The error will occur.
  2. Remove "node_modules/bootstrap/dist/js/bootstrap.bundle.js", from bundleconfig.json.
  3. Attempt to build again. Build will "succeed" albeit missing bootstrap script files.

Current behavior

Bundler & Minifier error 0: Object reference not set to an instance of an object.

Expected behavior

This should be pretty obvious -- build projects containing Bootstrap 5 without error.

eat-sleep-code avatar May 10 '21 15:05 eat-sleep-code

Same here. It looks like this is related to the minification, when I set the "minify.enabled": false bundle config it works again.

dennisreimann avatar May 17 '21 15:05 dennisreimann

Thanks! Probably is okay for a temporary solution, but hopefully gets fixed because defeating the purpose of half the addon if it can't minify the bundle.

:-)

But based on the last Nuget package update date, curious if this project is even supported anymore.

eat-sleep-code avatar May 17 '21 18:05 eat-sleep-code

Still an issue in Bootstrap 5.0.1.

@madskristensen Any idea when next release will be pushed to Nuget?

eat-sleep-code avatar May 21 '21 21:05 eat-sleep-code

Same here. Getting Bundler & Minifier error 0: Object reference not set to an instance of an object. sometimes #558

The workaround I use to get it fixed when happens:

  • set minify.enabled : false in bundle config.json for failed bundle
  • run dotnet build for the project from CLI (should be OK with the disabled minification)
  • restore minify.enabled : true in bundle config.json
  • run dotnet build for the project from CLI again (should be OK now with the restored minification too)
  • build the project / solution as you usually do (I mean if you e.g. use Visual Studio IDE) - should work OK after the magic applied above Hope that helps!

P.S. @madskristensen this is a weird thing happening. Maybe you could consider automating this. Would save time for the folks who keep wasting time on figuring out why this happens and how to fit it.

dmitry-pavlov avatar Oct 14 '21 09:10 dmitry-pavlov

Same here. Getting Bundler & Minifier error 0: Object reference not set to an instance of an object. sometimes #558

The workaround I use to get it fixed when happens:

  • set minify.enabled : false in bundle config.json for failed bundle
  • run dotnet build for the project from CLI (should be OK with the disabled minification)
  • restore minify.enabled : true in bundle config.json
  • run dotnet build for the project from CLI again (should be OK now with the restored minification too)
  • build the project / solution as you usually do (I mean if you e.g. use Visual Studio IDE) - should work OK after the magic applied above Hope that helps!

P.S. @madskristensen this is a weird thing happening. Maybe you could consider automating this. Would save time for the folks who keep wasting time on figuring out why this happens and how to fit it.

This doesn´t work for me.

Everytime I add bootstrap.js it will crash, no matter what. I´ve checked the file for "??" nullish coalescing operators but there is none in the file.

mkalinski93 avatar Apr 04 '22 10:04 mkalinski93

@mkalinski93

This package appears to no longer be maintained as it hasn't had a commit in over 9 or 10 months and hasn't had a NuGet release since 2020. I made repeated attempts to reach Mads -- the original creator -- but I got no response.

I would suggest moving to Webpack 5 which has very broad support and is actively maintained (often multiple release updates per month).

eat-sleep-code avatar Apr 07 '22 22:04 eat-sleep-code

Closing issue due to no response from repository maintainer in well over a year and a half. This project should be archived as it is no longer maintained. Consider using Webpack 5 or other maintained project.

eat-sleep-code avatar Jan 14 '23 23:01 eat-sleep-code