From 9f983d29af242071d8a5ef9ef69de18e09a6404f Mon Sep 17 00:00:00 2001 From: Mateusz Tomkowiak Date: Sat, 26 Feb 2022 19:46:20 +0100 Subject: [PATCH 1/2] Support rollup-plugin-multi-input. Add optional no hash option. --- package-lock.json | 23 ++++++++++ package.json | 1 + src/index.js | 43 +++++++++++++----- .../__snapshots__/index.test.js.snap | 28 ++++++++++++ test/multi-input/index.test.js | 19 ++++++++ test/multi-input/src/image.png | Bin 0 -> 95 bytes test/multi-input/src/index.js | 3 ++ test/multi-input/src/sub/folder/child.js | 6 +++ test/multi-input/src/sub/folder/content.md | 1 + .../__snapshots__/index.test.js.snap | 19 ++++++++ test/no-use-hash/content.md | 1 + test/no-use-hash/image.png | Bin 0 -> 95 bytes test/no-use-hash/index.js | 6 +++ test/no-use-hash/index.test.js | 14 ++++++ test/util.js | 18 ++++++++ 15 files changed, 170 insertions(+), 12 deletions(-) create mode 100644 test/multi-input/__snapshots__/index.test.js.snap create mode 100644 test/multi-input/index.test.js create mode 100644 test/multi-input/src/image.png create mode 100644 test/multi-input/src/index.js create mode 100644 test/multi-input/src/sub/folder/child.js create mode 100644 test/multi-input/src/sub/folder/content.md create mode 100644 test/no-use-hash/__snapshots__/index.test.js.snap create mode 100644 test/no-use-hash/content.md create mode 100644 test/no-use-hash/image.png create mode 100644 test/no-use-hash/index.js create mode 100644 test/no-use-hash/index.test.js diff --git a/package-lock.json b/package-lock.json index 3c30bd7..31b5154 100644 --- a/package-lock.json +++ b/package-lock.json @@ -35,6 +35,7 @@ "release-it": "^14.12.3", "rimraf": "^3.0.2", "rollup": "^2.64.0", + "rollup-plugin-multi-input": "^1.3.1", "semver": "^7.3.5", "typescript": "^4.5.4" }, @@ -13917,6 +13918,17 @@ "yarn": ">=1.0.0" } }, + "node_modules/rollup-plugin-multi-input": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/rollup-plugin-multi-input/-/rollup-plugin-multi-input-1.3.1.tgz", + "integrity": "sha512-bPsxHR6dUney7zsCAAlfkq7lbuy5xph2CvUstSv88oqhtRiLWXwVjiA1Gb4HVjC6I9sJI2eZeQlozXa+GXJKDA==", + "dev": true, + "dependencies": { + "core-js": "^3.1.3", + "fast-glob": "^3.0.0", + "lodash": "^4.17.11" + } + }, "node_modules/rollup-plugin-rebase": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/rollup-plugin-rebase/-/rollup-plugin-rebase-4.0.0.tgz", @@ -26629,6 +26641,17 @@ "@babel/runtime": "^7.14.0" } }, + "rollup-plugin-multi-input": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/rollup-plugin-multi-input/-/rollup-plugin-multi-input-1.3.1.tgz", + "integrity": "sha512-bPsxHR6dUney7zsCAAlfkq7lbuy5xph2CvUstSv88oqhtRiLWXwVjiA1Gb4HVjC6I9sJI2eZeQlozXa+GXJKDA==", + "dev": true, + "requires": { + "core-js": "^3.1.3", + "fast-glob": "^3.0.0", + "lodash": "^4.17.11" + } + }, "rollup-plugin-rebase": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/rollup-plugin-rebase/-/rollup-plugin-rebase-4.0.0.tgz", diff --git a/package.json b/package.json index a98e04f..8e21fe3 100644 --- a/package.json +++ b/package.json @@ -61,6 +61,7 @@ "release-it": "^14.12.3", "rimraf": "^3.0.2", "rollup": "^2.64.0", + "rollup-plugin-multi-input": "^1.3.1", "semver": "^7.3.5", "typescript": "^4.5.4" } diff --git a/src/index.js b/src/index.js index 05bb427..cc2c8e3 100644 --- a/src/index.js +++ b/src/index.js @@ -11,6 +11,8 @@ import postcssSugarSS from "sugarss" import { createFilter } from "@rollup/pluginutils" import { getHash } from "asset-hash" +const MULTI_INPUT_PLUGIN_NAME = 'rollup-plugin-multi-input'; + const scriptExtensions = /^\.(json|mjs|js|jsx|ts|tsx)$/ const styleParser = { @@ -21,22 +23,22 @@ const styleParser = { ".sass": postcssSass } -function getPostCssPlugins(keepName) { +function getPostCssPlugins(keepName, useHash) { return [ postcssImport(), postcssSmartAsset({ url: "copy", - useHash: true, - keepName + useHash, + keepName, }) ] } /* eslint-disable max-params */ -async function processStyle(id, fileDest, keepName) { +async function processStyle(id, fileDest, keepName, useHash) { const content = await fs.readFile(id) const parser = styleParser[path.extname(id)] - const processor = postcss(getPostCssPlugins(keepName)) + const processor = postcss(getPostCssPlugins(keepName, useHash)) const text = content.toString() const result = await processor.process(text, { @@ -61,7 +63,8 @@ export default function rebase(options = {}) { exclude, verbose = false, keepName = false, - assetFolder = "" + useHash = true, + assetFolder = "", } = options const filter = createFilter(include, exclude) @@ -70,6 +73,7 @@ export default function rebase(options = {}) { const files = {} let root = null + let hasMultiInput = false; function rootRelative(file) { // Last sequence is for Windows support @@ -94,12 +98,20 @@ export default function rebase(options = {}) { return Boolean(files[fileSource]) }, + options({ plugins }) { + // Check whether we are using rollup-plugin-multi-input + hasMultiInput = !!plugins?.some(plugin => plugin != null && typeof plugin !== "boolean" && plugin.name === MULTI_INPUT_PLUGIN_NAME); + }, + /* eslint-disable complexity, max-statements */ async resolveId(importee, importer) { // Ignore root files which are typically script files. Delegate to other // plugins or default behavior. if (!importer) { - root = path.dirname(path.resolve(importee)) + // If multiInput is detected, set root once for proper paths + if (!hasMultiInput || (hasMultiInput && !root)) { + root = path.dirname(path.resolve(importee)) + } return null } @@ -142,10 +154,17 @@ export default function rebase(options = {}) { } const fileName = path.basename(importee, fileExt) - const fileHash = await getHash(fileSource) - const fileTarget = keepName - ? `${fileName}~${fileHash}${fileExt}` - : `${fileHash}${fileExt}` + + // Set default file target name + let fileTarget = `${fileName}${fileExt}`; + + if (useHash) { + // If using hash, decide whether we should keep name or hash only + const fileHash = await getHash(fileSource); + fileTarget = keepName + ? `${fileName}~${fileHash}${fileExt}` + : `${fileHash}${fileExt}`; + } // Registering for our copying job when the bundle is created (kind of a job queue) // and respect any sub folder given by the configuration options. @@ -208,7 +227,7 @@ export default function rebase(options = {}) { ) } - await processStyle(fileSource, fileDest, keepName) + await processStyle(fileSource, fileDest, keepName, useHash) } else { if (verbose) { console.log( diff --git a/test/multi-input/__snapshots__/index.test.js.snap b/test/multi-input/__snapshots__/index.test.js.snap new file mode 100644 index 0000000..e87d4d1 --- /dev/null +++ b/test/multi-input/__snapshots__/index.test.js.snap @@ -0,0 +1,28 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Multi input support 1`] = ` +"HDWIGpiP.md +SmVOQyTt.png +index.js +sub" +`; + +exports[`Multi input support 2`] = ` +"import index from './sub/folder/child.js'; +export { default } from './sub/folder/child.js'; +import './SmVOQyTt.png'; +import './HDWIGpiP.md'; +" +`; + +exports[`Multi input support 3`] = ` +"import image from '../../SmVOQyTt.png'; +import content from '../../HDWIGpiP.md'; + +function index() { + return content + image +} + +export { index as default }; +" +`; diff --git a/test/multi-input/index.test.js b/test/multi-input/index.test.js new file mode 100644 index 0000000..9271197 --- /dev/null +++ b/test/multi-input/index.test.js @@ -0,0 +1,19 @@ +import { bundleWithMultiInput, clean, list, read } from "../util" +import { join, sep } from "path" + +const root = __dirname + +test("Multi input support", async () => { + await bundleWithMultiInput(root, ['src/**/!(*.test).js'], "output", {}, { + transformOutputPath: (output) => { + // Need to transform output as bundle path starts from root of project + return output.replace(`${join('test', 'multi-input', 'src')}${sep}`, ''); + }, + }) + + expect(await list(root, "output")).toMatchSnapshot() + expect(await read(root, "output/index.js")).toMatchSnapshot() + expect(await read(root, "output/sub/folder/child.js")).toMatchSnapshot() + + await clean(root, "output") +}) diff --git a/test/multi-input/src/image.png b/test/multi-input/src/image.png new file mode 100644 index 0000000000000000000000000000000000000000..c5916f289705642eec4975cf51458b9afeefe46c GIT binary patch literal 95 zcmeAS@N?(olHy`uVBq!ia0vp^j3CU&3?x-=hn)ga%mF?juK#@*VoWXSL2@NQe!*uh mnS}iXa=1KQ978JRBqsscYz)k1<~1vTECx?kKbLh*2~7ZT-W2Wt literal 0 HcmV?d00001 diff --git a/test/multi-input/src/index.js b/test/multi-input/src/index.js new file mode 100644 index 0000000..aa0734b --- /dev/null +++ b/test/multi-input/src/index.js @@ -0,0 +1,3 @@ +import index from "./sub/folder/child" + +export default index diff --git a/test/multi-input/src/sub/folder/child.js b/test/multi-input/src/sub/folder/child.js new file mode 100644 index 0000000..7b67167 --- /dev/null +++ b/test/multi-input/src/sub/folder/child.js @@ -0,0 +1,6 @@ +import image from "../../image.png" +import content from "./content.md" + +export default function() { + return content + image +} diff --git a/test/multi-input/src/sub/folder/content.md b/test/multi-input/src/sub/folder/content.md new file mode 100644 index 0000000..fec5601 --- /dev/null +++ b/test/multi-input/src/sub/folder/content.md @@ -0,0 +1 @@ +# Hello diff --git a/test/no-use-hash/__snapshots__/index.test.js.snap b/test/no-use-hash/__snapshots__/index.test.js.snap new file mode 100644 index 0000000..3b84539 --- /dev/null +++ b/test/no-use-hash/__snapshots__/index.test.js.snap @@ -0,0 +1,19 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`No use hash 1`] = ` +"content.md +image.png +index.js" +`; + +exports[`No use hash 2`] = ` +"import content from './content.md'; +import image from './image.png'; + +function index() { + return content + image +} + +export { index as default }; +" +`; diff --git a/test/no-use-hash/content.md b/test/no-use-hash/content.md new file mode 100644 index 0000000..fec5601 --- /dev/null +++ b/test/no-use-hash/content.md @@ -0,0 +1 @@ +# Hello diff --git a/test/no-use-hash/image.png b/test/no-use-hash/image.png new file mode 100644 index 0000000000000000000000000000000000000000..c5916f289705642eec4975cf51458b9afeefe46c GIT binary patch literal 95 zcmeAS@N?(olHy`uVBq!ia0vp^j3CU&3?x-=hn)ga%mF?juK#@*VoWXSL2@NQe!*uh mnS}iXa=1KQ978JRBqsscYz)k1<~1vTECx?kKbLh*2~7ZT-W2Wt literal 0 HcmV?d00001 diff --git a/test/no-use-hash/index.js b/test/no-use-hash/index.js new file mode 100644 index 0000000..eb32e25 --- /dev/null +++ b/test/no-use-hash/index.js @@ -0,0 +1,6 @@ +import content from "./content.md" +import image from "./image.png" + +export default function() { + return content + image +} diff --git a/test/no-use-hash/index.test.js b/test/no-use-hash/index.test.js new file mode 100644 index 0000000..91b8703 --- /dev/null +++ b/test/no-use-hash/index.test.js @@ -0,0 +1,14 @@ +import { bundle, clean, list, read } from "../util" + +const root = __dirname + +test("No use hash", async () => { + await bundle(root, "index.js", "output/index.js", { + useHash: false, + }) + + expect(await list(root, "output")).toMatchSnapshot() + expect(await read(root, "output/index.js")).toMatchSnapshot() + + await clean(root, "output") +}) diff --git a/test/util.js b/test/util.js index 00c3b52..9665ca3 100644 --- a/test/util.js +++ b/test/util.js @@ -3,6 +3,7 @@ import { readdir } from "fs" import fs from "fs-extra" import { rollup } from "rollup" +import multiInput from "rollup-plugin-multi-input"; import rebasePlugin from "../src" @@ -21,6 +22,23 @@ export async function bundle(root, input, output, pluginOptions = {}) { }) } +export async function bundleWithMultiInput(root, input, output, pluginOptions = {}, multiInputOptions = {}) { + const plugins = [ + multiInput(multiInputOptions), + rebasePlugin(pluginOptions) + ]; + + const result = await rollup({ + input: input.map(i => join(root, i)), + plugins, + }) + + await result.write({ + format: "es", + dir: join(root, output), + }) +} + export async function clean(root, files) { const input = Array.isArray(files) ? files : [ files ] const tasks = input.map((file) => fs.remove(join(root, file))) From 36f17d24450856b8c7d1a2749d3add51546748fa Mon Sep 17 00:00:00 2001 From: Mateusz Tomkowiak Date: Fri, 13 May 2022 10:06:03 +0200 Subject: [PATCH 2/2] Add skipHash option --- package-lock.json | 25 +------------- package.json | 1 - readme.md | 1 + src/index.js | 31 ++++++------------ .../__snapshots__/index.test.js.snap | 28 ---------------- test/multi-input/index.test.js | 19 ----------- test/multi-input/src/index.js | 3 -- test/multi-input/src/sub/folder/child.js | 6 ---- test/no-use-hash/content.md | 1 - test/no-use-hash/image.png | Bin 95 -> 0 bytes .../__snapshots__/index.test.js.snap | 4 +-- .../src/sub/folder => skip-hash}/content.md | 0 test/{multi-input/src => skip-hash}/image.png | Bin test/{no-use-hash => skip-hash}/index.js | 0 test/{no-use-hash => skip-hash}/index.test.js | 4 +-- test/util.js | 18 ---------- 16 files changed, 16 insertions(+), 125 deletions(-) delete mode 100644 test/multi-input/__snapshots__/index.test.js.snap delete mode 100644 test/multi-input/index.test.js delete mode 100644 test/multi-input/src/index.js delete mode 100644 test/multi-input/src/sub/folder/child.js delete mode 100644 test/no-use-hash/content.md delete mode 100644 test/no-use-hash/image.png rename test/{no-use-hash => skip-hash}/__snapshots__/index.test.js.snap (80%) rename test/{multi-input/src/sub/folder => skip-hash}/content.md (100%) rename test/{multi-input/src => skip-hash}/image.png (100%) rename test/{no-use-hash => skip-hash}/index.js (100%) rename test/{no-use-hash => skip-hash}/index.test.js (84%) diff --git a/package-lock.json b/package-lock.json index 2c105a4..3130797 100644 --- a/package-lock.json +++ b/package-lock.json @@ -35,12 +35,11 @@ "release-it": "^14.13.1", "rimraf": "^3.0.2", "rollup": "^2.70.1", - "rollup-plugin-multi-input": "^1.3.1", "semver": "^7.3.5", "typescript": "^4.6.2" }, "engines": { - "node": ">=16.0.0" + "node": ">=14" } }, "node_modules/@ampproject/remapping": { @@ -13940,17 +13939,6 @@ "yarn": ">=1.0.0" } }, - "node_modules/rollup-plugin-multi-input": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/rollup-plugin-multi-input/-/rollup-plugin-multi-input-1.3.1.tgz", - "integrity": "sha512-bPsxHR6dUney7zsCAAlfkq7lbuy5xph2CvUstSv88oqhtRiLWXwVjiA1Gb4HVjC6I9sJI2eZeQlozXa+GXJKDA==", - "dev": true, - "dependencies": { - "core-js": "^3.1.3", - "fast-glob": "^3.0.0", - "lodash": "^4.17.11" - } - }, "node_modules/rollup-plugin-rebase": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/rollup-plugin-rebase/-/rollup-plugin-rebase-4.0.1.tgz", @@ -26680,17 +26668,6 @@ "@babel/runtime": "^7.14.0" } }, - "rollup-plugin-multi-input": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/rollup-plugin-multi-input/-/rollup-plugin-multi-input-1.3.1.tgz", - "integrity": "sha512-bPsxHR6dUney7zsCAAlfkq7lbuy5xph2CvUstSv88oqhtRiLWXwVjiA1Gb4HVjC6I9sJI2eZeQlozXa+GXJKDA==", - "dev": true, - "requires": { - "core-js": "^3.1.3", - "fast-glob": "^3.0.0", - "lodash": "^4.17.11" - } - }, "rollup-plugin-rebase": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/rollup-plugin-rebase/-/rollup-plugin-rebase-4.0.1.tgz", diff --git a/package.json b/package.json index 400aec5..2a823ae 100644 --- a/package.json +++ b/package.json @@ -61,7 +61,6 @@ "release-it": "^14.13.1", "rimraf": "^3.0.2", "rollup": "^2.70.1", - "rollup-plugin-multi-input": "^1.3.1", "semver": "^7.3.5", "typescript": "^4.6.2" } diff --git a/readme.md b/readme.md index 516fe69..40d5922 100644 --- a/readme.md +++ b/readme.md @@ -61,6 +61,7 @@ config() - `assetFolder`: When set assets are placed inside a sub folder with that name. - `keepName`: If `true`, generated filenames will be `${filename}~${hash}.${ext}` instead of just `${hash}.${ext}` +- `skipHash`: If `true`, filenames will not include hash and will keep names - `verbose`: If `true`, increases log level - `include`: Standard include option for rollup plugins. - `exclude`: Standard exclude option for rollup plugins. diff --git a/src/index.js b/src/index.js index cc2c8e3..8426c2b 100644 --- a/src/index.js +++ b/src/index.js @@ -11,8 +11,6 @@ import postcssSugarSS from "sugarss" import { createFilter } from "@rollup/pluginutils" import { getHash } from "asset-hash" -const MULTI_INPUT_PLUGIN_NAME = 'rollup-plugin-multi-input'; - const scriptExtensions = /^\.(json|mjs|js|jsx|ts|tsx)$/ const styleParser = { @@ -23,22 +21,22 @@ const styleParser = { ".sass": postcssSass } -function getPostCssPlugins(keepName, useHash) { +function getPostCssPlugins(keepName, skipHash) { return [ postcssImport(), postcssSmartAsset({ url: "copy", - useHash, + useHash: !skipHash, keepName, }) ] } /* eslint-disable max-params */ -async function processStyle(id, fileDest, keepName, useHash) { +async function processStyle(id, fileDest, keepName, skipHash) { const content = await fs.readFile(id) const parser = styleParser[path.extname(id)] - const processor = postcss(getPostCssPlugins(keepName, useHash)) + const processor = postcss(getPostCssPlugins(keepName, skipHash)) const text = content.toString() const result = await processor.process(text, { @@ -63,7 +61,7 @@ export default function rebase(options = {}) { exclude, verbose = false, keepName = false, - useHash = true, + skipHash = false, assetFolder = "", } = options @@ -73,7 +71,6 @@ export default function rebase(options = {}) { const files = {} let root = null - let hasMultiInput = false; function rootRelative(file) { // Last sequence is for Windows support @@ -98,20 +95,12 @@ export default function rebase(options = {}) { return Boolean(files[fileSource]) }, - options({ plugins }) { - // Check whether we are using rollup-plugin-multi-input - hasMultiInput = !!plugins?.some(plugin => plugin != null && typeof plugin !== "boolean" && plugin.name === MULTI_INPUT_PLUGIN_NAME); - }, - /* eslint-disable complexity, max-statements */ async resolveId(importee, importer) { // Ignore root files which are typically script files. Delegate to other // plugins or default behavior. if (!importer) { - // If multiInput is detected, set root once for proper paths - if (!hasMultiInput || (hasMultiInput && !root)) { - root = path.dirname(path.resolve(importee)) - } + root = path.dirname(path.resolve(importee)) return null } @@ -156,14 +145,14 @@ export default function rebase(options = {}) { const fileName = path.basename(importee, fileExt) // Set default file target name - let fileTarget = `${fileName}${fileExt}`; + let fileTarget = `${fileName}${fileExt}` - if (useHash) { + if (!skipHash) { // If using hash, decide whether we should keep name or hash only const fileHash = await getHash(fileSource); fileTarget = keepName ? `${fileName}~${fileHash}${fileExt}` - : `${fileHash}${fileExt}`; + : `${fileHash}${fileExt}` } // Registering for our copying job when the bundle is created (kind of a job queue) @@ -227,7 +216,7 @@ export default function rebase(options = {}) { ) } - await processStyle(fileSource, fileDest, keepName, useHash) + await processStyle(fileSource, fileDest, keepName, skipHash) } else { if (verbose) { console.log( diff --git a/test/multi-input/__snapshots__/index.test.js.snap b/test/multi-input/__snapshots__/index.test.js.snap deleted file mode 100644 index e87d4d1..0000000 --- a/test/multi-input/__snapshots__/index.test.js.snap +++ /dev/null @@ -1,28 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`Multi input support 1`] = ` -"HDWIGpiP.md -SmVOQyTt.png -index.js -sub" -`; - -exports[`Multi input support 2`] = ` -"import index from './sub/folder/child.js'; -export { default } from './sub/folder/child.js'; -import './SmVOQyTt.png'; -import './HDWIGpiP.md'; -" -`; - -exports[`Multi input support 3`] = ` -"import image from '../../SmVOQyTt.png'; -import content from '../../HDWIGpiP.md'; - -function index() { - return content + image -} - -export { index as default }; -" -`; diff --git a/test/multi-input/index.test.js b/test/multi-input/index.test.js deleted file mode 100644 index 9271197..0000000 --- a/test/multi-input/index.test.js +++ /dev/null @@ -1,19 +0,0 @@ -import { bundleWithMultiInput, clean, list, read } from "../util" -import { join, sep } from "path" - -const root = __dirname - -test("Multi input support", async () => { - await bundleWithMultiInput(root, ['src/**/!(*.test).js'], "output", {}, { - transformOutputPath: (output) => { - // Need to transform output as bundle path starts from root of project - return output.replace(`${join('test', 'multi-input', 'src')}${sep}`, ''); - }, - }) - - expect(await list(root, "output")).toMatchSnapshot() - expect(await read(root, "output/index.js")).toMatchSnapshot() - expect(await read(root, "output/sub/folder/child.js")).toMatchSnapshot() - - await clean(root, "output") -}) diff --git a/test/multi-input/src/index.js b/test/multi-input/src/index.js deleted file mode 100644 index aa0734b..0000000 --- a/test/multi-input/src/index.js +++ /dev/null @@ -1,3 +0,0 @@ -import index from "./sub/folder/child" - -export default index diff --git a/test/multi-input/src/sub/folder/child.js b/test/multi-input/src/sub/folder/child.js deleted file mode 100644 index 7b67167..0000000 --- a/test/multi-input/src/sub/folder/child.js +++ /dev/null @@ -1,6 +0,0 @@ -import image from "../../image.png" -import content from "./content.md" - -export default function() { - return content + image -} diff --git a/test/no-use-hash/content.md b/test/no-use-hash/content.md deleted file mode 100644 index fec5601..0000000 --- a/test/no-use-hash/content.md +++ /dev/null @@ -1 +0,0 @@ -# Hello diff --git a/test/no-use-hash/image.png b/test/no-use-hash/image.png deleted file mode 100644 index c5916f289705642eec4975cf51458b9afeefe46c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 95 zcmeAS@N?(olHy`uVBq!ia0vp^j3CU&3?x-=hn)ga%mF?juK#@*VoWXSL2@NQe!*uh mnS}iXa=1KQ978JRBqsscYz)k1<~1vTECx?kKbLh*2~7ZT-W2Wt diff --git a/test/no-use-hash/__snapshots__/index.test.js.snap b/test/skip-hash/__snapshots__/index.test.js.snap similarity index 80% rename from test/no-use-hash/__snapshots__/index.test.js.snap rename to test/skip-hash/__snapshots__/index.test.js.snap index 3b84539..b017470 100644 --- a/test/no-use-hash/__snapshots__/index.test.js.snap +++ b/test/skip-hash/__snapshots__/index.test.js.snap @@ -1,12 +1,12 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`No use hash 1`] = ` +exports[`Skip hash 1`] = ` "content.md image.png index.js" `; -exports[`No use hash 2`] = ` +exports[`Skip hash 2`] = ` "import content from './content.md'; import image from './image.png'; diff --git a/test/multi-input/src/sub/folder/content.md b/test/skip-hash/content.md similarity index 100% rename from test/multi-input/src/sub/folder/content.md rename to test/skip-hash/content.md diff --git a/test/multi-input/src/image.png b/test/skip-hash/image.png similarity index 100% rename from test/multi-input/src/image.png rename to test/skip-hash/image.png diff --git a/test/no-use-hash/index.js b/test/skip-hash/index.js similarity index 100% rename from test/no-use-hash/index.js rename to test/skip-hash/index.js diff --git a/test/no-use-hash/index.test.js b/test/skip-hash/index.test.js similarity index 84% rename from test/no-use-hash/index.test.js rename to test/skip-hash/index.test.js index 91b8703..2d58c24 100644 --- a/test/no-use-hash/index.test.js +++ b/test/skip-hash/index.test.js @@ -2,9 +2,9 @@ import { bundle, clean, list, read } from "../util" const root = __dirname -test("No use hash", async () => { +test("Skip hash", async () => { await bundle(root, "index.js", "output/index.js", { - useHash: false, + skipHash: true, }) expect(await list(root, "output")).toMatchSnapshot() diff --git a/test/util.js b/test/util.js index 9665ca3..00c3b52 100644 --- a/test/util.js +++ b/test/util.js @@ -3,7 +3,6 @@ import { readdir } from "fs" import fs from "fs-extra" import { rollup } from "rollup" -import multiInput from "rollup-plugin-multi-input"; import rebasePlugin from "../src" @@ -22,23 +21,6 @@ export async function bundle(root, input, output, pluginOptions = {}) { }) } -export async function bundleWithMultiInput(root, input, output, pluginOptions = {}, multiInputOptions = {}) { - const plugins = [ - multiInput(multiInputOptions), - rebasePlugin(pluginOptions) - ]; - - const result = await rollup({ - input: input.map(i => join(root, i)), - plugins, - }) - - await result.write({ - format: "es", - dir: join(root, output), - }) -} - export async function clean(root, files) { const input = Array.isArray(files) ? files : [ files ] const tasks = input.map((file) => fs.remove(join(root, file)))