Giter Club home page Giter Club logo

Comments (4)

hiyuki avatar hiyuki commented on July 19, 2024

这个问题同微信确认目前没有支持,不过他们会考虑后续如何支持这种写法,在微信支持之前可以先用混合写法把worklet函数静态定义在methods中

from mpx.

ItsRyanWu avatar ItsRyanWu commented on July 19, 2024

@hiyuki 我这边还测试到 worklet 函数即使写在 methods 中,dev 模式可以,但 build 之后就不行了

from mpx.

hiyuki avatar hiyuki commented on July 19, 2024

这是因为terser默认会删除非标准的directives,可以更改terser配置规避这个问题:

new TerserPlugin({
  // terserOptions参考 https://github.com/webpack-contrib/terser-webpack-plugin#terseroptions
  terserOptions: {
    compress: {
      // terser的默认行为会把某些对象方法转为箭头函数,导致ios9等不支持箭头函数的环境白屏,详情见 https://github.com/terser/terser#compress-options
      arrows: false,
      // terser默认会删除非标准directive,为了保障skyline worklet的正常工作,需关闭该配置
      directives: false
    }
  }
}

我们更建议的做法是安装微信提供的babel插件,不仅可以规避上面这个问题,也不用依赖微信开发者工具的es5转义和worklet编译,插件地址:
https://www.npmjs.com/package/babel-plugin-worklet

from mpx.

ItsRyanWu avatar ItsRyanWu commented on July 19, 2024

感谢

from mpx.

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.