@marko/vite 2.4.9 → 3.0.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/README.md CHANGED
@@ -94,7 +94,7 @@ app.listen(3000);
94
94
 
95
95
  ### options.babelConfig
96
96
 
97
- You can manually override Marko's Babel configuration by passing a `babelConfig` object to the `@marko/vite` plugin. By default Babel's regular [config file resolution](https://babeljs.io/docs/en/config-files) will be used.
97
+ You can manually override Marko's Babel configuration by passing a `babelConfig` object to the `@marko/vite` plugin. If no babel configuration is specified, babel related config files will not be considered.
98
98
 
99
99
  ```javascript
100
100
  marko({
package/dist/index.js CHANGED
@@ -59,6 +59,13 @@ const htmlExt = ".html";
59
59
  const resolveOpts = { skipSelf: true };
60
60
  const cache = /* @__PURE__ */ new Map();
61
61
  const thisFile = typeof __filename === "string" ? __filename : (0, import_url.fileURLToPath)(import_meta.url);
62
+ const babelCaller = {
63
+ name: "@marko/vite",
64
+ supportsStaticESM: true,
65
+ supportsDynamicImport: true,
66
+ supportsTopLevelAwait: true,
67
+ supportsExportNamespaceFrom: true
68
+ };
62
69
  function markoPlugin(opts = {}) {
63
70
  let compiler;
64
71
  let { linked = true } = opts;
@@ -68,7 +75,7 @@ function markoPlugin(opts = {}) {
68
75
  let ssrConfig;
69
76
  let domConfig;
70
77
  let hydrateConfig;
71
- const resolveViteVirtualDep = (from, dep) => {
78
+ const resolveVirtualDependency = (from, dep) => {
72
79
  const query = `${virtualFileQuery}&id=${encodeURIComponent(
73
80
  normalizePath(dep.virtualPath)
74
81
  )}`;
@@ -105,7 +112,7 @@ function markoPlugin(opts = {}) {
105
112
  enforce: "pre",
106
113
  // Must be pre to allow us to resolve assets before vite.
107
114
  async config(config, env) {
108
- var _a;
115
+ var _a, _b;
109
116
  compiler ?? (compiler = await import(opts.compiler || "@marko/compiler"));
110
117
  runtimeId = opts.runtimeId;
111
118
  basePathVar = opts.basePathVar;
@@ -114,31 +121,36 @@ function markoPlugin(opts = {}) {
114
121
  runtimeId,
115
122
  sourceMaps: true,
116
123
  writeVersionComment: false,
117
- babelConfig: {
124
+ babelConfig: opts.babelConfig ? {
118
125
  ...opts.babelConfig,
119
- caller: {
126
+ caller: opts.babelConfig.caller ? {
120
127
  name: "@marko/vite",
121
128
  supportsStaticESM: true,
122
129
  supportsDynamicImport: true,
123
130
  supportsTopLevelAwait: true,
124
131
  supportsExportNamespaceFrom: true,
125
- ...(_a = opts.babelConfig) == null ? void 0 : _a.caller
126
- }
132
+ ...opts.babelConfig.caller
133
+ } : babelCaller
134
+ } : {
135
+ babelrc: false,
136
+ configFile: false,
137
+ browserslistConfigFile: false,
138
+ caller: babelCaller
127
139
  }
128
140
  };
129
141
  ssrConfig = {
130
142
  ...baseConfig,
131
- resolveVirtualDependency: resolveViteVirtualDep,
143
+ resolveVirtualDependency,
132
144
  output: "html"
133
145
  };
134
146
  domConfig = {
135
147
  ...baseConfig,
136
- resolveVirtualDependency: resolveViteVirtualDep,
148
+ resolveVirtualDependency,
137
149
  output: "dom"
138
150
  };
139
151
  hydrateConfig = {
140
152
  ...baseConfig,
141
- resolveVirtualDependency: resolveViteVirtualDep,
153
+ resolveVirtualDependency,
142
154
  output: "hydrate"
143
155
  };
144
156
  compiler.configure(baseConfig);
@@ -219,13 +231,26 @@ function markoPlugin(opts = {}) {
219
231
  "Cannot use @marko/vite `basePathVar` with Vite's `renderBuiltUrl` option."
220
232
  );
221
233
  }
234
+ const assetsDir = ((_b = (_a = config.build) == null ? void 0 : _a.assetsDir) == null ? void 0 : _b.replace(/[/\\]$/, "")) ?? "assets";
235
+ const assetsDirLen = assetsDir.length;
236
+ const assetsDirEnd = assetsDirLen + 1;
237
+ const trimAssertsDir = (fileName) => {
238
+ if (fileName.startsWith(assetsDir)) {
239
+ switch (fileName[assetsDirLen]) {
240
+ case POSIX_SEP:
241
+ case WINDOWS_SEP:
242
+ return fileName.slice(assetsDirEnd);
243
+ }
244
+ }
245
+ return fileName;
246
+ };
222
247
  config.experimental.renderBuiltUrl = (fileName, { hostType, ssr: ssr2 }) => {
223
248
  switch (hostType) {
224
249
  case "html":
225
- return fileName;
250
+ return trimAssertsDir(fileName);
226
251
  case "js":
227
252
  return {
228
- runtime: `${ssr2 ? basePathVar : `$mbp${runtimeId ? `_${runtimeId}` : ""}`}+${JSON.stringify(fileName)}`
253
+ runtime: `${ssr2 ? basePathVar : `$mbp${runtimeId ? `_${runtimeId}` : ""}`}+${JSON.stringify(trimAssertsDir(fileName))}`
229
254
  };
230
255
  default:
231
256
  return { relative: true };
package/dist/index.mjs CHANGED
@@ -39,6 +39,13 @@ var htmlExt = ".html";
39
39
  var resolveOpts = { skipSelf: true };
40
40
  var cache = /* @__PURE__ */ new Map();
41
41
  var thisFile = typeof __filename === "string" ? __filename : fileURLToPath(import.meta.url);
42
+ var babelCaller = {
43
+ name: "@marko/vite",
44
+ supportsStaticESM: true,
45
+ supportsDynamicImport: true,
46
+ supportsTopLevelAwait: true,
47
+ supportsExportNamespaceFrom: true
48
+ };
42
49
  function markoPlugin(opts = {}) {
43
50
  let compiler;
44
51
  let { linked = true } = opts;
@@ -48,7 +55,7 @@ function markoPlugin(opts = {}) {
48
55
  let ssrConfig;
49
56
  let domConfig;
50
57
  let hydrateConfig;
51
- const resolveViteVirtualDep = (from, dep) => {
58
+ const resolveVirtualDependency = (from, dep) => {
52
59
  const query = `${virtualFileQuery}&id=${encodeURIComponent(
53
60
  normalizePath(dep.virtualPath)
54
61
  )}`;
@@ -85,7 +92,7 @@ function markoPlugin(opts = {}) {
85
92
  enforce: "pre",
86
93
  // Must be pre to allow us to resolve assets before vite.
87
94
  async config(config, env) {
88
- var _a;
95
+ var _a, _b;
89
96
  compiler ?? (compiler = await import(opts.compiler || "@marko/compiler"));
90
97
  runtimeId = opts.runtimeId;
91
98
  basePathVar = opts.basePathVar;
@@ -94,31 +101,36 @@ function markoPlugin(opts = {}) {
94
101
  runtimeId,
95
102
  sourceMaps: true,
96
103
  writeVersionComment: false,
97
- babelConfig: {
104
+ babelConfig: opts.babelConfig ? {
98
105
  ...opts.babelConfig,
99
- caller: {
106
+ caller: opts.babelConfig.caller ? {
100
107
  name: "@marko/vite",
101
108
  supportsStaticESM: true,
102
109
  supportsDynamicImport: true,
103
110
  supportsTopLevelAwait: true,
104
111
  supportsExportNamespaceFrom: true,
105
- ...(_a = opts.babelConfig) == null ? void 0 : _a.caller
106
- }
112
+ ...opts.babelConfig.caller
113
+ } : babelCaller
114
+ } : {
115
+ babelrc: false,
116
+ configFile: false,
117
+ browserslistConfigFile: false,
118
+ caller: babelCaller
107
119
  }
108
120
  };
109
121
  ssrConfig = {
110
122
  ...baseConfig,
111
- resolveVirtualDependency: resolveViteVirtualDep,
123
+ resolveVirtualDependency,
112
124
  output: "html"
113
125
  };
114
126
  domConfig = {
115
127
  ...baseConfig,
116
- resolveVirtualDependency: resolveViteVirtualDep,
128
+ resolveVirtualDependency,
117
129
  output: "dom"
118
130
  };
119
131
  hydrateConfig = {
120
132
  ...baseConfig,
121
- resolveVirtualDependency: resolveViteVirtualDep,
133
+ resolveVirtualDependency,
122
134
  output: "hydrate"
123
135
  };
124
136
  compiler.configure(baseConfig);
@@ -199,13 +211,26 @@ function markoPlugin(opts = {}) {
199
211
  "Cannot use @marko/vite `basePathVar` with Vite's `renderBuiltUrl` option."
200
212
  );
201
213
  }
214
+ const assetsDir = ((_b = (_a = config.build) == null ? void 0 : _a.assetsDir) == null ? void 0 : _b.replace(/[/\\]$/, "")) ?? "assets";
215
+ const assetsDirLen = assetsDir.length;
216
+ const assetsDirEnd = assetsDirLen + 1;
217
+ const trimAssertsDir = (fileName) => {
218
+ if (fileName.startsWith(assetsDir)) {
219
+ switch (fileName[assetsDirLen]) {
220
+ case POSIX_SEP:
221
+ case WINDOWS_SEP:
222
+ return fileName.slice(assetsDirEnd);
223
+ }
224
+ }
225
+ return fileName;
226
+ };
202
227
  config.experimental.renderBuiltUrl = (fileName, { hostType, ssr: ssr2 }) => {
203
228
  switch (hostType) {
204
229
  case "html":
205
- return fileName;
230
+ return trimAssertsDir(fileName);
206
231
  case "js":
207
232
  return {
208
- runtime: `${ssr2 ? basePathVar : `$mbp${runtimeId ? `_${runtimeId}` : ""}`}+${JSON.stringify(fileName)}`
233
+ runtime: `${ssr2 ? basePathVar : `$mbp${runtimeId ? `_${runtimeId}` : ""}`}+${JSON.stringify(trimAssertsDir(fileName))}`
209
234
  };
210
235
  default:
211
236
  return { relative: true };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@marko/vite",
3
3
  "description": "A Marko plugin for Vite",
4
- "version": "2.4.9",
4
+ "version": "3.0.0",
5
5
  "author": "Dylan Piercey <dpiercey@ebay.com>",
6
6
  "bugs": "https://github.com/marko-js/vite/issues",
7
7
  "dependencies": {