From 5093c2d4836fe0deddda00032c8e0c28e8d1e159 Mon Sep 17 00:00:00 2001 From: Luiz Ferraz Date: Wed, 7 Feb 2024 16:50:12 -0300 Subject: [PATCH] Allow updating module resolution in DEV environment --- .changeset/pre.json | 1 + .changeset/smart-fans-ring.md | 5 +++++ packages/inline-mod/CHANGELOG.md | 6 ++++++ packages/inline-mod/package.json | 2 +- packages/inline-mod/src/vite.ts | 3 ++- 5 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 .changeset/smart-fans-ring.md diff --git a/.changeset/pre.json b/.changeset/pre.json index 54ff42eb..ad612335 100644 --- a/.changeset/pre.json +++ b/.changeset/pre.json @@ -16,6 +16,7 @@ "eleven-shrimps-rest", "fresh-beers-dream", "itchy-pants-happen", + "smart-fans-ring", "tame-rivers-tie", "thick-plums-prove" ] diff --git a/.changeset/smart-fans-ring.md b/.changeset/smart-fans-ring.md new file mode 100644 index 00000000..c6224ed7 --- /dev/null +++ b/.changeset/smart-fans-ring.md @@ -0,0 +1,5 @@ +--- +"@inox-tools/inline-mod": patch +--- + +Allow updating module resulution in DEV environment diff --git a/packages/inline-mod/CHANGELOG.md b/packages/inline-mod/CHANGELOG.md index ba298e0e..da77db76 100644 --- a/packages/inline-mod/CHANGELOG.md +++ b/packages/inline-mod/CHANGELOG.md @@ -1,5 +1,11 @@ # @inox-tools/inline-mod +## 1.1.0-smart-factory.4 + +### Patch Changes + +- bd29c64: Allow updating module resulution in DEV environment + ## 1.1.0-smart-factory.3 ### Minor Changes diff --git a/packages/inline-mod/package.json b/packages/inline-mod/package.json index a5c087f6..9e457e9d 100644 --- a/packages/inline-mod/package.json +++ b/packages/inline-mod/package.json @@ -1,6 +1,6 @@ { "name": "@inox-tools/inline-mod", - "version": "1.1.0-smart-factory.3", + "version": "1.1.0-smart-factory.4", "description": "Define a virtual module inline with any reference to buildtime values", "keywords": [ "vite-plugin" diff --git a/packages/inline-mod/src/vite.ts b/packages/inline-mod/src/vite.ts index d1192f79..b052dfcb 100644 --- a/packages/inline-mod/src/vite.ts +++ b/packages/inline-mod/src/vite.ts @@ -1,3 +1,4 @@ +import 'vite/types/importMeta.js'; import { magicFactory } from './closure/inspectCode.js'; import { InlineModuleError } from './closure/types.js'; import { inspectInlineMod, type InlineModule, type ModuleOptions } from './inlining.js'; @@ -31,7 +32,7 @@ export function inlineModule(options: ModuleOptions): string { } export function defineModule(name: string, options: ModuleOptions): string { - if (modRegistry.has(name)) { + if (import.meta.env.PROD && modRegistry.has(name)) { throw new InlineModulePluginError(`Module "${name}" already defined.`); } modRegistry.set(name, inspectInlineMod(options));