@remix-run/assets 0.4.4 → 0.6.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 +331 -72
- package/dist/assets.d.ts +4 -1
- package/dist/assets.d.ts.map +1 -1
- package/dist/assets.js +2 -2
- package/dist/lib/access.d.ts +35 -4
- package/dist/lib/access.d.ts.map +1 -1
- package/dist/lib/access.js +332 -11
- package/dist/lib/asset-server.d.ts +138 -11
- package/dist/lib/asset-server.d.ts.map +1 -1
- package/dist/lib/asset-server.js +281 -30
- package/dist/lib/compilation-error.d.ts +1 -1
- package/dist/lib/compilation-error.d.ts.map +1 -1
- package/dist/lib/file-matcher.js +1 -1
- package/dist/lib/files/compiler.d.ts.map +1 -1
- package/dist/lib/files/compiler.js +9 -8
- package/dist/lib/files/config.js +1 -1
- package/dist/lib/hmr.d.ts +37 -0
- package/dist/lib/hmr.d.ts.map +1 -0
- package/dist/lib/hmr.js +357 -0
- package/dist/lib/injected-packages.d.ts +3 -2
- package/dist/lib/injected-packages.d.ts.map +1 -1
- package/dist/lib/injected-packages.js +43 -17
- package/dist/lib/inspection.d.ts +39 -0
- package/dist/lib/inspection.d.ts.map +1 -0
- package/dist/lib/inspection.js +160 -0
- package/dist/lib/loaders.d.ts +57 -0
- package/dist/lib/loaders.d.ts.map +1 -0
- package/dist/lib/loaders.js +1 -0
- package/dist/lib/module-store.d.ts +24 -0
- package/dist/lib/module-store.d.ts.map +1 -1
- package/dist/lib/module-store.js +136 -11
- package/dist/lib/routes.d.ts +11 -3
- package/dist/lib/routes.d.ts.map +1 -1
- package/dist/lib/routes.js +124 -80
- package/dist/lib/scripts/compiler.d.ts +24 -1
- package/dist/lib/scripts/compiler.d.ts.map +1 -1
- package/dist/lib/scripts/compiler.js +183 -29
- package/dist/lib/scripts/conditions.d.ts +2 -0
- package/dist/lib/scripts/conditions.d.ts.map +1 -0
- package/dist/lib/scripts/conditions.js +1 -0
- package/dist/lib/scripts/emit.d.ts +3 -0
- package/dist/lib/scripts/emit.d.ts.map +1 -1
- package/dist/lib/scripts/emit.js +24 -5
- package/dist/lib/scripts/resolve.d.ts +4 -0
- package/dist/lib/scripts/resolve.d.ts.map +1 -1
- package/dist/lib/scripts/resolve.js +75 -10
- package/dist/lib/scripts/transform.d.ts +9 -0
- package/dist/lib/scripts/transform.d.ts.map +1 -1
- package/dist/lib/scripts/transform.js +222 -18
- package/dist/lib/source-maps.js +1 -1
- package/dist/lib/styles/compiler.d.ts +14 -1
- package/dist/lib/styles/compiler.d.ts.map +1 -1
- package/dist/lib/styles/compiler.js +78 -14
- package/dist/lib/styles/emit.js +4 -4
- package/dist/lib/styles/resolve.d.ts.map +1 -1
- package/dist/lib/styles/resolve.js +16 -15
- package/dist/lib/styles/transform.js +5 -5
- package/dist/lib/target.d.ts +1 -1
- package/dist/lib/target.d.ts.map +1 -1
- package/dist/lib/watch.js +1 -1
- package/dist/types/hmr.d.ts +36 -0
- package/package.json +16 -11
- package/src/assets.ts +4 -1
- package/src/lib/access.ts +445 -11
- package/src/lib/asset-server.ts +466 -27
- package/src/lib/compilation-error.ts +4 -3
- package/src/lib/files/compiler.ts +9 -5
- package/src/lib/hmr.ts +397 -0
- package/src/lib/injected-packages.ts +52 -16
- package/src/lib/inspection.ts +229 -0
- package/src/lib/loaders.ts +80 -0
- package/src/lib/module-store.ts +190 -9
- package/src/lib/routes.ts +158 -126
- package/src/lib/scripts/compiler.ts +248 -24
- package/src/lib/scripts/conditions.ts +1 -0
- package/src/lib/scripts/emit.ts +50 -5
- package/src/lib/scripts/resolve.ts +129 -7
- package/src/lib/scripts/transform.ts +290 -19
- package/src/lib/styles/compiler.ts +108 -8
- package/src/lib/styles/emit.ts +1 -1
- package/src/lib/styles/resolve.ts +19 -15
- package/src/lib/styles/transform.ts +2 -2
- package/src/types/hmr.d.ts +36 -0
|
@@ -163,17 +163,21 @@ export function resolveServedStyleOrThrow(
|
|
|
163
163
|
}
|
|
164
164
|
|
|
165
165
|
if (!args.isAllowed(identityPath)) {
|
|
166
|
-
throw createAssetServerCompilationError(
|
|
167
|
-
|
|
168
|
-
|
|
166
|
+
throw createAssetServerCompilationError(
|
|
167
|
+
`File "${identityPath}" is not allowed by the asset server access configuration. ` +
|
|
168
|
+
`Add a matching allowFiles or allowPackages rule, or remove a conflicting denyFiles rule.`,
|
|
169
|
+
{
|
|
170
|
+
code: 'FILE_NOT_ALLOWED',
|
|
171
|
+
},
|
|
172
|
+
)
|
|
169
173
|
}
|
|
170
174
|
|
|
171
175
|
let stableUrlPathname = args.routes.toUrlPathname(identityPath)
|
|
172
176
|
if (!stableUrlPathname) {
|
|
173
177
|
throw createAssetServerCompilationError(
|
|
174
|
-
`File ${identityPath} is outside all configured
|
|
178
|
+
`File ${identityPath} is outside all configured mounts.`,
|
|
175
179
|
{
|
|
176
|
-
code: '
|
|
180
|
+
code: 'FILE_OUTSIDE_MOUNTS',
|
|
177
181
|
},
|
|
178
182
|
)
|
|
179
183
|
}
|
|
@@ -218,8 +222,8 @@ function resolveImportDependency(
|
|
|
218
222
|
|
|
219
223
|
if (!args.isAllowed(identityPath)) {
|
|
220
224
|
throw createAssetServerCompilationError(
|
|
221
|
-
`Import "${url}" in ${importerPath}, resolved to "${identityPath}", is not allowed by the asset server
|
|
222
|
-
`Add a matching
|
|
225
|
+
`Import "${url}" in ${importerPath}, resolved to "${identityPath}", is not allowed by the asset server access configuration. ` +
|
|
226
|
+
`Add a matching allowFiles or allowPackages rule, remove a conflicting denyFiles rule, or mark this import as external.`,
|
|
223
227
|
{
|
|
224
228
|
code: 'IMPORT_NOT_ALLOWED',
|
|
225
229
|
},
|
|
@@ -228,10 +232,10 @@ function resolveImportDependency(
|
|
|
228
232
|
|
|
229
233
|
if (!args.routes.toUrlPathname(identityPath)) {
|
|
230
234
|
throw createAssetServerCompilationError(
|
|
231
|
-
`Import "${url}" in ${importerPath}, resolved to "${identityPath}", is outside all configured
|
|
232
|
-
`Add a matching
|
|
235
|
+
`Import "${url}" in ${importerPath}, resolved to "${identityPath}", is outside all configured mounts. ` +
|
|
236
|
+
`Add a matching mount for this file path, or mark this import as external.`,
|
|
233
237
|
{
|
|
234
|
-
code: '
|
|
238
|
+
code: 'IMPORT_OUTSIDE_MOUNTS',
|
|
235
239
|
},
|
|
236
240
|
)
|
|
237
241
|
}
|
|
@@ -288,8 +292,8 @@ function resolveUrlDependency(
|
|
|
288
292
|
|
|
289
293
|
if (!args.isAllowed(identityPath)) {
|
|
290
294
|
throw createAssetServerCompilationError(
|
|
291
|
-
`URL "${url}" in ${importerPath}, resolved to "${identityPath}", is not allowed by the asset server
|
|
292
|
-
`Add a matching
|
|
295
|
+
`URL "${url}" in ${importerPath}, resolved to "${identityPath}", is not allowed by the asset server access configuration. ` +
|
|
296
|
+
`Add a matching allowFiles or allowPackages rule, or remove a conflicting denyFiles rule.`,
|
|
293
297
|
{
|
|
294
298
|
code: 'URL_NOT_ALLOWED',
|
|
295
299
|
},
|
|
@@ -298,10 +302,10 @@ function resolveUrlDependency(
|
|
|
298
302
|
|
|
299
303
|
if (!args.routes.toUrlPathname(identityPath)) {
|
|
300
304
|
throw createAssetServerCompilationError(
|
|
301
|
-
`URL "${url}" in ${importerPath}, resolved to "${identityPath}", is outside all configured
|
|
302
|
-
`Add a matching
|
|
305
|
+
`URL "${url}" in ${importerPath}, resolved to "${identityPath}", is outside all configured mounts. ` +
|
|
306
|
+
`Add a matching mount for this file path.`,
|
|
303
307
|
{
|
|
304
|
-
code: '
|
|
308
|
+
code: 'URL_OUTSIDE_MOUNTS',
|
|
305
309
|
},
|
|
306
310
|
)
|
|
307
311
|
}
|
|
@@ -99,9 +99,9 @@ export async function transformStyle(
|
|
|
99
99
|
let stableUrlPathname = args.routes.toUrlPathname(record.identityPath)
|
|
100
100
|
if (!stableUrlPathname) {
|
|
101
101
|
throw createAssetServerCompilationError(
|
|
102
|
-
`File ${record.identityPath} is outside all configured
|
|
102
|
+
`File ${record.identityPath} is outside all configured mounts.`,
|
|
103
103
|
{
|
|
104
|
-
code: '
|
|
104
|
+
code: 'FILE_OUTSIDE_MOUNTS',
|
|
105
105
|
},
|
|
106
106
|
)
|
|
107
107
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
interface ImportMetaHot {
|
|
2
|
+
/** Mutable state preserved for this module across accepted updates and passed to dispose handlers. */
|
|
3
|
+
readonly data: Record<string, unknown>
|
|
4
|
+
/** Accepts updates to this module, optionally receiving its newly evaluated namespace. */
|
|
5
|
+
accept(callback?: (module: HotModule) => HotCallbackResult): void
|
|
6
|
+
/** Accepts updates from one dependency, optionally receiving its newly evaluated namespace. */
|
|
7
|
+
accept(dep: string, callback?: (module: HotModule) => HotCallbackResult): void
|
|
8
|
+
/**
|
|
9
|
+
* Accepts updates from multiple dependencies. The callback array preserves `deps` order and
|
|
10
|
+
* contains the updated namespace only at the position of the dependency that changed.
|
|
11
|
+
*/
|
|
12
|
+
accept(
|
|
13
|
+
deps: readonly string[],
|
|
14
|
+
callback?: (modules: Array<HotModule | undefined>) => HotCallbackResult,
|
|
15
|
+
): void
|
|
16
|
+
/** Registers cleanup that runs before this module is re-evaluated or the runtime is disposed. */
|
|
17
|
+
dispose(callback: (data: Record<string, unknown>) => HotCallbackResult): void
|
|
18
|
+
/** Declines the current update and reloads the page if no importing boundary accepts it. */
|
|
19
|
+
invalidate(message?: string): void
|
|
20
|
+
/** Registers a listener for custom events from the browser HMR channel. */
|
|
21
|
+
on(event: string, callback: (data: unknown) => void | Promise<void>): void
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
type HotModule = Readonly<Record<string, unknown>> & {
|
|
25
|
+
readonly [Symbol.toStringTag]: 'Module'
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
type HotCallbackResult = void | Promise<void>
|
|
29
|
+
|
|
30
|
+
declare global {
|
|
31
|
+
interface ImportMeta {
|
|
32
|
+
readonly hot?: ImportMetaHot
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export {}
|