vite-plugin-cross-origin-storage 1.4.4 → 1.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +27 -11
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1638,16 +1638,24 @@ function cosPlugin(options = {}) {
1638
1638
  const include = options.include || ["**/*"];
1639
1639
  const includeArray = Array.isArray(include) ? include : [include];
1640
1640
  const require2 = createRequire(path.join(process.cwd(), "index.js"));
1641
- for (const item of includeArray) {
1641
+ function getPackageName(item) {
1642
1642
  if (typeof item === "string") {
1643
- let pkgName = item;
1644
- if (item.startsWith("vendor-")) {
1645
- pkgName = item.replace("vendor-", "");
1646
- }
1643
+ return item.startsWith("vendor-") ? item.replace("vendor-", "") : item;
1644
+ }
1645
+ if (item instanceof RegExp) {
1646
+ const source = item.source;
1647
+ const match = source.match(/vendor-([a-zA-Z0-9-@/]+?)(?:[-._]|\/|$)/);
1648
+ return match ? match[1] : null;
1649
+ }
1650
+ return null;
1651
+ }
1652
+ for (const item of includeArray) {
1653
+ const pkgName = getPackageName(item);
1654
+ if (pkgName) {
1647
1655
  try {
1648
1656
  require2.resolve(pkgName);
1649
1657
  if (!externalArray.includes(pkgName)) {
1650
- console.log(`COS Plugin: [MAGIC] Externalizing package "${pkgName}"`);
1658
+ console.log(`COS Plugin: [MAGIC] Externalizing package "${pkgName}" (matched from ${item})`);
1651
1659
  externalArray.push(pkgName);
1652
1660
  }
1653
1661
  } catch (e) {
@@ -1695,12 +1703,20 @@ function cosPlugin(options = {}) {
1695
1703
  const require2 = createRequire(path.join(process.cwd(), "index.js"));
1696
1704
  const include = options.include || ["**/*"];
1697
1705
  const includeArray = Array.isArray(include) ? include : [include];
1698
- for (const item of includeArray) {
1699
- if (typeof item !== "string") continue;
1700
- let pkgName = item;
1701
- if (item.startsWith("vendor-")) {
1702
- pkgName = item.replace("vendor-", "");
1706
+ function getPackageName(item) {
1707
+ if (typeof item === "string") {
1708
+ return item.startsWith("vendor-") ? item.replace("vendor-", "") : item;
1709
+ }
1710
+ if (item instanceof RegExp) {
1711
+ const source = item.source;
1712
+ const match = source.match(/vendor-([a-zA-Z0-9-@/]+?)(?:[-._]|\/|$)/);
1713
+ return match ? match[1] : null;
1703
1714
  }
1715
+ return null;
1716
+ }
1717
+ for (const item of includeArray) {
1718
+ const pkgName = getPackageName(item);
1719
+ if (!pkgName) continue;
1704
1720
  try {
1705
1721
  let pkgPath = "";
1706
1722
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-plugin-cross-origin-storage",
3
- "version": "1.4.4",
3
+ "version": "1.4.5",
4
4
  "description": "Vite plugin to load chunks from Cross-Origin Storage",
5
5
  "keywords": [
6
6
  "vite",