From b60fe9ef4eec9cc4c449b4c202c8b4fc1ab94da1 Mon Sep 17 00:00:00 2001 From: Danny Gleckler Date: Fri, 18 Oct 2024 17:59:56 -0400 Subject: [PATCH] Fix variable name --- packages/dynamic-import-vars/src/index.js | 2 +- ...llup-plugin-dynamic-import-vars.test.js.md | 22 +++++++++--------- ...up-plugin-dynamic-import-vars.test.js.snap | Bin 1195 -> 1204 bytes 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/dynamic-import-vars/src/index.js b/packages/dynamic-import-vars/src/index.js index d13549897..c7152cfd8 100644 --- a/packages/dynamic-import-vars/src/index.js +++ b/packages/dynamic-import-vars/src/index.js @@ -78,7 +78,7 @@ function dynamicImportVariables({ include, exclude, warnOnError, errorWhenNoFile // will turn these into chunks automatically ms.prepend( `function __variableDynamicImportRuntime${dynamicImportIndex}__(path) { - path = (${normalizePathString})(path); + const normalPath = (${normalizePathString})(path); switch (normalPath) { ${paths .map((p) => ` case '${p}': return import('${p}'${importArg ? `, ${importArg}` : ''});`) diff --git a/packages/dynamic-import-vars/test/snapshots/rollup-plugin-dynamic-import-vars.test.js.md b/packages/dynamic-import-vars/test/snapshots/rollup-plugin-dynamic-import-vars.test.js.md index 496447938..df1ff0319 100644 --- a/packages/dynamic-import-vars/test/snapshots/rollup-plugin-dynamic-import-vars.test.js.md +++ b/packages/dynamic-import-vars/test/snapshots/rollup-plugin-dynamic-import-vars.test.js.md @@ -9,7 +9,7 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `function __variableDynamicImportRuntime0__(path) {␊ - path = (function normalizePath(p) {␊ + const normalPath = (function normalizePath(p) {␊ return (␊ p␊ // remove any ./ inside the path␊ @@ -43,7 +43,7 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `function __variableDynamicImportRuntime0__(path) {␊ - path = (function normalizePath(p) {␊ + const normalPath = (function normalizePath(p) {␊ return (␊ p␊ // remove any ./ inside the path␊ @@ -59,7 +59,7 @@ Generated by [AVA](https://avajs.dev). case './module-dir-a/module-a-2.js': return import('./module-a-2-qepdcyXv.js');␊ case './module-dir-b/module-b-1.js': return import('./module-b-1-3qdzaV4G.js');␊ case './module-dir-b/module-b-2.js': return import('./module-b-2-_8gpxG1i.js');␊ - case './sub-dir/fixture-upwards-path.js': return import('./fixture-upwards-path-3kYiIOy5.js');␊ + case './sub-dir/fixture-upwards-path.js': return import('./fixture-upwards-path-ULPK6OKR.js');␊ default: return new Promise(function(resolve, reject) {␊ (typeof queueMicrotask === 'function' ? queueMicrotask : setTimeout)(␊ reject.bind(null, new Error("Unknown variable dynamic import: " + normalPath))␊ @@ -80,7 +80,7 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `function __variableDynamicImportRuntime0__(path) {␊ - path = (function normalizePath(p) {␊ + const normalPath = (function normalizePath(p) {␊ return (␊ p␊ // remove any ./ inside the path␊ @@ -114,7 +114,7 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `function __variableDynamicImportRuntime0__(path) {␊ - path = (function normalizePath(p) {␊ + const normalPath = (function normalizePath(p) {␊ return (␊ p␊ // remove any ./ inside the path␊ @@ -150,7 +150,7 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `function __variableDynamicImportRuntime0__(path) {␊ - path = (function normalizePath(p) {␊ + const normalPath = (function normalizePath(p) {␊ return (␊ p␊ // remove any ./ inside the path␊ @@ -184,7 +184,7 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `function __variableDynamicImportRuntime2__(path) {␊ - path = (function normalizePath(p) {␊ + const normalPath = (function normalizePath(p) {␊ return (␊ p␊ // remove any ./ inside the path␊ @@ -200,7 +200,7 @@ Generated by [AVA](https://avajs.dev). case './module-dir-a/module-a-2.js': return import('./module-a-2-qepdcyXv.js');␊ case './module-dir-b/module-b-1.js': return import('./module-b-1-3qdzaV4G.js');␊ case './module-dir-b/module-b-2.js': return import('./module-b-2-_8gpxG1i.js');␊ - case './sub-dir/fixture-upwards-path.js': return import('./fixture-upwards-path-3kYiIOy5.js');␊ + case './sub-dir/fixture-upwards-path.js': return import('./fixture-upwards-path-ULPK6OKR.js');␊ default: return new Promise(function(resolve, reject) {␊ (typeof queueMicrotask === 'function' ? queueMicrotask : setTimeout)(␊ reject.bind(null, new Error("Unknown variable dynamic import: " + normalPath))␊ @@ -210,7 +210,7 @@ Generated by [AVA](https://avajs.dev). }␊ ␊ function __variableDynamicImportRuntime1__(path) {␊ - path = (function normalizePath(p) {␊ + const normalPath = (function normalizePath(p) {␊ return (␊ p␊ // remove any ./ inside the path␊ @@ -233,7 +233,7 @@ Generated by [AVA](https://avajs.dev). }␊ ␊ function __variableDynamicImportRuntime0__(path) {␊ - path = (function normalizePath(p) {␊ + const normalPath = (function normalizePath(p) {␊ return (␊ p␊ // remove any ./ inside the path␊ @@ -305,7 +305,7 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `function __variableDynamicImportRuntime0__(path) {␊ - path = (function normalizePath(p) {␊ + const normalPath = (function normalizePath(p) {␊ return (␊ p␊ // remove any ./ inside the path␊ diff --git a/packages/dynamic-import-vars/test/snapshots/rollup-plugin-dynamic-import-vars.test.js.snap b/packages/dynamic-import-vars/test/snapshots/rollup-plugin-dynamic-import-vars.test.js.snap index cd8622916dc35f28875b2f2193f8ca6680f2c075..1ab24197b226ce656081aeb72d63d176b0a47b5f 100644 GIT binary patch literal 1204 zcmV;l1WWrtRzV#JiiDMnqKCgaZx0<4h`GT!bW8 zC8`TeFh)Z8*Yq`}SBxkh0U%Jtf`O4W0HVP=fa8F`knbT7)(6`G$|Us>R2Lzga@5fl z7zM;b!&!IM?RCfL)IfK1vqZ_K!huDwZ3iMkg)Gr9UT!${tCt(jt2^tCX`I|#x6=tt z^Ug}i$7~&?%ZM3652Ylc4*?RNvJTiz$znE)Oli?rX_knZ%Njsp<_<_d%YCZ6E*OU% z81Ax1B!X@`A@}0|EuRXD3>(C%+uKrK8oGjJ4mJ*Z6RU2uY0SR4|9LCznawp#voTGx zVeMk%d;PV&F-;%aBo5SQ9K(HB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