https://zhengjiangtao.cn/show/zj/ataola-utils-amd.html
UMD <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta content="width=device-width, initial-scale=1.0"> <title>ataola utils</title> </head> <body> </body> <script src="http://unpkg.com/@ataola/utils@0.1.10/dist/ataola-utils.umd.js"></script> <script> const ataola = this['ataola-utils']; console.log(ataola); console.log(ataola.getVersion()); </script> </html>https://zhengjiangtao.cn/show/zj/ataola-utils-umd.html
IIFE <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta content="width=device-width, initial-scale=1.0"> <title>ataola utils</title> </head> <body> </body> <script src="http://unpkg.com/@ataola/utils@0.1.10/dist/ataola-utils.min.js"></script> <script> // https://unpkg.com/@ataola/utils@0.1.10/dist/ataola-utils.js // https://cdn.jsdelivr.net/npm/@ataola/utils@0.1.10/dist/ataola-utils.js // use this['ataola-utils'] || window['ataola-utils'] const ataola = this['ataola-utils']; console.log(ataola); console.log(ataola.getVersion()); </script> </html>https://zhengjiangtao.cn/show/zj/ataola-utils.html
ES Module <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta content="width=device-width, initial-scale=1.0"> <title>utils unpkg</title> </head> <body> </body> <script type="module"> import * as ataola from 'https://unpkg.com/@ataola/utils@0.1.10/dist/ataola-utils.esm.js'; console.log(ataola); </script> </html>https://zhengjiangtao.cn/show/zj/ataola-utils-amd.html
ComonJS这里AMD相关的引入需要你先引入require.js的支持,如果是commonJS模块的话,需要用seajs,我试了下不是很好使,我放弃了别打我,建议直接在node.js环境下引入,如楼上
参考文献Rollup官方文档:https://rollupjs.org/guide/zh/
Rollup插件库: https://github.com/rollup/plugins
IIFE: https://developer.mozilla.org/zh-CN/docs/Glossary/IIFE