bpmn-io / bpmnlint

Validate BPMN diagrams based on configurable lint rules.
MIT License
125 stars 37 forks source link

Compilation error in globle rules in version 10.3.0 #142

Closed nanfb closed 2 months ago

nanfb commented 2 months ago

Describe the Bug

In this version function hasName(event) { return ( event.name?.trim() !== '' ); } This function will cause build errors in webpack4. Should you consider modifying the writing method?

Steps to Reproduce

https://github.com/bpmn-io/bpmnlint/blob/main/rules/global.js

  1. do this
  2. do that
  3. now this happens

Expected Behavior

Environment

barmac commented 2 months ago

Please explain why. What's the error?

nanfb commented 2 months ago

Please explain why. What's the error?

It may be that the "?." operator is not supported. The project itself can be compiled correctly because of babel, but node_module will not recognize it. The situation may be more complicated. node version is 14+

barmac commented 2 months ago

Please paste the exact error. Note that Node 14 is not supported anymore, but anyway it is supposed to support optional chaining according to https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining#browser_compatibility

nanfb commented 2 months ago

请粘贴确切的错误。请注意,Node 14 不再受支持,但无论如何,根据https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining#browser_compatibility,它应该支持可选链接

error in ./node_modules/bpmnlint/rules/global.js Module parse failed: Unexpected token (82:17) You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders | function hasName(event) { | return ( | event.name?.trim() !== '' | ); | } @ ./src/.bpmnlintrc 86:0-43 88:27-33 @ ./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/babel-loader/lib!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/bpmn/bpmn/index.vue?vue&type=script&lang=js @ ./src/components/bpmn/bpmn/index.vue?vue&type=script&lang=js @ ./src/components/bpmn/bpmn/index.vue @ ./src sync ^.\/.*.vue$ @ ./src/utils/util.js @ ./src/permission.js @ ./src/main.js @ multi (webpack)-dev-server/client?http:// *** /sockjs-node (webpack)/hot/dev-server.js ./src/main.js

I just confirmed that it is not a problem with the node version. Because I upgraded the version some time ago, I forgot. The current version is 16+. I use bpmnlint-loader to identify .bpmnlintrc and there will be this problem. image I think it may be a problem with webpack or loader

barmac commented 2 months ago

Does the problem persist with Webpack 5? I think it's rather unlikely that we change the code from an already supported version of JavaScript. Note that optional chaining is broadly supported now.

barmac commented 2 months ago

I'll close this as not planned. In case you want to support old browsers, you can always transpile the code.