npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

weex-loader-for-didiprism

v1.0.3

Published

Webpack loader for Weex project.

Downloads

2

Readme

Weex Loader For DiDiPrism

A webpack loader for Weex project with DiDiPrism.

npm npm

这是一个Webpack Loader,它用在基于VueWeex项目中,通过该Loader生成在小桔棱镜中使用的属性,辅助小桔棱镜做标签元素的唯一ID校验。

快速上手

安装

Loader 已上传到 npm 仓库,使用下面的命令安装:

npm i --save weex-loader-for-didiprism

使用

安装之后,就可以在Webpack配置中使用它了,针对.vue做语法转换及解析。配置文件示例代码如下:

const webpackConfig = {
  entry: {
    index: './example/main.js'
  },
  mode: 'production', // 'development',
  output: {
    path: path.resolve(__dirname, 'dist'),
    filename: options.dev ? '[name].js' : '[name].js?[chunkhash]',
    chunkFilename: '[id].js?[chunkhash]',
    publicPath: options.dev ? '/assets/' : publicPath
  },
  module: {
    rules: [{
      test: /\.vue$/,
      use: [
        'vue-loader',
        // 注意:需要将 weex-loader-for-prism 放到数组的靠后位置,因为Webpack是按照从后往前的顺序执行loader
        'weex-loader-for-didiprism'
      ]
    },
    {
      test: /\.js$/,
      use: ['babel-loader'],
      exclude: /node_modules/
    }]
  }
}

效果

Loader要实现的效果,是给带有点击事件的标签,自动添加一些小桔棱镜的属性,方便Native侧做元素的唯一标识。

比如,我们业务代码里写的是这样一个组件:

<template>
  <div @click="onClick">This is a subtitle.</div>
</template>
<script>
export default {
  data: () => ({

  }),
  methods: {
    onClick() {
      console.log('---click the subtitle---')
    }
  }
}
</script>
<style lang="less" scoped>

</style>

Webpack在经过weex-loader-for-didiprismvue-loader的打包之后,会将上面的Vue组件转换成这样一段AST代码:

var render = function() {
  var _vm = this
  var _h = _vm.$createElement
  var _c = _vm._self._c || _h
  return _c(
    "div",
    {
      staticClass: "content-title",
      attrs: { prismFunctionName: "onClick", prismClassName: "content-title" },
      on: { click: _vm.onClick }
    },
    [_vm._v("This is a title.")]
  )
}

有点击事件监听的标签,会多出两个属性:prismFunctionNameprismClassName,它们就是给小桔棱镜Native侧使用的属性。这样,开发者就不用手动添加这些属性,主需要关注业务逻辑即可。

协议