vike 0.4.168-commit-7678a7d → 0.4.168-commit-42406a9

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.
Files changed (168) hide show
  1. package/dist/cjs/node/plugin/plugins/buildConfig.js +2 -2
  2. package/dist/cjs/node/plugin/plugins/commonConfig/assertResolveAlias.js +1 -1
  3. package/dist/cjs/node/plugin/plugins/devConfig/determineOptimizeDeps.js +19 -16
  4. package/dist/cjs/node/plugin/plugins/distFileNames.js +1 -1
  5. package/dist/cjs/node/plugin/plugins/envVars.js +1 -5
  6. package/dist/cjs/node/plugin/plugins/importUserCode/index.js +1 -4
  7. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getConfigValuesSerialized.js +14 -11
  8. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +11 -14
  9. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/{resolveImportPath.js → resolvePointerImport.js} +58 -44
  10. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transformFileImports.js +8 -8
  11. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +52 -12
  12. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +81 -106
  13. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +2 -2
  14. package/dist/cjs/node/plugin/shared/getFilePath.js +44 -48
  15. package/dist/cjs/node/plugin/utils.js +2 -2
  16. package/dist/cjs/node/prerender/runPrerender.js +6 -5
  17. package/dist/cjs/node/prerender/utils.js +2 -1
  18. package/dist/cjs/node/runtime/html/serializePageContextClientSide.js +1 -0
  19. package/dist/cjs/node/runtime/index-common.js +14 -3
  20. package/dist/cjs/node/runtime/renderPage/createHttpResponseObject/getCacheControl.js +2 -1
  21. package/dist/cjs/node/runtime/renderPage/loadUserFilesServerSide.js +25 -14
  22. package/dist/cjs/node/runtime/renderPage/log404/index.js +2 -2
  23. package/dist/cjs/node/runtime/renderPage/logErrorHint.js +1 -1
  24. package/dist/cjs/node/runtime/utils.js +2 -1
  25. package/dist/cjs/node/shared/assertV1Design.js +1 -1
  26. package/dist/cjs/node/shared/getClientEntry.js +2 -2
  27. package/dist/cjs/node/shared/utils.js +0 -1
  28. package/dist/cjs/shared/getPageFiles/analyzeClientSide.js +3 -3
  29. package/dist/cjs/shared/getPageFiles/getExports.js +8 -15
  30. package/dist/cjs/shared/getPageFiles.js +3 -6
  31. package/dist/cjs/shared/hooks/getHook.js +7 -6
  32. package/dist/cjs/shared/page-configs/getConfigDefinedAt.js +48 -0
  33. package/dist/cjs/shared/page-configs/{helpers/getConfigValue.js → getConfigValue.js} +6 -8
  34. package/dist/cjs/shared/page-configs/helpers.js +6 -11
  35. package/dist/cjs/shared/page-configs/serialize/assertPageConfigsSerialized.js +1 -1
  36. package/dist/cjs/shared/page-configs/serialize/parseConfigValuesImported.js +2 -1
  37. package/dist/cjs/shared/page-configs/serialize/parseConfigValuesSerialized.js +11 -6
  38. package/dist/cjs/shared/page-configs/serialize/parsePageConfigs.js +4 -3
  39. package/dist/cjs/shared/page-configs/serialize/serializeConfigValue.js +3 -3
  40. package/dist/cjs/shared/route/index.js +2 -2
  41. package/dist/cjs/shared/route/loadPageRoutes.js +12 -10
  42. package/dist/cjs/shared/route/resolveRouteFunction.js +8 -9
  43. package/dist/cjs/shared/route/resolveRouteString.js +5 -16
  44. package/dist/cjs/shared/route/utils.js +0 -1
  45. package/dist/cjs/shared/utils.js +1 -0
  46. package/dist/cjs/utils/assertPathFilesystemAbsolute.js +39 -0
  47. package/dist/cjs/utils/createErrorWithCleanStackTrace.js +1 -7
  48. package/dist/cjs/utils/debug.js +2 -1
  49. package/dist/cjs/utils/findFile.js +2 -1
  50. package/dist/cjs/utils/hasProp.js +9 -5
  51. package/dist/cjs/utils/injectRollupInputs.js +2 -1
  52. package/dist/cjs/utils/isArray.js +8 -0
  53. package/dist/cjs/utils/isArrayOfStrings.js +8 -0
  54. package/dist/cjs/utils/isNpmPackage.js +1 -1
  55. package/dist/cjs/utils/isObjectOfStrings.js +8 -0
  56. package/dist/cjs/utils/projectInfo.js +1 -1
  57. package/dist/esm/client/client-routing-runtime/getPageContextFromHooks.d.ts +3 -1
  58. package/dist/esm/client/client-routing-runtime/getPageContextFromHooks.js +2 -1
  59. package/dist/esm/client/server-routing-runtime/getPageContext.d.ts +1 -0
  60. package/dist/esm/client/shared/getPageContextSerializedInHtml.d.ts +1 -0
  61. package/dist/esm/client/shared/getPageContextSerializedInHtml.js +1 -0
  62. package/dist/esm/client/shared/loadUserFilesClientSide.js +3 -7
  63. package/dist/esm/node/plugin/plugins/buildConfig.js +1 -1
  64. package/dist/esm/node/plugin/plugins/commonConfig/assertResolveAlias.js +2 -2
  65. package/dist/esm/node/plugin/plugins/devConfig/determineOptimizeDeps.js +20 -17
  66. package/dist/esm/node/plugin/plugins/distFileNames.js +2 -2
  67. package/dist/esm/node/plugin/plugins/envVars.js +2 -6
  68. package/dist/esm/node/plugin/plugins/importUserCode/index.js +2 -5
  69. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getConfigValuesSerialized.d.ts +2 -2
  70. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getConfigValuesSerialized.js +14 -11
  71. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.d.ts +4 -3
  72. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.d.ts +2 -2
  73. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +12 -15
  74. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolvePointerImport.d.ts +12 -0
  75. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolvePointerImport.js +123 -0
  76. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transformFileImports.d.ts +8 -8
  77. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transformFileImports.js +7 -7
  78. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +53 -13
  79. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +81 -106
  80. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +1 -1
  81. package/dist/esm/node/plugin/shared/getFilePath.d.ts +11 -5
  82. package/dist/esm/node/plugin/shared/getFilePath.js +43 -47
  83. package/dist/esm/node/plugin/utils.d.ts +2 -2
  84. package/dist/esm/node/plugin/utils.js +2 -2
  85. package/dist/esm/node/prerender/runPrerender.js +6 -5
  86. package/dist/esm/node/prerender/utils.d.ts +2 -1
  87. package/dist/esm/node/prerender/utils.js +2 -1
  88. package/dist/esm/node/runtime/html/serializePageContextClientSide.d.ts +1 -0
  89. package/dist/esm/node/runtime/html/serializePageContextClientSide.js +1 -0
  90. package/dist/esm/node/runtime/index-common.d.ts +0 -4
  91. package/dist/esm/node/runtime/index-common.js +14 -3
  92. package/dist/esm/node/runtime/renderPage/createHttpResponseObject/getCacheControl.js +2 -1
  93. package/dist/esm/node/runtime/renderPage/loadUserFilesServerSide.d.ts +4 -4
  94. package/dist/esm/node/runtime/renderPage/loadUserFilesServerSide.js +27 -16
  95. package/dist/esm/node/runtime/renderPage/log404/index.js +2 -2
  96. package/dist/esm/node/runtime/renderPage/logErrorHint.js +2 -2
  97. package/dist/esm/node/runtime/renderPage/preparePageContextForUserConsumptionServerSide.d.ts +2 -7
  98. package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.d.ts +16 -16
  99. package/dist/esm/node/runtime/utils.d.ts +2 -1
  100. package/dist/esm/node/runtime/utils.js +2 -1
  101. package/dist/esm/node/shared/assertV1Design.js +1 -1
  102. package/dist/esm/node/shared/getClientEntry.js +1 -1
  103. package/dist/esm/node/shared/utils.d.ts +0 -1
  104. package/dist/esm/node/shared/utils.js +0 -1
  105. package/dist/esm/shared/getPageFiles/analyzeClientSide.js +1 -1
  106. package/dist/esm/shared/getPageFiles/getExports.d.ts +4 -5
  107. package/dist/esm/shared/getPageFiles/getExports.js +9 -16
  108. package/dist/esm/shared/getPageFiles.d.ts +1 -2
  109. package/dist/esm/shared/getPageFiles.js +1 -3
  110. package/dist/esm/shared/hooks/getHook.js +6 -5
  111. package/dist/esm/shared/page-configs/Config.d.ts +2 -2
  112. package/dist/esm/shared/page-configs/FilePath.d.ts +32 -22
  113. package/dist/esm/shared/page-configs/PageConfig.d.ts +27 -15
  114. package/dist/esm/shared/page-configs/getConfigDefinedAt.d.ts +11 -0
  115. package/dist/esm/shared/page-configs/getConfigDefinedAt.js +42 -0
  116. package/dist/esm/shared/page-configs/{helpers/getConfigValue.d.ts → getConfigValue.d.ts} +2 -2
  117. package/dist/esm/shared/page-configs/{helpers/getConfigValue.js → getConfigValue.js} +6 -8
  118. package/dist/esm/shared/page-configs/helpers.d.ts +3 -9
  119. package/dist/esm/shared/page-configs/helpers.js +6 -8
  120. package/dist/esm/shared/page-configs/serialize/PageConfigSerialized.d.ts +7 -4
  121. package/dist/esm/shared/page-configs/serialize/assertPageConfigsSerialized.js +2 -2
  122. package/dist/esm/shared/page-configs/serialize/parseConfigValuesImported.js +2 -1
  123. package/dist/esm/shared/page-configs/serialize/parseConfigValuesSerialized.js +12 -7
  124. package/dist/esm/shared/page-configs/serialize/parsePageConfigs.js +5 -4
  125. package/dist/esm/shared/page-configs/serialize/serializeConfigValue.js +3 -3
  126. package/dist/esm/shared/route/index.js +2 -2
  127. package/dist/esm/shared/route/loadPageRoutes.d.ts +3 -3
  128. package/dist/esm/shared/route/loadPageRoutes.js +10 -8
  129. package/dist/esm/shared/route/resolveRouteFunction.d.ts +1 -1
  130. package/dist/esm/shared/route/resolveRouteFunction.js +9 -10
  131. package/dist/esm/shared/route/resolveRouteString.d.ts +0 -2
  132. package/dist/esm/shared/route/resolveRouteString.js +5 -16
  133. package/dist/esm/shared/route/utils.d.ts +0 -1
  134. package/dist/esm/shared/route/utils.js +0 -1
  135. package/dist/esm/shared/utils.d.ts +1 -0
  136. package/dist/esm/shared/utils.js +1 -0
  137. package/dist/esm/utils/assertPathFilesystemAbsolute.d.ts +6 -0
  138. package/dist/esm/utils/assertPathFilesystemAbsolute.js +33 -0
  139. package/dist/esm/utils/createErrorWithCleanStackTrace.js +1 -7
  140. package/dist/esm/utils/debug.js +2 -1
  141. package/dist/esm/utils/findFile.js +2 -1
  142. package/dist/esm/utils/hasProp.d.ts +1 -0
  143. package/dist/esm/utils/hasProp.js +9 -5
  144. package/dist/esm/utils/injectRollupInputs.js +2 -1
  145. package/dist/esm/utils/isArray.d.ts +1 -0
  146. package/dist/esm/utils/isArray.js +4 -0
  147. package/dist/esm/utils/isArrayOfStrings.d.ts +2 -0
  148. package/dist/esm/utils/isArrayOfStrings.js +5 -0
  149. package/dist/esm/utils/isNpmPackage.js +1 -1
  150. package/dist/esm/utils/isObjectOfStrings.d.ts +2 -0
  151. package/dist/esm/utils/isObjectOfStrings.js +5 -0
  152. package/dist/esm/utils/projectInfo.d.ts +2 -2
  153. package/dist/esm/utils/projectInfo.js +1 -1
  154. package/package.json +1 -1
  155. package/dist/cjs/shared/page-configs/helpers/getConfigDefinedAtString.js +0 -43
  156. package/dist/cjs/utils/assertPathIsFilesystemAbsolute.js +0 -21
  157. package/dist/cjs/utils/isStringRecord.js +0 -7
  158. package/dist/cjs/utils/mergeCumulativeValues.js +0 -21
  159. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveImportPath.d.ts +0 -13
  160. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveImportPath.js +0 -109
  161. package/dist/esm/shared/page-configs/helpers/getConfigDefinedAtString.d.ts +0 -7
  162. package/dist/esm/shared/page-configs/helpers/getConfigDefinedAtString.js +0 -37
  163. package/dist/esm/utils/assertPathIsFilesystemAbsolute.d.ts +0 -3
  164. package/dist/esm/utils/assertPathIsFilesystemAbsolute.js +0 -15
  165. package/dist/esm/utils/isStringRecord.d.ts +0 -1
  166. package/dist/esm/utils/isStringRecord.js +0 -3
  167. package/dist/esm/utils/mergeCumulativeValues.d.ts +0 -2
  168. package/dist/esm/utils/mergeCumulativeValues.js +0 -18
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.manifestTempFile = exports.analyzeClientEntries = exports.assertRollupInput = exports.buildConfig = void 0;
7
7
  const utils_js_1 = require("../utils.js");
8
8
  const getVikeConfig_js_1 = require("./importUserCode/v1-design/getVikeConfig.js");
9
- const helpers_js_1 = require("../../../shared/page-configs/helpers.js");
9
+ const getConfigValue_js_1 = require("../../../shared/page-configs/getConfigValue.js");
10
10
  const findPageFiles_js_1 = require("../shared/findPageFiles.js");
11
11
  const getConfigVike_js_1 = require("../../shared/getConfigVike.js");
12
12
  const virtualFilePageConfigValuesAll_js_1 = require("../../shared/virtual-files/virtualFilePageConfigValuesAll.js");
@@ -156,7 +156,7 @@ function analyzeClientEntries(pageConfigs, config) {
156
156
  let clientEntries = {};
157
157
  let clientEntryList = [];
158
158
  pageConfigs.forEach((pageConfig) => {
159
- const configValue = (0, helpers_js_1.getConfigValue)(pageConfig, 'clientRouting', 'boolean');
159
+ const configValue = (0, getConfigValue_js_1.getConfigValue)(pageConfig, 'clientRouting', 'boolean');
160
160
  if (configValue?.value) {
161
161
  hasClientRouting = true;
162
162
  }
@@ -80,7 +80,7 @@ function assertResolveAlias(config) {
80
80
  exports.assertResolveAlias = assertResolveAlias;
81
81
  function getAliases(config) {
82
82
  const { alias } = config.resolve;
83
- if (!Array.isArray(alias)) {
83
+ if (!(0, utils_js_1.isArray)(alias)) {
84
84
  return [alias];
85
85
  }
86
86
  else {
@@ -35,28 +35,32 @@ exports.determineOptimizeDeps = determineOptimizeDeps;
35
35
  async function getPageDeps(config, pageConfigs, isDev) {
36
36
  let entries = [];
37
37
  let include = [];
38
+ const addEntry = (e) => {
39
+ (0, utils_js_1.assert)(e);
40
+ entries.push(e);
41
+ };
42
+ const addInclude = (e) => {
43
+ (0, utils_js_1.assert)(e);
44
+ // Shouldn't be a path alias, as path aliases would need to be added to config.optimizeDeps.entries instead of config.optimizeDeps.include
45
+ (0, utils_js_1.assertIsNpmPackageImport)(e);
46
+ include.push(e);
47
+ };
38
48
  // V1 design
39
49
  {
40
50
  pageConfigs.forEach((pageConfig) => {
41
51
  (0, getConfigValueSourcesNotOverriden_js_1.getConfigValueSourcesNotOverriden)(pageConfig).forEach((configValueSource) => {
42
52
  if (!configValueSource.valueIsImportedAtRuntime)
43
53
  return;
44
- const { definedAt, configEnv } = configValueSource;
54
+ const { definedAtFilePath, configEnv } = configValueSource;
45
55
  if (!configEnv.client)
46
56
  return;
47
- if (definedAt.filePathAbsoluteUserRootDir !== null) {
48
- const { filePathAbsoluteFilesystem } = definedAt;
49
- (0, utils_js_1.assert)(filePathAbsoluteFilesystem);
50
- // Surprisingly Vite expects entries to be absolute paths
51
- entries.push(filePathAbsoluteFilesystem);
57
+ if (definedAtFilePath.filePathAbsoluteUserRootDir !== null) {
58
+ // Vite expects entries to be filesystem absolute paths (surprisingly so).
59
+ addEntry(definedAtFilePath.filePathAbsoluteFilesystem);
52
60
  }
53
61
  else {
54
- // Adding definedAt.filePathAbsoluteFilesystem doesn't work for npm packages, I guess because of Vite's config.server.fs.allow
55
- const { importPathAbsolute } = definedAt;
56
- (0, utils_js_1.assert)(importPathAbsolute); // Help TS
57
- // Shouldn't be a path alias, as path aliases would need to be added to config.optimizeDeps.entries instead of config.optimizeDeps.include
58
- (0, utils_js_1.assertIsNpmPackageImport)(importPathAbsolute);
59
- include.push(importPathAbsolute);
62
+ // Adding definedAtFilePath.filePathAbsoluteFilesystem doesn't work for npm packages, I guess because of Vite's config.server.fs.allow
63
+ addInclude(definedAtFilePath.importPathAbsolute);
60
64
  }
61
65
  });
62
66
  });
@@ -68,8 +72,7 @@ async function getPageDeps(config, pageConfigs, isDev) {
68
72
  pageFiles.forEach((filePathAbsoluteUserRootDir) => {
69
73
  const entry = (0, getFilePath_js_1.getFilePathResolved)({ filePathAbsoluteUserRootDir, userRootDir });
70
74
  const { filePathAbsoluteFilesystem } = entry;
71
- (0, utils_js_1.assert)(filePathAbsoluteFilesystem);
72
- entries.push(filePathAbsoluteFilesystem);
75
+ addEntry(filePathAbsoluteFilesystem);
73
76
  });
74
77
  }
75
78
  entries = (0, utils_js_1.unique)(entries);
@@ -86,7 +89,7 @@ function getVirtualFiles(config, pageConfigs) {
86
89
  return entriesVirtualFiles;
87
90
  }
88
91
  function normalizeEntries(entries) {
89
- if (Array.isArray(entries))
92
+ if ((0, utils_js_1.isArray)(entries))
90
93
  return entries;
91
94
  if (typeof entries === 'string')
92
95
  return [entries];
@@ -95,7 +98,7 @@ function normalizeEntries(entries) {
95
98
  (0, utils_js_1.assert)(false);
96
99
  }
97
100
  function normalizeInclude(include) {
98
- if (Array.isArray(include))
101
+ if ((0, utils_js_1.isArray)(include))
99
102
  return include;
100
103
  if (include === undefined)
101
104
  return [];
@@ -171,7 +171,7 @@ function getRollupOutputs(config) {
171
171
  (_a = config.build).rollupOptions ?? (_a.rollupOptions = {});
172
172
  (_b = config.build.rollupOptions).output ?? (_b.output = {});
173
173
  const { output } = config.build.rollupOptions;
174
- if (!Array.isArray(output)) {
174
+ if (!(0, utils_js_1.isArray)(output)) {
175
175
  return [output];
176
176
  }
177
177
  return output;
@@ -30,11 +30,7 @@ function envVarsPlugin() {
30
30
  Object.entries(envsAll)
31
31
  .filter(([key]) => {
32
32
  // Already handled by Vite
33
- const envPrefix = !config.envPrefix
34
- ? []
35
- : Array.isArray(config.envPrefix)
36
- ? config.envPrefix
37
- : [config.envPrefix];
33
+ const envPrefix = !config.envPrefix ? [] : (0, utils_js_1.isArray)(config.envPrefix) ? config.envPrefix : [config.envPrefix];
38
34
  return !envPrefix.some((prefix) => key.startsWith(prefix));
39
35
  })
40
36
  .forEach(([envName, envVal]) => {
@@ -128,10 +128,7 @@ function isVikeConfigModule(filePathAbsoluteFilesystem) {
128
128
  }
129
129
  function reloadConfig(filePath, config, op) {
130
130
  {
131
- const { filePathToShowToUserResolved } = (0, getFilePath_js_1.getFilePathResolved)({
132
- filePathAbsoluteFilesystem: filePath,
133
- userRootDir: config.root
134
- });
131
+ const filePathToShowToUserResolved = (0, getFilePath_js_1.getModuleFilePath)(filePath, config);
135
132
  const msg = `${op} ${picocolors_1.default.dim(filePathToShowToUserResolved)}`;
136
133
  (0, loggerNotProd_js_1.logConfigInfo)(msg, 'info');
137
134
  }
@@ -13,7 +13,7 @@ const getConfigValueSourcesNotOverriden_js_1 = require("../../../shared/getConfi
13
13
  function getConfigValuesSerialized(pageConfig, isEnvMatch) {
14
14
  const lines = [];
15
15
  Object.entries(pageConfig.configValuesComputed).forEach(([configName, configValuesComputed]) => {
16
- const { value, configEnv } = configValuesComputed;
16
+ const { configEnv } = configValuesComputed;
17
17
  if (!isEnvMatch(configEnv))
18
18
  return;
19
19
  // configValeSources has higher precedence
@@ -21,9 +21,11 @@ function getConfigValuesSerialized(pageConfig, isEnvMatch) {
21
21
  return;
22
22
  const configValue = pageConfig.configValues[configName];
23
23
  (0, utils_js_1.assert)(configValue);
24
- const { definedAt } = configValue;
25
- const valueSerialized = getConfigValueSerialized(value, configName, definedAt);
26
- (0, serializeConfigValue_js_1.serializeConfigValue)(lines, configName, { definedAt, valueSerialized });
24
+ const { value, ...common } = configValue;
25
+ (0, utils_js_1.assert)(value === configValuesComputed.value);
26
+ const valueSerialized = getConfigValueSerialized(value, configName, configValue.definedAtData);
27
+ const configValueSerialized = { valueSerialized, ...common };
28
+ (0, serializeConfigValue_js_1.serializeConfigValue)(lines, configName, configValueSerialized);
27
29
  });
28
30
  (0, getConfigValueSourcesNotOverriden_js_1.getConfigValueSourcesNotOverriden)(pageConfig).forEach((configValueSource) => {
29
31
  const { configName, configEnv } = configValueSource;
@@ -33,20 +35,21 @@ function getConfigValuesSerialized(pageConfig, isEnvMatch) {
33
35
  if (!isEnvMatch(configEnv, configValueSource)) {
34
36
  return;
35
37
  }
36
- const { value, definedAt } = configValue;
37
- const valueSerialized = getConfigValueSerialized(value, configName, definedAt);
38
- (0, serializeConfigValue_js_1.serializeConfigValue)(lines, configName, { definedAt, valueSerialized });
38
+ const { value, ...common } = configValue;
39
+ const valueSerialized = getConfigValueSerialized(value, configName, configValue.definedAtData);
40
+ const configValueSerialized = { valueSerialized, ...common };
41
+ (0, serializeConfigValue_js_1.serializeConfigValue)(lines, configName, configValueSerialized);
39
42
  });
40
43
  const code = lines.join('\n');
41
44
  return code;
42
45
  }
43
46
  exports.getConfigValuesSerialized = getConfigValuesSerialized;
44
- function assertConfigValueIsSerializable(value, configName, definedAt) {
47
+ function assertConfigValueIsSerializable(value, configName, definedAtData) {
45
48
  // Contains asserts
46
- getConfigValueSerialized(value, configName, definedAt);
49
+ getConfigValueSerialized(value, configName, definedAtData);
47
50
  }
48
51
  exports.assertConfigValueIsSerializable = assertConfigValueIsSerializable;
49
- function getConfigValueSerialized(value, configName, definedAt) {
52
+ function getConfigValueSerialized(value, configName, definedAtData) {
50
53
  const valueName = `config${(0, utils_js_1.getPropAccessNotation)(configName)}`;
51
54
  let configValueSerialized;
52
55
  try {
@@ -64,7 +67,7 @@ function getConfigValueSerialized(value, configName, definedAt) {
64
67
  serializationErrMsg = 'see serialization error printed above'
65
68
  }
66
69
  */
67
- const configValueFilePathToShowToUser = (0, helpers_js_1.getConfigValueFilePathToShowToUser)({ definedAt });
70
+ const configValueFilePathToShowToUser = (0, helpers_js_1.getConfigValueFilePathToShowToUser)(definedAtData);
68
71
  (0, utils_js_1.assert)(configValueFilePathToShowToUser);
69
72
  (0, utils_js_1.assertUsage)(false, `${picocolors_1.default.cyan(configName)} defined by ${configValueFilePathToShowToUser} must be defined over a so-called "pointer import", see https://vike.dev/config#pointer-imports`);
70
73
  }
@@ -11,8 +11,7 @@ const assertPlusFileExport_js_1 = require("../../../../../../shared/page-configs
11
11
  const picocolors_1 = __importDefault(require("@brillout/picocolors"));
12
12
  const transformFileImports_js_1 = require("./transformFileImports.js");
13
13
  const getConfigFileExport_js_1 = require("../getConfigFileExport.js");
14
- const resolveImportPath_js_1 = require("./resolveImportPath.js");
15
- const getFilePath_js_1 = require("../../../../shared/getFilePath.js");
14
+ const resolvePointerImport_js_1 = require("./resolvePointerImport.js");
16
15
  (0, utils_js_1.assertIsNotProductionRuntime)();
17
16
  // Load fake import
18
17
  async function loadImportedFile(import_, userRootDir, importedFilesLoaded) {
@@ -62,13 +61,11 @@ function assertNoInfiniteLoop(visited, filePathAbsoluteFilesystem) {
62
61
  (0, utils_js_1.assertUsage)(idx === -1, `Infinite extends loop ${[...loop, filePathAbsoluteFilesystem].join('>')}`);
63
62
  }
64
63
  async function loadExtendsConfigs(configFileExports, configFilePath, userRootDir, visited) {
65
- const extendsImportData = getExtendsImportData(configFileExports, configFilePath);
64
+ const extendsPointerImportData = getExtendsPointerImportData(configFileExports, configFilePath);
66
65
  const extendsConfigFiles = [];
67
- extendsImportData.map((importData) => {
68
- const { importPath: importPathAbsolute } = importData;
69
- const filePathAbsoluteFilesystem = (0, resolveImportPath_js_1.resolveImportPath)(importData, configFilePath);
70
- (0, resolveImportPath_js_1.assertImportPath)(filePathAbsoluteFilesystem, importData, configFilePath);
71
- const filePath = (0, getFilePath_js_1.getFilePathResolved)({ filePathAbsoluteFilesystem, userRootDir, importPathAbsolute });
66
+ extendsPointerImportData.map((pointerImportData) => {
67
+ const filePath = (0, resolvePointerImport_js_1.resolvePointerImport)(pointerImportData, configFilePath, userRootDir);
68
+ (0, utils_js_1.assert)(filePath.filePathAbsoluteFilesystem);
72
69
  extendsConfigFiles.push(filePath);
73
70
  });
74
71
  const extendsConfigs = [];
@@ -80,7 +77,7 @@ async function loadExtendsConfigs(configFileExports, configFilePath, userRootDir
80
77
  const extendsFilePaths = extendsConfigFiles.map((f) => f.filePathAbsoluteFilesystem);
81
78
  return { extendsConfigs, extendsFilePaths };
82
79
  }
83
- function getExtendsImportData(configFileExports, configFilePath) {
80
+ function getExtendsPointerImportData(configFileExports, configFilePath) {
84
81
  const { filePathToShowToUser } = configFilePath;
85
82
  const configFileExport = (0, getConfigFileExport_js_1.getConfigFileExport)(configFileExports, filePathToShowToUser);
86
83
  const wrongUsage = `${filePathToShowToUser} sets the config ${picocolors_1.default.cyan('extends')} to an invalid value, see https://vike.dev/extends`;
@@ -97,10 +94,10 @@ function getExtendsImportData(configFileExports, configFilePath) {
97
94
  else {
98
95
  (0, utils_js_1.assertUsage)(false, wrongUsage);
99
96
  }
100
- const extendsImportData = extendList.map((importDataSerialized) => {
101
- const importData = (0, transformFileImports_js_1.parseImportData)(importDataSerialized);
102
- (0, utils_js_1.assertUsage)(importData, wrongUsage);
103
- return importData;
97
+ const extendsPointerImportData = extendList.map((importString) => {
98
+ const pointerImportData = (0, transformFileImports_js_1.parsePointerImportData)(importString);
99
+ (0, utils_js_1.assertUsage)(pointerImportData, wrongUsage);
100
+ return pointerImportData;
104
101
  });
105
- return extendsImportData;
102
+ return extendsPointerImportData;
106
103
  }
@@ -3,79 +3,86 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.clearFilesEnvMap = exports.assertImportPath = exports.resolveImportPath = exports.resolveImport = void 0;
6
+ exports.clearFilesEnvMap = exports.resolvePointerImport = exports.resolvePointerImportOfConfig = void 0;
7
7
  const picocolors_1 = __importDefault(require("@brillout/picocolors"));
8
8
  const utils_js_1 = require("../../../../utils.js");
9
9
  const transformFileImports_js_1 = require("./transformFileImports.js");
10
10
  const path_1 = __importDefault(require("path"));
11
11
  const getFilePath_js_1 = require("../../../../shared/getFilePath.js");
12
12
  const filesEnvMap = new Map();
13
- function resolveImport(configValue, importerFilePath, userRootDir, configEnv, configName) {
13
+ function resolvePointerImportOfConfig(configValue, importerFilePath, userRootDir, configEnv, configName) {
14
14
  if (typeof configValue !== 'string')
15
15
  return null;
16
- const importData = (0, transformFileImports_js_1.parseImportData)(configValue);
17
- if (!importData)
16
+ const pointerImportData = (0, transformFileImports_js_1.parsePointerImportData)(configValue);
17
+ if (!pointerImportData)
18
18
  return null;
19
- const { importPath, exportName } = importData;
20
- const filePathAbsoluteFilesystem = resolveImportPath(importData, importerFilePath);
21
- assertFileEnv(filePathAbsoluteFilesystem ?? importPath, configEnv, configName);
19
+ const { importPath, exportName } = pointerImportData;
20
+ const filePath = resolvePointerImport(pointerImportData, importerFilePath, userRootDir);
22
21
  const fileExportPathToShowToUser = exportName === 'default' || exportName === configName ? [] : [exportName];
22
+ assertFileEnv(filePath.filePathAbsoluteFilesystem, importPath, configEnv, configName);
23
+ return {
24
+ ...filePath,
25
+ fileExportName: exportName,
26
+ fileExportPathToShowToUser
27
+ };
28
+ }
29
+ exports.resolvePointerImportOfConfig = resolvePointerImportOfConfig;
30
+ function resolvePointerImport(pointerImportData, importerFilePath, userRootDir) {
31
+ const { importPath } = pointerImportData;
32
+ const filePathAbsoluteFilesystem = resolveImportPathWithNode(pointerImportData, importerFilePath);
23
33
  let filePath;
24
- if (importPath.startsWith('.')) {
25
- (0, utils_js_1.assert)(importPath.startsWith('./') || importPath.startsWith('../'));
26
- assertImportPath(filePathAbsoluteFilesystem, importData, importerFilePath);
27
- filePath = (0, getFilePath_js_1.getFilePathResolved)({ filePathAbsoluteFilesystem, userRootDir });
34
+ // - importPath is one of the following. (See `transpileAndExecuteFile()`.)
35
+ // - A relative import path
36
+ // - A filesystem absolute path
37
+ // - An npm package import
38
+ // - importPath cannot be a path alias (since esbuild resolves path aliases, see transpileAndExecuteFile.ts)
39
+ (0, utils_js_1.assertPosixPath)(importPath);
40
+ if (importPath.startsWith('.') || (0, utils_js_1.isPathFilesystemAbsolute)(importPath)) {
41
+ if (importPath.startsWith('.')) {
42
+ (0, utils_js_1.assert)(importPath.startsWith('./') || importPath.startsWith('../'));
43
+ }
44
+ assertImportPath(filePathAbsoluteFilesystem, pointerImportData, importerFilePath);
45
+ const filePathAbsoluteUserRootDir = (0, getFilePath_js_1.getFilePathAbsoluteUserRootDir)({ filePathAbsoluteFilesystem, userRootDir });
46
+ // This assert() is guarenteed, see assertUsage() in the onResolve() esbuild hook in transpileAndExecuteFile.ts
47
+ (0, utils_js_1.assert)(filePathAbsoluteUserRootDir);
28
48
  // Imports are included in virtual files, thus the relative path of imports need to resolved.
29
49
  // ```
30
50
  // [vite] Internal server error: Failed to resolve import "./onPageTransitionHooks" from "virtual:vike:pageConfigValuesAll:client:/pages/index". Does the file exist?
31
51
  // ```
32
- (0, utils_js_1.assertUsage)(filePath.filePathAbsoluteUserRootDir, `${importerFilePath.filePathToShowToUser} imports a relative path ${picocolors_1.default.cyan(importPath)} resolving outside of ${userRootDir} which is forbidden: import from a relative path inside ${userRootDir}, or import from a dependency's package.json#exports entry instead`);
33
- // Alternativey, we can try one of the following but last time we tried none of the following worked.
34
- // /*
35
- // assert(filePathAbsoluteFilesystem.startsWith('/'))
36
- // filePath = `/@fs${filePathAbsoluteFilesystem}`
37
- // /*/
38
- // assert(filePathAbsoluteUserRootDir.startsWith('../'))
39
- // filePathAbsoluteUserRootDir = '/' + filePathAbsoluteUserRootDir
40
- // //*/
52
+ filePath = (0, getFilePath_js_1.getFilePathResolved)({ filePathAbsoluteUserRootDir, userRootDir });
41
53
  }
42
54
  else {
43
- // importPath can be:
44
- // - an npm package import
45
- // - a path alias
55
+ const importPathAbsolute = importPath;
56
+ // importPath cannot be a path alias (since esbuild resolves path aliases, see transpileAndExecuteFile.ts)
57
+ (0, utils_js_1.assertIsNpmPackageImport)(importPathAbsolute);
46
58
  if (filePathAbsoluteFilesystem) {
47
59
  filePath = (0, getFilePath_js_1.getFilePathResolved)({
48
60
  userRootDir,
49
61
  filePathAbsoluteFilesystem,
50
- importPathAbsolute: importPath
62
+ importPathAbsolute
51
63
  });
52
64
  }
53
65
  else {
54
66
  filePath = (0, getFilePath_js_1.getFilePathUnresolved)({
55
- importPathAbsolute: importPath
67
+ importPathAbsolute
56
68
  });
57
69
  }
58
70
  }
59
- return {
60
- ...filePath,
61
- fileExportName: exportName,
62
- fileExportPathToShowToUser
63
- };
71
+ return filePath;
64
72
  }
65
- exports.resolveImport = resolveImport;
66
- function resolveImportPath(importData, importerFilePath) {
73
+ exports.resolvePointerImport = resolvePointerImport;
74
+ function resolveImportPathWithNode(pointerImportData, importerFilePath) {
67
75
  const importerFilePathAbsolute = importerFilePath.filePathAbsoluteFilesystem;
68
76
  (0, utils_js_1.assertPosixPath)(importerFilePathAbsolute);
69
77
  const cwd = path_1.default.posix.dirname(importerFilePathAbsolute);
70
78
  // We can't use import.meta.resolve() as of Junary 2023 (and probably for a lot longer)
71
79
  // https://stackoverflow.com/questions/54977743/do-require-resolve-for-es-modules#comment137174954_62272600:~:text=But%20the%20argument%20parent%20(aka%20cwd)%20still%20requires%20a%20flag
72
- // filePathAbsoluteFilesystem is expected to be null when importData.importPath is a Vite path alias
73
- const filePathAbsoluteFilesystem = (0, utils_js_1.requireResolve)(importData.importPath, cwd);
80
+ // filePathAbsoluteFilesystem is expected to be null when pointerImportData.importPath is a Vite path alias
81
+ const filePathAbsoluteFilesystem = (0, utils_js_1.requireResolve)(pointerImportData.importPath, cwd);
74
82
  return filePathAbsoluteFilesystem;
75
83
  }
76
- exports.resolveImportPath = resolveImportPath;
77
- function assertImportPath(filePathAbsoluteFilesystem, importData, importerFilePath) {
78
- const { importPath: importPath, importStringWasGenerated, importString } = importData;
84
+ function assertImportPath(filePathAbsoluteFilesystem, pointerImportData, importerFilePath) {
85
+ const { importPath: importPath, importStringWasGenerated, importString } = pointerImportData;
79
86
  const { filePathToShowToUser } = importerFilePath;
80
87
  if (!filePathAbsoluteFilesystem) {
81
88
  const importPathString = picocolors_1.default.cyan(`'${importPath}'`);
@@ -92,18 +99,25 @@ function assertImportPath(filePathAbsoluteFilesystem, importData, importerFilePa
92
99
  }
93
100
  }
94
101
  }
95
- exports.assertImportPath = assertImportPath;
96
- function assertFileEnv(filePathForEnvCheck, configEnv, configName) {
97
- (0, utils_js_1.assertPosixPath)(filePathForEnvCheck);
98
- if (!filesEnvMap.has(filePathForEnvCheck)) {
99
- filesEnvMap.set(filePathForEnvCheck, []);
102
+ function assertFileEnv(filePathAbsoluteFilesystem, importPath, configEnv, configName) {
103
+ let key;
104
+ if (filePathAbsoluteFilesystem) {
105
+ key = filePathAbsoluteFilesystem;
106
+ }
107
+ else {
108
+ (0, utils_js_1.assertIsNpmPackageImport)(importPath);
109
+ key = importPath;
110
+ }
111
+ (0, utils_js_1.assertPosixPath)(key);
112
+ if (!filesEnvMap.has(key)) {
113
+ filesEnvMap.set(key, []);
100
114
  }
101
- const fileEnv = filesEnvMap.get(filePathForEnvCheck);
115
+ const fileEnv = filesEnvMap.get(key);
102
116
  fileEnv.push({ configEnv, configName });
103
117
  const configDifferentEnv = fileEnv.filter((c) => !(0, utils_js_1.deepEqual)(c.configEnv, configEnv))[0];
104
118
  if (configDifferentEnv) {
105
119
  (0, utils_js_1.assertUsage)(false, [
106
- `${filePathForEnvCheck} defines the value of configs living in different environments:`,
120
+ `${key} defines the value of configs living in different environments:`,
107
121
  ...[configDifferentEnv, { configName, configEnv }].map((c) => ` - config ${picocolors_1.default.cyan(c.configName)} which value lives in environment ${picocolors_1.default.cyan(JSON.stringify(c.configEnv))}`),
108
122
  'Defining config values in the same file is allowed only if they live in the same environment, see https://vike.dev/config#pointer-imports'
109
123
  ].join('\n'));
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.isImportData = exports.parseImportData = exports.transformFileImports = void 0;
6
+ exports.isPointerImportData = exports.parsePointerImportData = exports.transformFileImports = void 0;
7
7
  // Playground: https://github.com/brillout/acorn-playground
8
8
  // Notes about `with { type: 'pointer' }`
9
9
  // - It works well with TypeScript: it doesn't complain upon `with { type: 'unknown-to-typescript' }` and go-to-definition & types are preserved: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-3.html#import-attributes
@@ -93,7 +93,7 @@ skipWarnings) {
93
93
  }
94
94
  return importLocalName;
95
95
  })();
96
- const importString = serializeImportData({ importPath, exportName, importStringWasGenerated: true });
96
+ const importString = serializePointerImportData({ importPath, exportName, importStringWasGenerated: true });
97
97
  replacement += `const ${importLocalName} = '${importString}';`;
98
98
  });
99
99
  spliceOperations.push({
@@ -122,17 +122,17 @@ function getImports(code) {
122
122
  const import_ = 'import';
123
123
  const SEP = ':';
124
124
  const zeroWidthSpace = '\u200b';
125
- function serializeImportData({ importPath, exportName, importStringWasGenerated }) {
125
+ function serializePointerImportData({ importPath, exportName, importStringWasGenerated }) {
126
126
  const tag = importStringWasGenerated ? zeroWidthSpace : '';
127
127
  // `import:${importPath}:${importPath}`
128
128
  return `${tag}${import_}${SEP}${importPath}${SEP}${exportName}`;
129
129
  }
130
- function isImportData(str) {
130
+ function isPointerImportData(str) {
131
131
  return str.startsWith(import_ + SEP) || str.startsWith(zeroWidthSpace + import_ + SEP);
132
132
  }
133
- exports.isImportData = isImportData;
134
- function parseImportData(importString) {
135
- if (!isImportData(importString)) {
133
+ exports.isPointerImportData = isPointerImportData;
134
+ function parsePointerImportData(importString) {
135
+ if (!isPointerImportData(importString)) {
136
136
  return null;
137
137
  }
138
138
  let importStringWasGenerated = false;
@@ -152,7 +152,7 @@ function parseImportData(importString) {
152
152
  const importPath = parts.slice(0, -1).join(SEP);
153
153
  return { importPath, exportName, importStringWasGenerated, importString };
154
154
  }
155
- exports.parseImportData = parseImportData;
155
+ exports.parsePointerImportData = parsePointerImportData;
156
156
  function spliceMany(str, operations) {
157
157
  let strMod = '';
158
158
  let endPrev;
@@ -13,6 +13,7 @@ const utils_js_1 = require("../../../../utils.js");
13
13
  const transformFileImports_js_1 = require("./transformFileImports.js");
14
14
  const getVikeConfig_js_1 = require("../getVikeConfig.js");
15
15
  require("source-map-support/register.js");
16
+ const getFilePath_js_1 = require("../../../../shared/getFilePath.js");
16
17
  (0, utils_js_1.assertIsNotProductionRuntime)();
17
18
  const debug = (0, utils_js_1.createDebugger)('vike:pointer-imports');
18
19
  async function transpileAndExecuteFile(filePath, userRootDir, isConfigFile) {
@@ -114,13 +115,21 @@ async function transpileWithEsbuild(filePath, userRootDir, transformImports) {
114
115
  return resolved;
115
116
  }
116
117
  (0, utils_js_1.assert)(resolved.path);
117
- resolved.path = (0, utils_js_1.toPosixPath)(resolved.path);
118
+ const importPathResolved = (0, utils_js_1.toPosixPath)(resolved.path);
119
+ const importPathOriginal = args.path;
120
+ // Esbuild resolves path aliases.
121
+ // - Enabling us to use:
122
+ // ```js
123
+ // isNpmPackageImport(str, { cannotBePathAlias: true })
124
+ // assertIsNpmPackageImport()
125
+ // ```
126
+ (0, utils_js_1.assertPathFilesystemAbsolute)(importPathResolved);
118
127
  // vike-{react,vue,solid} follow the convention that their config export resolves to a file named +config.js
119
128
  // - This is temporary, see comment below.
120
- const isVikeExtensionConfigImport = resolved.path.endsWith('+config.js');
129
+ const isVikeExtensionConfigImport = importPathResolved.endsWith('+config.js');
121
130
  const isPointerImport = transformImports === 'all' ||
122
131
  // .jsx, .vue, .svg, ... => obviously not config code
123
- !(0, utils_js_1.isJavaScriptFile)(resolved.path) ||
132
+ !(0, utils_js_1.isJavaScriptFile)(importPathResolved) ||
124
133
  // Import of a Vike extension config => make it a pointer import because we want to show nice error messages (that can display whether a configas been set by the user or by a Vike extension).
125
134
  // - We should have Node.js directly load vike-{react,vue,solid} while enforcing Vike extensions to set 'name' in their +config.js file.
126
135
  // - vike@0.4.162 already started soft-requiring Vike extensions to set the name config
@@ -129,21 +138,52 @@ async function transpileWithEsbuild(filePath, userRootDir, transformImports) {
129
138
  // - For example if esbuild cannot resolve a path alias while Vite can.
130
139
  // - When tsconfig.js#compilerOptions.paths is set, then esbuild is able to resolve the path alias.
131
140
  resolved.errors.length > 0;
132
- pointerImports[resolved.path] = isPointerImport;
133
- (0, utils_js_1.assertPosixPath)(resolved.path);
141
+ (0, utils_js_1.assertPosixPath)(importPathResolved);
134
142
  const isExternal = isPointerImport ||
135
143
  // Performance: npm package imports that aren't pointer imports can be externalized. For example, if Vike eventually adds support for setting Vite configs in the vike.config.js file, then the user may import a Vite plugin in his vike.config.js file. (We could as well let esbuild always transpile /node_modules/ code but it would be useless and would unnecessarily slow down transpilation.)
136
- resolved.path.includes('/node_modules/');
144
+ importPathResolved.includes('/node_modules/');
145
+ const filePathAbsoluteUserRootDir = (0, getFilePath_js_1.getFilePathAbsoluteUserRootDir)({
146
+ filePathAbsoluteFilesystem: importPathResolved,
147
+ userRootDir
148
+ });
149
+ let importPathTranspiled;
150
+ (0, utils_js_1.assertPosixPath)(importPathOriginal);
151
+ if (importPathOriginal.startsWith('./') || importPathOriginal.startsWith('../')) {
152
+ // - We need this assertUsage() because we didn't find a way (yet?) to use filesystem absolute import paths in virtual files.
153
+ // - Alternatively, we can again try one of the following for generating the imports of virtual files. (Last time we tried none of it worked.)
154
+ // - ~~~js
155
+ // assert(filePathAbsoluteFilesystem.startsWith('/'))
156
+ // filePath = `/@fs${filePathAbsoluteFilesystem}`
157
+ // ~~~
158
+ // - ~~~js
159
+ // assert(filePathAbsoluteUserRootDir.startsWith('../'))
160
+ // filePathAbsoluteUserRootDir = '/' + filePathAbsoluteUserRootDir
161
+ // ~~~
162
+ (0, utils_js_1.assertUsage)(filePathAbsoluteUserRootDir, `Import ${picocolors_1.default.cyan(importPathOriginal)} resolves to ${importPathResolved} outside of ${userRootDir} which is forbidden: make sure your relative import paths resolve inside ${userRootDir}, or import from an npm package.`);
163
+ importPathTranspiled = importPathResolved;
164
+ }
165
+ else {
166
+ // importPathOriginal is either:
167
+ // - Npm package import
168
+ // - Path alias
169
+ if (filePathAbsoluteUserRootDir) {
170
+ // importPathOriginal is most likely a path alias. (Is it even possible for an npm package import to resolved inside `userRootDir`?)
171
+ importPathTranspiled = importPathResolved;
172
+ }
173
+ else {
174
+ // importPathOriginal is an npm package import. (Assuming path aliases always resolve inside `userRootDir`.)
175
+ (0, utils_js_1.assertIsNpmPackageImport)(importPathOriginal);
176
+ importPathTranspiled = importPathOriginal;
177
+ }
178
+ }
137
179
  if (debug.isActivated)
138
- debug('onResolved()', { args, resolved, isPointerImport, isExternal });
139
- // We need esbuild to resolve path aliases so that we can use:
140
- // isNpmPackageImport(str, { cannotBePathAlias: true })
141
- // assertIsNpmPackageImport()
142
- (0, utils_js_1.assertPathIsFilesystemAbsolute)(resolved.path);
180
+ debug('onResolved()', { args, resolved, importPathTranspiled, isPointerImport, isExternal });
181
+ pointerImports[importPathTranspiled] = isPointerImport;
143
182
  if (isExternal) {
144
- return { external: true, path: resolved.path };
183
+ return { external: true, path: importPathTranspiled };
145
184
  }
146
185
  else {
186
+ resolved.path = importPathTranspiled;
147
187
  return resolved;
148
188
  }
149
189
  });