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 🙏

© 2024 – Pkg Stats / Ryan Hefner

mini-webpack-build

v1.0.0

Published

module.hot.accept()是webpack中的一个API,用于在开发模式下实现热更新。 热更新可以让代码更改后自动重新加载到浏览器中,而无需手动刷新页面。 module.hot.accept()允许开发者在代码发生变化时触发回调函数,通过回调函数来更新页面上的内容。

Downloads

2

Readme

module.hot.accept()是webpack中的一个API,用于在开发模式下实现热更新。 热更新可以让代码更改后自动重新加载到浏览器中,而无需手动刷新页面。 module.hot.accept()允许开发者在代码发生变化时触发回调函数,通过回调函数来更新页面上的内容。

"@babel/core" 是 Babel 的核心模块,它负责创建转换器(Transformer)以及协调其他 Babel 模块。 "@babel/parser" 是 Babel 的解析器,它将代码字符串解析为抽象语法树(AST)表示。 "@babel/preset-env" 是一个智能预设集合,可以根据目标环境自动确定所需的插件和 polyfill。 "@babel/traverse" 是一个 AST 遍历工具,可以帮助开发人员在节点级别对代码进行修改和转换。 这些工具可以一起使用来实现自定义的 JavaScript 编译器,以便将我们的源代码转换为浏览器、Node.js 或其他 JavaScript 运行时所能理解的版本,同时可以兼容各种环境以及旧版浏览器中的 ES6+ 特性。

cnpm install @babel/core @babel/parser @babel/preset-env @babel/traverse ./src/add.js export default (a, b) => a + b ./src/index.js import add from "./add.js"; console.log(add(1 , 2)) ./index.js 如下图所示 node index.js 于是就会在根目录下生成dist文件,并且生成bundle.js文件,执行它就会生成对应对应的结果 分析文件相互依赖如何实现打包的 把js文件按照键值对的形式,键为路径值,值为文件内容 需要导入到html文件,所以最开始是需要require函数,导入入口文件的 入口文件有个局部变量_export,防止文件间相互污染 根据文件路径,选择eval去执行对应的code字符串代码 如果在code内部含有require函数,则递归调用就行 !(function (obj) { function require(path) { var _export = {} !(function (_export, code) { eval(code) })(_export, obj[path]) // 先执行eval(code),他的内部再次访问require,

        return _export
    }
    // 入口
    require('./index.js')
})({
    './add.js': '_export.default = function (a, b) {return a + b}',
    './index.js': `
        var add = require('./add.js').default
        console.log(add(1 , 2)) 
    `,
})