@wyw-in-js/vite 1.1.0 → 2.0.0-alpha.0

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.
package/types/index.js CHANGED
@@ -1,53 +1,14 @@
1
- "use strict";
2
1
  /**
3
2
  * This file contains a Vite loader for wyw-in-js.
4
3
  * It uses the transform.ts function to generate class names from source code,
5
4
  * returns transformed code without template literals and attaches generated source maps
6
5
  */
7
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8
- if (k2 === undefined) k2 = k;
9
- var desc = Object.getOwnPropertyDescriptor(m, k);
10
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
11
- desc = { enumerable: true, get: function() { return m[k]; } };
12
- }
13
- Object.defineProperty(o, k2, desc);
14
- }) : (function(o, m, k, k2) {
15
- if (k2 === undefined) k2 = k;
16
- o[k2] = m[k];
17
- }));
18
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
19
- Object.defineProperty(o, "default", { enumerable: true, value: v });
20
- }) : function(o, v) {
21
- o["default"] = v;
22
- });
23
- var __importStar = (this && this.__importStar) || (function () {
24
- var ownKeys = function(o) {
25
- ownKeys = Object.getOwnPropertyNames || function (o) {
26
- var ar = [];
27
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
28
- return ar;
29
- };
30
- return ownKeys(o);
31
- };
32
- return function (mod) {
33
- if (mod && mod.__esModule) return mod;
34
- var result = {};
35
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
36
- __setModuleDefault(result, mod);
37
- return result;
38
- };
39
- })();
40
- var __importDefault = (this && this.__importDefault) || function (mod) {
41
- return (mod && mod.__esModule) ? mod : { "default": mod };
42
- };
43
- Object.defineProperty(exports, "__esModule", { value: true });
44
- exports.default = wywInJS;
45
- const fs_1 = require("fs");
46
- const path_1 = __importDefault(require("path"));
47
- const vite_1 = require("vite");
48
- const shared_1 = require("@wyw-in-js/shared");
49
- const transformPkg = __importStar(require("@wyw-in-js/transform"));
50
- const { createTransformManifest, createFileReporter, getFileIdx, stringifyTransformManifest, transform, TransformCacheCollection, } = transformPkg;
6
+ import { existsSync } from 'fs';
7
+ import path from 'path';
8
+ import { createFilter, loadEnv } from 'vite';
9
+ import { asyncResolverFactory, logger, syncResolve } from '@wyw-in-js/shared';
10
+ import * as transformPkg from '@wyw-in-js/transform';
11
+ const { createTransformManifest, createFileReporter, disposeEvalBroker, getFileIdx, stringifyTransformManifest, transform, TransformCacheCollection, } = transformPkg;
51
12
  const createMetadataManifest = (metadata, context) => typeof createTransformManifest === 'function'
52
13
  ? createTransformManifest(metadata, context)
53
14
  : {
@@ -59,30 +20,30 @@ const stringifyMetadataManifest = (manifest) => typeof stringifyTransformManifes
59
20
  ? stringifyTransformManifest(manifest)
60
21
  : `${JSON.stringify(manifest, null, 2)}\n`;
61
22
  const isWindowsAbsolutePath = (value) => /^[a-zA-Z]:[\\/]/.test(value);
62
- const normalizeToPosix = (value) => value.replace(/\\/g, path_1.default.posix.sep);
23
+ const normalizeToPosix = (value) => value.replace(/\\/g, path.posix.sep);
63
24
  const isInside = (childPath, parentPath) => {
64
- const rel = path_1.default.relative(parentPath, childPath);
65
- return rel === '' || (!rel.startsWith('..') && !path_1.default.isAbsolute(rel));
25
+ const rel = path.relative(parentPath, childPath);
26
+ return rel === '' || (!rel.startsWith('..') && !path.isAbsolute(rel));
66
27
  };
67
28
  const isWywCssAssetName = (value) => value.endsWith('.wyw-in-js.css');
68
29
  const normalizeAssetRelativePath = (value) => {
69
- const normalized = path_1.default.posix.normalize(normalizeToPosix(value).replace(/^\/+/, ''));
70
- if (normalized.startsWith('..') || path_1.default.posix.isAbsolute(normalized)) {
30
+ const normalized = path.posix.normalize(normalizeToPosix(value).replace(/^\/+/, ''));
31
+ if (normalized.startsWith('..') || path.posix.isAbsolute(normalized)) {
71
32
  return null;
72
33
  }
73
34
  return normalized;
74
35
  };
75
36
  const stripExtension = (value) => {
76
- const ext = path_1.default.posix.extname(value);
37
+ const ext = path.posix.extname(value);
77
38
  return ext ? value.slice(0, -ext.length) : value;
78
39
  };
79
40
  const getComparableAssetPaths = (value, rootDir) => {
80
41
  const variants = new Set();
81
42
  const normalized = normalizeToPosix(value);
82
43
  variants.add(normalized);
83
- if (path_1.default.isAbsolute(value) || isWindowsAbsolutePath(normalized)) {
44
+ if (path.isAbsolute(value) || isWindowsAbsolutePath(normalized)) {
84
45
  if (isInside(value, rootDir)) {
85
- const relativeToRoot = normalizeAssetRelativePath(path_1.default.relative(rootDir, value));
46
+ const relativeToRoot = normalizeAssetRelativePath(path.relative(rootDir, value));
86
47
  if (relativeToRoot) {
87
48
  variants.add(relativeToRoot);
88
49
  }
@@ -144,8 +105,8 @@ const findWywCssAssetFileName = (bundle, cssFilename, rootDir) => {
144
105
  return null;
145
106
  };
146
107
  const getRelativeImportPath = (fromFileName, toFileName) => {
147
- const fromDir = path_1.default.posix.dirname(normalizeToPosix(fromFileName));
148
- const relativePath = path_1.default.posix.relative(fromDir, normalizeToPosix(toFileName));
108
+ const fromDir = path.posix.dirname(normalizeToPosix(fromFileName));
109
+ const relativePath = path.posix.relative(fromDir, normalizeToPosix(toFileName));
149
110
  return relativePath.startsWith('.') ? relativePath : `./${relativePath}`;
150
111
  };
151
112
  const escapeForRegExp = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
@@ -188,7 +149,7 @@ const safeDecodeURIComponent = (value) => {
188
149
  };
189
150
  const normalizeViteFsPath = (value) => {
190
151
  const fsPath = value.slice(VITE_FS_PREFIX.length);
191
- return path_1.default.normalize(safeDecodeURIComponent(fsPath));
152
+ return path.normalize(safeDecodeURIComponent(fsPath));
192
153
  };
193
154
  const isCssReloadTarget = (value) => {
194
155
  if (!value || typeof value !== 'object')
@@ -217,12 +178,12 @@ const getWywCssAssetFileNames = (resolvedConfig, output, originalAssetFileNames)
217
178
  const preserveModulesRootValue = output.preserveModulesRoot;
218
179
  let preserveModulesRootAbs = null;
219
180
  if (typeof preserveModulesRootValue === 'string') {
220
- preserveModulesRootAbs = path_1.default.isAbsolute(preserveModulesRootValue)
181
+ preserveModulesRootAbs = path.isAbsolute(preserveModulesRootValue)
221
182
  ? preserveModulesRootValue
222
- : path_1.default.resolve(rootDir, preserveModulesRootValue);
183
+ : path.resolve(rootDir, preserveModulesRootValue);
223
184
  }
224
185
  const preserveModulesRootRel = preserveModulesRootAbs && isInside(preserveModulesRootAbs, rootDir)
225
- ? normalizeToPosix(path_1.default.relative(rootDir, preserveModulesRootAbs))
186
+ ? normalizeToPosix(path.relative(rootDir, preserveModulesRootAbs))
226
187
  : null;
227
188
  return (assetInfo) => {
228
189
  const template = typeof originalAssetFileNames === 'function'
@@ -237,18 +198,18 @@ const getWywCssAssetFileNames = (resolvedConfig, output, originalAssetFileNames)
237
198
  }
238
199
  let relativePath = null;
239
200
  const assetNameNormalized = normalizeToPosix(assetName);
240
- if (path_1.default.isAbsolute(assetName) ||
201
+ if (path.isAbsolute(assetName) ||
241
202
  isWindowsAbsolutePath(assetNameNormalized)) {
242
203
  const preserveRel = preserveModulesRootAbs && isInside(assetName, preserveModulesRootAbs)
243
- ? path_1.default.relative(preserveModulesRootAbs, assetName)
204
+ ? path.relative(preserveModulesRootAbs, assetName)
244
205
  : null;
245
206
  if (preserveRel &&
246
- !path_1.default.isAbsolute(preserveRel) &&
207
+ !path.isAbsolute(preserveRel) &&
247
208
  !preserveRel.startsWith('..')) {
248
209
  relativePath = preserveRel;
249
210
  }
250
211
  else if (isInside(assetName, rootDir)) {
251
- relativePath = path_1.default.relative(rootDir, assetName);
212
+ relativePath = path.relative(rootDir, assetName);
252
213
  }
253
214
  }
254
215
  else if (preserveModulesRootRel &&
@@ -266,13 +227,13 @@ const getWywCssAssetFileNames = (resolvedConfig, output, originalAssetFileNames)
266
227
  }
267
228
  const withoutExt = stripExtension(normalized);
268
229
  if (template.includes('[name]')) {
269
- const dir = path_1.default.posix.dirname(withoutExt);
230
+ const dir = path.posix.dirname(withoutExt);
270
231
  if (dir === '.' || dir === '') {
271
232
  return template;
272
233
  }
273
234
  return template.replace(/\[name\]/g, `${dir}/[name]`);
274
235
  }
275
- const dir = path_1.default.posix.dirname(withoutExt);
236
+ const dir = path.posix.dirname(withoutExt);
276
237
  if (dir === '.' || dir === '') {
277
238
  return template;
278
239
  }
@@ -287,7 +248,7 @@ const getWywCssAssetFileNames = (resolvedConfig, output, originalAssetFileNames)
287
248
  return `${prefix}${dir}/${template.slice(idx)}`;
288
249
  };
289
250
  };
290
- function wywInJS({ debug, include, exclude, sourceMap, preserveCssPaths, keepComments, prefixer, preprocessor, ssrDevCss, ssrDevCssPath, transformLibraries, ...rest } = {}) {
251
+ export default function wywInJS({ debug, include, exclude, sourceMap, preserveCssPaths, keepComments, prefixer, preprocessor, ssrDevCss, ssrDevCssPath, transformLibraries, ...rest } = {}) {
291
252
  const supportedModuleExtensions = new Set([
292
253
  '.cjs',
293
254
  '.cts',
@@ -298,7 +259,7 @@ function wywInJS({ debug, include, exclude, sourceMap, preserveCssPaths, keepCom
298
259
  '.ts',
299
260
  '.tsx',
300
261
  ]);
301
- const filter = (0, vite_1.createFilter)(include, exclude);
262
+ const filter = createFilter(include, exclude);
302
263
  const cssLookup = {};
303
264
  const cssFileLookup = {};
304
265
  const metadataLookup = {};
@@ -308,6 +269,17 @@ function wywInJS({ debug, include, exclude, sourceMap, preserveCssPaths, keepCom
308
269
  let config;
309
270
  let devServer;
310
271
  let importMetaEnvForEval = null;
272
+ const buildOverrideContext = (getEnv) => (context, filename) => {
273
+ const env = getEnv();
274
+ const withEnv = env
275
+ ? { ...context, __wyw_import_meta_env: env }
276
+ : context;
277
+ return rest.overrideContext
278
+ ? rest.overrideContext(withEnv, filename)
279
+ : withEnv;
280
+ };
281
+ const overrideContextClient = buildOverrideContext(() => importMetaEnvForEval?.client);
282
+ const overrideContextSsr = buildOverrideContext(() => importMetaEnvForEval?.ssr);
311
283
  const ssrDevCssEnabled = Boolean(ssrDevCss);
312
284
  const [ssrDevCssPathname, ssrDevCssQuery] = (ssrDevCssPath ?? '/_wyw-in-js/ssr.css').split('?', 2);
313
285
  const ssrDevCssRoute = ssrDevCssPathname.startsWith('/')
@@ -333,29 +305,29 @@ function wywInJS({ debug, include, exclude, sourceMap, preserveCssPaths, keepCom
333
305
  const { emitter, onDone } = createFileReporter(debug ?? false);
334
306
  const isSafeAssetPath = (fileName) => fileName !== '' &&
335
307
  fileName !== '..' &&
336
- !fileName.startsWith(`..${path_1.default.posix.sep}`) &&
337
- !path_1.default.posix.isAbsolute(fileName) &&
308
+ !fileName.startsWith(`..${path.posix.sep}`) &&
309
+ !path.posix.isAbsolute(fileName) &&
338
310
  !isWindowsAbsolutePath(fileName);
339
311
  const replaceModuleExtension = (filename, nextExtension) => {
340
- const extension = path_1.default.extname(filename);
312
+ const extension = path.extname(filename);
341
313
  return supportedModuleExtensions.has(extension)
342
314
  ? `${filename.slice(0, -extension.length)}${nextExtension}`
343
315
  : `${filename}${nextExtension}`;
344
316
  };
345
317
  const toBundleRelativePath = (filename) => {
346
- const relativePath = normalizeToPosix(path_1.default.relative(config.root, filename));
318
+ const relativePath = normalizeToPosix(path.relative(config.root, filename));
347
319
  if (isSafeAssetPath(relativePath)) {
348
320
  return relativePath;
349
321
  }
350
- if (!path_1.default.isAbsolute(relativePath) &&
322
+ if (!path.isAbsolute(relativePath) &&
351
323
  !isWindowsAbsolutePath(relativePath)) {
352
- return path_1.default.posix.join('_wyw-in-js', 'external', ...relativePath
353
- .split(path_1.default.posix.sep)
324
+ return path.posix.join('_wyw-in-js', 'external', ...relativePath
325
+ .split(path.posix.sep)
354
326
  .filter(Boolean)
355
327
  .map((segment) => (segment === '..' ? '__up__' : segment)));
356
328
  }
357
- return path_1.default.posix.join('_wyw-in-js', 'external', ...normalizeToPosix(path_1.default.resolve(filename))
358
- .split(path_1.default.posix.sep)
329
+ return path.posix.join('_wyw-in-js', 'external', ...normalizeToPosix(path.resolve(filename))
330
+ .split(path.posix.sep)
359
331
  .filter(Boolean)
360
332
  .map((segment) => segment.replace(/:$/, '')));
361
333
  };
@@ -385,15 +357,24 @@ function wywInJS({ debug, include, exclude, sourceMap, preserveCssPaths, keepCom
385
357
  const clientCache = new TransformCacheCollection();
386
358
  const ssrCache = new TransformCacheCollection();
387
359
  const caches = new Set([clientCache, ssrCache]);
360
+ let evalBrokersDisposed = false;
361
+ const disposeEvalBrokers = () => {
362
+ if (evalBrokersDisposed)
363
+ return;
364
+ evalBrokersDisposed = true;
365
+ for (const cache of caches) {
366
+ disposeEvalBroker(cache);
367
+ }
368
+ };
388
369
  const getCache = (isSsr) => isSsr ? ssrCache : clientCache;
389
370
  const isInsideCacheDir = (filename) => {
390
371
  if (!config.cacheDir) {
391
372
  return false;
392
373
  }
393
- const relative = path_1.default.relative(config.cacheDir, filename);
374
+ const relative = path.relative(config.cacheDir, filename);
394
375
  return (relative !== '' &&
395
376
  !relative.startsWith('..') &&
396
- !path_1.default.isAbsolute(relative));
377
+ !path.isAbsolute(relative));
397
378
  };
398
379
  const getDepsOptimizer = () => {
399
380
  if (!devServer)
@@ -430,8 +411,8 @@ function wywInJS({ debug, include, exclude, sourceMap, preserveCssPaths, keepCom
430
411
  }
431
412
  return viteResolver(what, importer, false, true);
432
413
  };
433
- const createAsyncResolver = (0, shared_1.asyncResolverFactory)(async (resolved, what, importer, stack) => {
434
- const log = shared_1.logger.extend('vite').extend(getFileIdx(importer));
414
+ const createAsyncResolver = asyncResolverFactory(async (resolved, what, importer, stack) => {
415
+ const log = logger.extend('vite').extend(getFileIdx(importer));
435
416
  if (resolved) {
436
417
  log("resolve ✅ '%s'@'%s -> %O\n%s", what, importer, resolved);
437
418
  // Vite adds param like `?v=667939b3` to cached modules
@@ -447,7 +428,7 @@ function wywInJS({ debug, include, exclude, sourceMap, preserveCssPaths, keepCom
447
428
  if (resolvedId.startsWith('/@')) {
448
429
  return null;
449
430
  }
450
- if (!(0, fs_1.existsSync)(resolvedId)) {
431
+ if (!existsSync(resolvedId)) {
451
432
  // When Vite resolves to an optimized deps entry (cacheDir) it may not be written yet.
452
433
  // Wait for Vite's optimizer instead of calling optimizeDeps() manually (deprecated in Vite 7).
453
434
  try {
@@ -459,19 +440,19 @@ function wywInJS({ debug, include, exclude, sourceMap, preserveCssPaths, keepCom
459
440
  // Vite can return an optimized deps entry (from cacheDir) before it's written to disk.
460
441
  // Manually calling optimizeDeps is deprecated in Vite 7 and can also get called many times.
461
442
  // Instead, fall back to resolving the original module path directly.
462
- if (!(0, fs_1.existsSync)(resolvedId) && isInsideCacheDir(resolvedId)) {
443
+ if (!existsSync(resolvedId) && isInsideCacheDir(resolvedId)) {
463
444
  try {
464
- return (0, shared_1.syncResolve)(what, importer, stack);
445
+ return syncResolve(what, importer, stack);
465
446
  }
466
447
  catch {
467
448
  // Fall through to preserve previous behavior: return resolvedId and let WyW surface the error.
468
449
  }
469
450
  }
470
451
  }
471
- if (!(0, fs_1.existsSync)(resolvedId) && !path_1.default.isAbsolute(resolvedId)) {
452
+ if (!existsSync(resolvedId) && !path.isAbsolute(resolvedId)) {
472
453
  // Vite can resolve an import to a bare specifier when bundling for SSR and marking it as external.
473
454
  // In that case we still need a real file path for WyW evaluation.
474
- return (0, shared_1.syncResolve)(what, importer, stack);
455
+ return syncResolve(what, importer, stack);
475
456
  }
476
457
  return resolvedId;
477
458
  }
@@ -482,12 +463,15 @@ function wywInJS({ debug, include, exclude, sourceMap, preserveCssPaths, keepCom
482
463
  }
483
464
  if (!what.startsWith('.') &&
484
465
  !what.startsWith('/') &&
485
- !path_1.default.isAbsolute(what)) {
466
+ !path.isAbsolute(what)) {
486
467
  // Keep compatibility with SSR externalization: fall back to Node resolution for bare specifiers.
487
- return (0, shared_1.syncResolve)(what, importer, stack);
468
+ return syncResolve(what, importer, stack);
488
469
  }
489
470
  throw new Error(`Could not resolve ${what}`);
490
- }, (what, importer) => [what, importer]);
471
+ }, (what, importer) => [
472
+ what,
473
+ importer,
474
+ ]);
491
475
  const asyncResolveClient = createAsyncResolver(resolveClient);
492
476
  const asyncResolveSsr = createAsyncResolver(resolveSsr);
493
477
  return {
@@ -500,6 +484,9 @@ function wywInJS({ debug, include, exclude, sourceMap, preserveCssPaths, keepCom
500
484
  },
501
485
  buildEnd() {
502
486
  onDone(process.cwd());
487
+ if (config.command === 'build') {
488
+ disposeEvalBrokers();
489
+ }
503
490
  },
504
491
  configResolved(resolvedConfig) {
505
492
  config = resolvedConfig;
@@ -532,7 +519,7 @@ function wywInJS({ debug, include, exclude, sourceMap, preserveCssPaths, keepCom
532
519
  'envDir' in config && typeof config.envDir === 'string'
533
520
  ? config.envDir
534
521
  : config.root;
535
- const loaded = (0, vite_1.loadEnv)(config.mode, envDir, envPrefix);
522
+ const loaded = loadEnv(config.mode, envDir, envPrefix);
536
523
  const base = {
537
524
  ...loaded,
538
525
  BASE_URL: config.base,
@@ -547,32 +534,33 @@ function wywInJS({ debug, include, exclude, sourceMap, preserveCssPaths, keepCom
547
534
  },
548
535
  configureServer(_server) {
549
536
  devServer = _server;
550
- if (!ssrDevCssEnabled || config.command !== 'serve')
551
- return;
552
- devServer.middlewares.use((req, res, next) => {
553
- const { url } = req;
554
- if (!url) {
555
- next();
556
- return;
557
- }
558
- const [pathname] = url.split('?', 1);
559
- if (pathname !== ssrDevCssRoute) {
560
- next();
561
- return;
562
- }
563
- const etag = `W/"${ssrDevCssVersion}"`;
564
- const ifNoneMatch = req.headers['if-none-match'];
565
- if (ifNoneMatch === etag) {
566
- res.statusCode = 304;
567
- res.end();
568
- return;
569
- }
570
- res.statusCode = 200;
571
- res.setHeader('Content-Type', 'text/css; charset=utf-8');
572
- res.setHeader('Cache-Control', 'no-cache');
573
- res.setHeader('ETag', etag);
574
- res.end(getSsrDevCssContents());
575
- });
537
+ devServer.httpServer?.once('close', disposeEvalBrokers);
538
+ if (ssrDevCssEnabled && config.command === 'serve') {
539
+ devServer.middlewares.use((req, res, next) => {
540
+ const { url } = req;
541
+ if (!url) {
542
+ next();
543
+ return;
544
+ }
545
+ const [pathname] = url.split('?', 1);
546
+ if (pathname !== ssrDevCssRoute) {
547
+ next();
548
+ return;
549
+ }
550
+ const etag = `W/"${ssrDevCssVersion}"`;
551
+ const ifNoneMatch = req.headers['if-none-match'];
552
+ if (ifNoneMatch === etag) {
553
+ res.statusCode = 304;
554
+ res.end();
555
+ return;
556
+ }
557
+ res.statusCode = 200;
558
+ res.setHeader('Content-Type', 'text/css; charset=utf-8');
559
+ res.setHeader('Cache-Control', 'no-cache');
560
+ res.setHeader('ETag', etag);
561
+ res.end(getSsrDevCssContents());
562
+ });
563
+ }
576
564
  },
577
565
  transformIndexHtml(html) {
578
566
  if (!ssrDevCssEnabled || config.command !== 'serve')
@@ -666,20 +654,14 @@ function wywInJS({ debug, include, exclude, sourceMap, preserveCssPaths, keepCom
666
654
  !filter(url) ||
667
655
  id in cssLookup)
668
656
  return;
669
- const log = shared_1.logger.extend('vite').extend(getFileIdx(id));
657
+ const log = logger.extend('vite').extend(getFileIdx(id));
670
658
  log('transform %s', id);
671
659
  const isSsr = typeof transformOptions === 'boolean'
672
660
  ? transformOptions
673
661
  : Boolean(transformOptions?.ssr);
674
- const overrideContext = (context, filename) => {
675
- const env = importMetaEnvForEval?.[isSsr ? 'ssr' : 'client'];
676
- const withEnv = env
677
- ? { ...context, __wyw_import_meta_env: env }
678
- : context;
679
- return rest.overrideContext
680
- ? rest.overrideContext(withEnv, filename)
681
- : withEnv;
682
- };
662
+ const overrideContext = isSsr
663
+ ? overrideContextSsr
664
+ : overrideContextClient;
683
665
  const transformServices = {
684
666
  options: {
685
667
  filename: id,
@@ -712,7 +694,7 @@ function wywInJS({ debug, include, exclude, sourceMap, preserveCssPaths, keepCom
712
694
  pluginCode: diagnostic.category,
713
695
  });
714
696
  });
715
- const relativeId = normalizeToPosix(path_1.default.relative(config.root, id));
697
+ const relativeId = normalizeToPosix(path.relative(config.root, id));
716
698
  const metadataFilename = replaceModuleExtension(id, '.wyw-in-js.json');
717
699
  const metadataRelativePath = toBundleRelativePath(metadataFilename);
718
700
  delete metadataLookup[metadataRelativePath];
@@ -745,7 +727,7 @@ function wywInJS({ debug, include, exclude, sourceMap, preserveCssPaths, keepCom
745
727
  dependencies ??= [];
746
728
  const cssFilename = normalizeToPosix(replaceModuleExtension(id, '.wyw-in-js.css'));
747
729
  cssFilesByModuleId.set(id, cssFilename);
748
- const cssRelativePath = normalizeToPosix(path_1.default.relative(config.root, cssFilename));
730
+ const cssRelativePath = normalizeToPosix(path.relative(config.root, cssFilename));
749
731
  const cssId = `/${cssRelativePath}`;
750
732
  if (sourceMap && result.cssSourceMapText) {
751
733
  const map = Buffer.from(result.cssSourceMapText).toString('base64');