vite-add-cdn-script 1.0.1 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import l from "cdn-script-core";
1
+ import { getExternalScript as l } from "cdn-script-core";
2
2
  var d = /* @__PURE__ */ ((e) => (e.PRE = "pre", e.POST = "post", e))(d || {});
3
3
  const s = "vite-add-cdn-script";
4
4
  function f(e) {
@@ -1 +1 @@
1
- (function(e,r){typeof exports=="object"&&typeof module<"u"?module.exports=r(require("cdn-script-core")):typeof define=="function"&&define.amd?define(["cdn-script-core"],r):(e=typeof globalThis<"u"?globalThis:e||self,e.index=r(e.getExternalScript))})(this,function(e){"use strict";var r=(n=>(n.PRE="pre",n.POST="post",n))(r||{});const c="vite-add-cdn-script";function f(n){const{customScript:a={},defaultCdns:i=["jsdelivr","unpkg"]}=n;let o;return{name:c,enforce:r.PRE,apply:"build",config(t){o=t},async transformIndexHtml(t){var p,u;if(!i||i.length===0)throw new Error("defaultCdns不能为空");const s=(u=(p=o.build)==null?void 0:p.rollupOptions)==null?void 0:u.external;if(!s)return t;try{const d=await e({libName:c,customScript:a,external:s,defaultCdns:i});return t=t.replace("</head>",`${d}</head>`),t}catch(d){console.error("vite-add-cdn-script error:",d.message),process.exit(1)}}}}return f});
1
+ (function(e,r){typeof exports=="object"&&typeof module<"u"?module.exports=r(require("cdn-script-core")):typeof define=="function"&&define.amd?define(["cdn-script-core"],r):(e=typeof globalThis<"u"?globalThis:e||self,e.index=r(e.cdnScriptCore))})(this,function(e){"use strict";var r=(n=>(n.PRE="pre",n.POST="post",n))(r||{});const d="vite-add-cdn-script";function f(n){const{customScript:a={},defaultCdns:i=["jsdelivr","unpkg"]}=n;let o;return{name:d,enforce:r.PRE,apply:"build",config(t){o=t},async transformIndexHtml(t){var p,u;if(!i||i.length===0)throw new Error("defaultCdns不能为空");const s=(u=(p=o.build)==null?void 0:p.rollupOptions)==null?void 0:u.external;if(!s)return t;try{const c=await e.getExternalScript({libName:d,customScript:a,external:s,defaultCdns:i});return t=t.replace("</head>",`${c}</head>`),t}catch(c){console.error("vite-add-cdn-script error:",c.message),process.exit(1)}}}}return f});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-add-cdn-script",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "keywords": [
5
5
  "vite",
6
6
  "cdn",
@@ -26,7 +26,7 @@
26
26
  "exports": {
27
27
  "types": "./index.d.ts",
28
28
  "import": "./dist/index.js",
29
- "require": "./dist/index.js"
29
+ "require": "./dist/index.umd.cjs"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@jest/globals": "^29.7.0",
@@ -52,7 +52,7 @@
52
52
  "registry": "https://registry.npmjs.org/"
53
53
  },
54
54
  "dependencies": {
55
- "cdn-script-core": "1.0.0"
55
+ "cdn-script-core": "1.0.2"
56
56
  },
57
57
  "scripts": {
58
58
  "dev": "vite",