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

Inline JavaScript is not enabled. Is it set in your options? #7308

Closed
duxard opened this issue Mar 9, 2022 · 27 comments · Fixed by #8552
Closed

Inline JavaScript is not enabled. Is it set in your options? #7308

duxard opened this issue Mar 9, 2022 · 27 comments · Fixed by #8552

Comments

@duxard
Copy link

duxard commented Mar 9, 2022

What problem does this feature solve?

Hi team, I bumped into the following problem and wasn't able to find a proper place to post the issue. I'm using storybook tool in my project and this is my configuration for it (pls pay attention to less-loader):

module.exports = {
  module: {
    rules: [
      {
        test: /\.less$/i,
        use: [
          {
            loader: "less-loader",
            options: {
              lessOptions: {
                javascriptEnabled: true
              },
            },
          },
        ],
      },
    ],
  },
}

However, when I'm trying to compile the project (npm run storybook) the following ERROR comes up:

.bezierEasingMixin();
^
Inline JavaScript is not enabled. Is it set in your options?

As far as I can see I added { javascriptEnabled: true } option but it did not help. Any ideas on how to troubleshoot the issue?

less@3.5.0
less-loader@7.0.0

What does the proposed API look like?

N/A

@cipchk
Copy link
Member

cipchk commented Mar 11, 2022

@duxard Can you provide your angular and ng-zorro-antd version numbers?

@duxard
Copy link
Author

duxard commented Mar 11, 2022

@cipchk I'm using the following versions:
angular 11.2.1
ng-zorro-antd 11.3.0

@cipchk
Copy link
Member

cipchk commented Mar 11, 2022

Try removing the node_modules and yarn.lock (or package_lock.json) files, then reinstalling the dependency yarn.

If still, try to upgrade less to ^3.9.0.

@duxard
Copy link
Author

duxard commented Mar 11, 2022

Tried it out, but unfortunately it did not help :(

@gizmoGremlin
Copy link

@duxard did you find a solution? I have same problem. Thanks

@cipchk
Copy link
Member

cipchk commented Mar 28, 2022

@duxard @gizmoGremlin Can you provider less installed package infomation via yarn why less.

@duxard
Copy link
Author

duxard commented Mar 30, 2022

@gizmoGremlin
looks like the problem goes away if you use angular @13 & Ng-Zorro @13

After some experimenting I had come to conclusion that it did not work with @11 versions of libraries (as it was in my case)

@cipchk i'm using npm - what is the correct way (npm command) to provide you with the required information?

@duxard
Copy link
Author

duxard commented Mar 31, 2022

@cipchk

+-- @angular-devkit/build-angular@0.1102.6

| +-- less-loader@7.3.0

| | `-- less@4.1.1 deduped

| `-- less@4.1.1

`-- ng-packagr@11.2.4

`-- less@4.1.1 deduped

@cipchk
Copy link
Member

cipchk commented Apr 1, 2022

@duxard It looks like less is currently a 4.x version, try to force a ^3.9.0 version in package.json.

@duxard
Copy link
Author

duxard commented Apr 7, 2022

@cipchk gotcha, will give it try! Thank you

@bguezzie
Copy link

bguezzie commented Mar 9, 2023

This is happening for me, as well. Originally I was on Less 4.x but even after switching to ^3.9.0 I see the same behavior.
"@angular-devkit/build-angular": "^14.2.6",
"ng-zorro-antd": "^14.1.1",
"less": "^3.9.0",

Any advice on how to proceed? Is there a version of ng-zorro that uses the newer @plugin model?

[EDIT] If there's a way to pass the javascript enablement flag to Less via Angular config, that'll work too, but I don't see anything like that.

@npetillon
Copy link

I encountered the same problem when testing esbuild from angular v16.
The response of the issue angular-cli:

The javascriptEnabled option is deprecated by Less and is not recommended due to security concerns. This was actually discussed in 2018 (Angular v6 timeframe) in regards to what appears to be the same package (angular/angular-cli#10430). Due to potential security concerns with users unintentionally executing JS at build time, further discussion with the team will be needed to determine a long-term path forward.

@DanialV
Copy link

DanialV commented Jun 8, 2023

Still have this problem even after updating ant design to version 16

X [ERROR] Inline JavaScript is not enabled. Is it set in your options? [plugin angular-less]

    node_modules/ng-zorro-antd/style/color/bezierEasing.less:110:0:
      110 │ .bezierEasingMixin();

@JoaoPauloLousada
Copy link

I also have this issue when I migrate to angular V16.
Don't know how to fix it properly.

@qyjs
Copy link

qyjs commented Jun 27, 2023

Still have this problem even after updating ant design to version 16
image

@DanialV
Copy link

DanialV commented Jul 5, 2023

This is the singular error hindering my project's compatibility with ES Build. Could you let me know if there are any plans to address this issue in the near future?

@shalltears
Copy link

I also have this error,
but because i use @angular-devkit/build-angular:browser-esbuild to builder
it is angular docs:https://angular.io/guide/esbuild

@cipchk
Copy link
Member

cipchk commented Jul 24, 2023

@qyjs @shalltears Since esbuild does not support inline Javascript by default, see: angular/angular-cli#25572

@belwalshubham
Copy link

Hey I'm also getting this below error how can I resolve this

 ERROR #98123  WEBPACK.DEVELOP

Generating development JavaScript bundle failed

Module build failed (from ./node_modules/gatsby-plugin-less/node_module
s/less-loader/dist/cjs.js):

// https://github.com/ant-design/ant-motion/issues/44
.bezierEasingMixin();
^
Inline JavaScript is not enabled. Is it set in your options?
      Error in /Users/shubhambelwal/Documents/xxx/nod
e_modules/antd/es/style/color/bezierEasing.less (line 110, column 0)

Here is my Gatsby configuration in gatsby-config.js:

module.exports = {
  plugins: [
    'gatsby-plugin-antd',
    'gatsby-plugin-less',
    {
      resolve: 'gatsby-plugin-antd',
      options: {
        javascriptEnabled: true,
        style: true,
      }
    },
    {
      resolve: 'gatsby-plugin-less',
      options: {
        javascriptEnabled: true,
      },
  ]
}

I have the following dependencies installed:

gatsby-plugin-less@^6.20.0
less@^2.7.1
less-loader@^3.0.0
gatsby-plugin-antd@^2.2.0
antd@^3.26.11

Despite configuring the plugins with javascriptEnabled: true, I'm still encountering this error. How can I resolve this issue?

Any help or insights would be greatly appreciated. Thank you!

@ogix
Copy link
Contributor

ogix commented Apr 2, 2024

This issue is already open for 2 years. Any updates? It should be fixed before Angular drops support for this flag.

@micobarac
Copy link

Still the same in Angular 17.3.0 and NG-Zorro 17.3.0:

▲ [WARNING] Deprecated inline execution of JavaScript has been enabled ("javascriptEnabled") [plugin angular-less]

    node_modules/ng-zorro-antd/style/color/bezierEasing.less:110:0:
      110 │ .bezierEasingMixin();
          ╵ ^

  JavaScript found within less stylesheets may be executed at build time. [https://lesscss.org/usage/#less-options]
  Support for "javascriptEnabled" may be removed from the Angular CLI starting with Angular v19.
  The plugin "angular-less" was triggered by this import

    angular:styles/global:styles:1:8:

@micobarac
Copy link

micobarac commented Apr 18, 2024

Here's an example of how you can define a Bezier easing function in Less, without javascript:

// Define a mixin for Bezier easing
.bezierEasingMixin(@x1, @y1, @x2, @y2) {
  @bezierEasing: cubic-bezier(@x1, @y1, @x2, @y2);
}

// Usage example
.myAnimation {
  .bezierEasingMixin(0.26, 0.09, 0.37, 0.18);
  transition: all 0.3s @bezierEasing; // Use the Bezier easing in a CSS property
}

@gkorakas-eli
Copy link

Any updates?

@strybol-nicolas
Copy link

Updates or feedback on this issue would be greatly appreciated!

@dylanvdmerwe
Copy link

Does this mean we cannot use esbuild yet with ngzorro?

@HyperLife1119 HyperLife1119 linked a pull request May 27, 2024 that will close this issue
3 tasks
@HyperLife1119
Copy link
Collaborator

HyperLife1119 commented May 27, 2024

Does this mean we cannot use esbuild yet with ngzorro?

Currently zorro can be used with esbuild,, just ignore the warning message. We plan to eliminate this warning in v18 :)

@TuKun33
Copy link

TuKun33 commented May 31, 2024

Hey I'm also getting this below error how can I resolve this

 ERROR #98123  WEBPACK.DEVELOP

Generating development JavaScript bundle failed

Module build failed (from ./node_modules/gatsby-plugin-less/node_module
s/less-loader/dist/cjs.js):

// https://github.com/ant-design/ant-motion/issues/44
.bezierEasingMixin();
^
Inline JavaScript is not enabled. Is it set in your options?
      Error in /Users/shubhambelwal/Documents/xxx/nod
e_modules/antd/es/style/color/bezierEasing.less (line 110, column 0)

Here is my Gatsby configuration in gatsby-config.js:

module.exports = {
  plugins: [
    'gatsby-plugin-antd',
    'gatsby-plugin-less',
    {
      resolve: 'gatsby-plugin-antd',
      options: {
        javascriptEnabled: true,
        style: true,
      }
    },
    {
      resolve: 'gatsby-plugin-less',
      options: {
        javascriptEnabled: true,
      },
  ]
}

I have the following dependencies installed:

gatsby-plugin-less@^6.20.0
less@^2.7.1
less-loader@^3.0.0
gatsby-plugin-antd@^2.2.0
antd@^3.26.11

Despite configuring the plugins with javascriptEnabled: true, I'm still encountering this error. How can I resolve this issue?

Any help or insights would be greatly appreciated. Thank you!

Thinks, 🤗 its working for me to downgraded less to v2.7.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.