diff --git a/src/helpers.ts b/src/helpers.ts index 1f659b7..21f3742 100644 --- a/src/helpers.ts +++ b/src/helpers.ts @@ -1,4 +1,3 @@ -import { FilterPattern, normalizePath } from "@rollup/pluginutils"; import path from "path"; import { OutputOptions } from "rollup"; @@ -25,16 +24,3 @@ export function getRelativeImportPath(from: string, to: string) { return import_path; } - -export function normalizeFilterPattern(pattern?: FilterPattern): FilterPattern | undefined { - if (typeof pattern === "string") return normalizePath(pattern); - - if (Array.isArray(pattern)) { - return pattern.map(element => { - if (typeof element === "string") return normalizePath(element); - return element; - }); - } - - return pattern; -} diff --git a/src/index.ts b/src/index.ts index 94cf9a1..11c3bdf 100644 --- a/src/index.ts +++ b/src/index.ts @@ -3,7 +3,7 @@ import path from "path"; import { Plugin } from "rollup"; import { createFilter, FilterPattern, normalizePath } from "@rollup/pluginutils"; import { parse, print, types, visit } from "recast"; -import { getOutputId, getRelativeImportPath, normalizeFilterPattern } from "./helpers"; +import { getOutputId, getRelativeImportPath } from "./helpers"; const PLUGIN_NAME = "external-assets"; const PREFIX = `\0${PLUGIN_NAME}:`; @@ -34,8 +34,6 @@ export default function externalAssets( exclude?: FilterPattern, options?: Options, ): Plugin { - include = normalizeFilterPattern(include); - exclude = normalizeFilterPattern(exclude); const idFilter = createFilter(include, exclude, options); const assets = new Map(); diff --git a/tests/unit.test.ts b/tests/unit.test.ts index 9e91f5f..85a3313 100644 --- a/tests/unit.test.ts +++ b/tests/unit.test.ts @@ -1,5 +1,5 @@ import path from "path"; -import { getOutputId, normalizeFilterPattern } from "../src/helpers"; +import { getOutputId } from "../src/helpers"; test("getOutputId", () => { expect(getOutputId("a.ext", { dir: "out" })).toBe(path.resolve("out/a.ext")); @@ -12,23 +12,3 @@ test("getOutputId", () => { expect(getOutputId("a.ext", {})).toBe(path.resolve("a.ext")); expect(getOutputId("a/b.ext", {})).toBe(path.resolve("a/b.ext")); }); - -test("normalizeFilterPattern", () => { - expect(normalizeFilterPattern()).toBeUndefined(); - expect(normalizeFilterPattern(null)).toBeNull(); - expect(normalizeFilterPattern(/\.txt/g)).toStrictEqual(/\.txt/g); - expect(normalizeFilterPattern("abc/def/**/*")).toBe("abc/def/**/*"); - expect(normalizeFilterPattern("abc\\def\\**\\*")).toBe("abc/def/**/*"); - expect(normalizeFilterPattern(path.resolve("abc/def/**/*"))).toBe(path.resolve("abc/def/**/*").replace(/\\/g, "/")); - expect([ - normalizeFilterPattern(/\.txt/g), - normalizeFilterPattern("abc/def/**/*"), - normalizeFilterPattern("abc\\def\\**\\*"), - normalizeFilterPattern(path.resolve("abc/def/**/*")), - ]).toStrictEqual([ - /\.txt/g, - "abc/def/**/*", - "abc/def/**/*", - path.resolve("abc/def/**/*").replace(/\\/g, "/"), - ]); -});