Code Monkey home page Code Monkey logo

Comments (4)

Taritsyn avatar Taritsyn commented on June 2, 2024 1

We are not using the JavaScript Engine Switcher directly our self, only configuring it. It is being used by LigerShark.WebOptimizer.Sass (or more precisely, one of its dependencies).

Thanks for information! I have an idea how to prevent this error.

from javascriptengineswitcher.

Taritsyn avatar Taritsyn commented on June 2, 2024 1

Hello, Ville!

I tried to solve this problem in JavaScript Engine Switcher 3.24.0 and WebOptimizer.Sass 3.0.115. You need to add the following setting to the Startup.cs file:

public void ConfigureServices(IServiceCollection services)
{// Registration of JS engines
    services.AddJsEngineSwitcher(options =>
    {
        options.AllowCurrentProperty = false;
        options.DefaultEngineName = JintJsEngine.EngineName;
    })
        .AddJint()
        ;

In this case, AllowCurrentProperty property forbid access to the JsEngineSwitcher.Current property, and thus all work is done through standard ASP.NET Core DI.

from javascriptengineswitcher.

Taritsyn avatar Taritsyn commented on June 2, 2024

Hello, Ville!

It is assumed that registration of engines in the JavaScript Engine Switcher is performed only once at start of the application (for example, in regular tests I use a special initializer). Under normal conditions, methods of the Startup class are also called only once when the application starts. Perhaps this behavior changes when using a WebApplicationFactory and because of this the error occurs.

Internally, registration of engines in the JavaScript Engine Switcher is based not on the IServiceCollection interface, but on the JsEngineSwitcher.Current property. In fact, JavaScript Engine Switcher is a global variable. This implementation is due to the fact that this library was created before appeared .NET Core and is still used in a large number of projects written in .NET Framework.

Are you directly using a JavaScript Engine Switcher or using some library that uses it as a dependency?

from javascriptengineswitcher.

VilleHakli avatar VilleHakli commented on June 2, 2024

We are not using the JavaScript Engine Switcher directly our self, only configuring it. It is being used by LigerShark.WebOptimizer.Sass (or more precisely, one of its dependencies).

Now that I think about it, we do not need to compile the sass in our tests and thus there should not be any need to configure JavaScript Engine Switcher in tests.

I'm closing this issue as this is not common/supported case and there are many easy ways to circumvent the problem.

Thanks for all the work you do with this library!

from javascriptengineswitcher.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.