@quilted/rollup 0.2.38 → 0.2.40

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.
@@ -1,9 +1,12 @@
1
1
  import type { Plugin, PluginContext } from 'rollup';
2
2
  export interface AssetManifestOptions {
3
3
  file: string;
4
- baseURL: string;
4
+ key?: URLSearchParams;
5
+ base: string;
5
6
  priority?: number;
6
- cacheKey?: URLSearchParams;
7
+ moduleID?(details: {
8
+ imported: string;
9
+ }): string;
7
10
  }
8
11
  export declare function assetManifest(manifestOptions: AssetManifestOptions): Plugin;
9
12
  export declare function rawAssets(): Plugin;
@@ -1 +1 @@
1
- {"version":3,"file":"assets.d.ts","sourceRoot":"","sources":["../../../source/features/assets.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAIV,MAAM,EACN,aAAa,EACd,MAAM,QAAQ,CAAC;AAQhB,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,eAAe,CAAC;CAC5B;AAED,wBAAgB,aAAa,CAAC,eAAe,EAAE,oBAAoB,GAAG,MAAM,CAO3E;AAgKD,wBAAgB,SAAS,IAAI,MAAM,CAmBlC;AAED,wBAAgB,YAAY,CAAC,EAC3B,IAAW,EACX,OAAa,EACb,UAA4C,EAC5C,WAAkC,EAClC,aAAsC,GACvC,GAAE;IACD,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;CACnB;;;EA+DL"}
1
+ {"version":3,"file":"assets.d.ts","sourceRoot":"","sources":["../../../source/features/assets.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAIV,MAAM,EACN,aAAa,EACd,MAAM,QAAQ,CAAC;AAKhB,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,eAAe,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,CAAC,OAAO,EAAE;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAC,GAAG,MAAM,CAAC;CAChD;AAED,wBAAgB,aAAa,CAAC,eAAe,EAAE,oBAAoB,GAAG,MAAM,CAO3E;AA2KD,wBAAgB,SAAS,IAAI,MAAM,CAmBlC;AAED,wBAAgB,YAAY,CAAC,EAC3B,IAAW,EACX,OAAa,EACb,UAA4C,EAC5C,WAAkC,EAClC,aAAsC,GACvC,GAAE;IACD,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;CACnB;;;EA+DL"}
@@ -1,4 +1,5 @@
1
1
  import type { Plugin } from 'rollup';
2
+ export declare const IMPORT_PREFIX = "quilt-async-import:";
2
3
  export interface Options {
3
4
  preload?: boolean;
4
5
  baseURL?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"async.d.ts","sourceRoot":"","sources":["../../../source/features/async.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,MAAM,EAA4B,MAAM,QAAQ,CAAC;AAO9D,MAAM,WAAW,OAAO;IACtB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,CAAC,OAAO,EAAE;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAC,GAAG,MAAM,CAAC;CAChD;AAED,wBAAgB,YAAY,CAAC,EAC3B,OAAc,EACd,OAAoB,EACpB,QAAQ,EAAE,WAA6B,GACxC,GAAE,OAAY,GAAG,MAAM,CAiFvB"}
1
+ {"version":3,"file":"async.d.ts","sourceRoot":"","sources":["../../../source/features/async.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,MAAM,EAA4B,MAAM,QAAQ,CAAC;AAK9D,eAAO,MAAM,aAAa,wBAAwB,CAAC;AAEnD,MAAM,WAAW,OAAO;IACtB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,CAAC,OAAO,EAAE;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAC,GAAG,MAAM,CAAC;CAChD;AAED,wBAAgB,YAAY,CAAC,EAC3B,OAAc,EACd,OAAoB,EACpB,QAAQ,EAAE,WAA6B,GACxC,GAAE,OAAY,GAAG,MAAM,CAiFvB"}
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "access": "public",
7
7
  "@quilted/registry": "https://registry.npmjs.org"
8
8
  },
9
- "version": "0.2.38",
9
+ "version": "0.2.40",
10
10
  "engines": {
11
11
  "node": ">=14.0.0"
12
12
  },
@@ -143,7 +143,7 @@
143
143
  "@rollup/plugin-commonjs": "^25.0.5",
144
144
  "@rollup/plugin-json": "^6.0.1",
145
145
  "@rollup/plugin-node-resolve": "^15.2.3",
146
- "@quilted/assets": "^0.1.0",
146
+ "@quilted/assets": "^0.1.3",
147
147
  "@quilted/babel": "^0.2.2",
148
148
  "@quilted/graphql": "^3.3.4",
149
149
  "@types/babel__preset-env": "^7.9.0",
package/source/app.ts CHANGED
@@ -8,7 +8,7 @@ import type {
8
8
  InputPluginOption,
9
9
  GetManualChunk,
10
10
  } from 'rollup';
11
- import type {AssetsBuildManifest} from '@quilted/assets';
11
+ import type {AssetBuildManifest} from '@quilted/assets';
12
12
 
13
13
  import {
14
14
  MAGIC_MODULE_ENTRY,
@@ -614,8 +614,8 @@ export async function quiltAppBrowserPlugins({
614
614
 
615
615
  plugins.push(
616
616
  assetManifest({
617
- baseURL,
618
- cacheKey,
617
+ key: cacheKey,
618
+ base: baseURL,
619
619
  file: path.join(manifestsDirectory, `assets${targetFilenamePart}.json`),
620
620
  priority: assets?.priority,
621
621
  }),
@@ -637,6 +637,8 @@ export function quiltAppBrowserInput({
637
637
  root,
638
638
  entry,
639
639
  }: Pick<AppBrowserOptions, 'root' | 'entry'> = {}) {
640
+ const MODULES_TO_ENTRIES = new Map<string, string>();
641
+
640
642
  return {
641
643
  name: '@quilted/app-browser/input',
642
644
  async options(options) {
@@ -648,6 +650,15 @@ export function quiltAppBrowserInput({
648
650
  typeof finalEntry === 'string' && finalEntry !== MAGIC_MODULE_ENTRY
649
651
  ? path.basename(finalEntry).split('.').slice(0, -1).join('.')
650
652
  : 'browser';
653
+ const additionalEntries = await additionalEntriesForAppBrowser({root});
654
+
655
+ if (typeof finalEntry === 'string') {
656
+ MODULES_TO_ENTRIES.set(finalEntry, '.');
657
+ }
658
+
659
+ for (const [name, entry] of Object.entries(additionalEntries)) {
660
+ MODULES_TO_ENTRIES.set(entry, `./${name}`);
661
+ }
651
662
 
652
663
  return {
653
664
  ...options,
@@ -655,10 +666,24 @@ export function quiltAppBrowserInput({
655
666
  // Otherwise, Rollup will use the file name as the output name.
656
667
  input:
657
668
  typeof finalEntry === 'string'
658
- ? {[finalEntryName]: finalEntry}
659
- : finalEntry,
669
+ ? {...additionalEntries, [finalEntryName]: finalEntry}
670
+ : Array.isArray(finalEntry)
671
+ ? finalEntry
672
+ : {...additionalEntries, ...finalEntry},
660
673
  };
661
674
  },
675
+ resolveId(source, importer, options) {
676
+ const entry = MODULES_TO_ENTRIES.get(source);
677
+ if (entry == null) return null;
678
+
679
+ return this.resolve(source, importer, {...options, skipSelf: true}).then(
680
+ (resolved) => {
681
+ return resolved
682
+ ? {...resolved, meta: {...resolved.meta, quilt: {entry}}}
683
+ : resolved;
684
+ },
685
+ );
686
+ },
662
687
  } satisfies Plugin;
663
688
  }
664
689
 
@@ -1151,17 +1176,6 @@ export function magicModuleAppComponent({
1151
1176
  entry ??
1152
1177
  async function magicModuleApp() {
1153
1178
  const project = Project.load(root);
1154
- const {packageJSON} = project;
1155
-
1156
- if (typeof packageJSON.raw.main === 'string') {
1157
- return project.resolve(packageJSON.raw.main);
1158
- }
1159
-
1160
- const rootEntry = (packageJSON.raw.exports as any)?.['.'];
1161
-
1162
- if (typeof rootEntry === 'string') {
1163
- return project.resolve(rootEntry);
1164
- }
1165
1179
 
1166
1180
  const globbed = await project.glob(
1167
1181
  '{App,app,index}.{ts,tsx,mjs,js,jsx}',
@@ -1183,7 +1197,7 @@ export function magicModuleAppRequestRouter({
1183
1197
  return createMagicModulePlugin({
1184
1198
  name: '@quilted/magic-module/app-request-router',
1185
1199
  module: MAGIC_MODULE_REQUEST_ROUTER,
1186
- alias: () => appServerEntry({entry, root}) as Promise<string>,
1200
+ alias: () => sourceEntryForAppServer({entry, root}) as Promise<string>,
1187
1201
  async source() {
1188
1202
  return multiline`
1189
1203
  import '@quilted/quilt/globals';
@@ -1216,25 +1230,6 @@ export function magicModuleAppRequestRouter({
1216
1230
  });
1217
1231
  }
1218
1232
 
1219
- export async function appServerEntry({
1220
- entry,
1221
- root = process.cwd(),
1222
- }: Pick<AppServerOptions, 'entry' | 'root'> = {}) {
1223
- if (entry) return entry;
1224
-
1225
- const project = Project.load(root);
1226
-
1227
- const globbed = await project.glob(
1228
- '{server,service,backend}.{ts,tsx,mjs,js,jsx}',
1229
- {
1230
- nodir: true,
1231
- absolute: true,
1232
- },
1233
- );
1234
-
1235
- return globbed[0];
1236
- }
1237
-
1238
1233
  export function magicModuleAppBrowserEntry({
1239
1234
  hydrate = true,
1240
1235
  selector = '#app',
@@ -1278,7 +1273,7 @@ export function magicModuleAppAssetManifests() {
1278
1273
  const manifests = await Promise.all(
1279
1274
  manifestFiles.map(
1280
1275
  async (file) =>
1281
- JSON.parse(await fs.readFile(file, 'utf8')) as AssetsBuildManifest,
1276
+ JSON.parse(await fs.readFile(file, 'utf8')) as AssetBuildManifest,
1282
1277
  ),
1283
1278
  );
1284
1279
 
@@ -1345,6 +1340,39 @@ export async function sourceEntryForAppBrowser({
1345
1340
  if (entry) {
1346
1341
  return project.resolve(entry);
1347
1342
  } else {
1343
+ const {packageJSON} = project;
1344
+
1345
+ // If we have a `main` or `browser` field in our `package.json`, use that
1346
+ // as the browser entry.
1347
+ if (typeof packageJSON.raw.main === 'string') {
1348
+ return project.resolve(packageJSON.raw.main);
1349
+ }
1350
+
1351
+ if (typeof packageJSON.raw.browser === 'string') {
1352
+ return project.resolve(packageJSON.raw.browser);
1353
+ }
1354
+
1355
+ // Try `package.json` `exports` field, if it’s a string or an object with export conditions
1356
+ let currentEntry = packageJSON.raw.exports as any;
1357
+ let resolvedEntryFromExports = resolveExportsField(
1358
+ project,
1359
+ currentEntry,
1360
+ BROWSER_EXPORT_CONDITIONS,
1361
+ );
1362
+
1363
+ if (resolvedEntryFromExports) return resolvedEntryFromExports;
1364
+
1365
+ // Then, try `exports[.]`, if it’s a string or an object with export conditions
1366
+ currentEntry = currentEntry?.['.'];
1367
+ resolvedEntryFromExports = resolveExportsField(
1368
+ project,
1369
+ currentEntry,
1370
+ BROWSER_EXPORT_CONDITIONS,
1371
+ );
1372
+
1373
+ if (resolvedEntryFromExports) return resolvedEntryFromExports;
1374
+
1375
+ // If we don’t have an entry yet, try the default file names
1348
1376
  const files = await project.glob(
1349
1377
  '{browser,client,web}.{ts,tsx,mjs,js,jsx}',
1350
1378
  {
@@ -1357,6 +1385,72 @@ export async function sourceEntryForAppBrowser({
1357
1385
  }
1358
1386
  }
1359
1387
 
1388
+ const BROWSER_EXPORT_CONDITIONS = new Set([
1389
+ 'browser',
1390
+ 'source',
1391
+ 'quilt:source',
1392
+ 'default',
1393
+ ]);
1394
+ const SERVER_EXPORT_CONDITIONS = new Set([
1395
+ 'server',
1396
+ 'source',
1397
+ 'quilt:source',
1398
+ 'default',
1399
+ ]);
1400
+
1401
+ async function additionalEntriesForAppBrowser({
1402
+ root = process.cwd(),
1403
+ }: {
1404
+ root?: string | URL;
1405
+ }) {
1406
+ const additionalEntries: Record<string, string> = {};
1407
+
1408
+ const project = Project.load(root);
1409
+ const exports = project.packageJSON.raw.exports as any;
1410
+
1411
+ if (typeof exports === 'object' && exports != null) {
1412
+ for (const [key, value] of Object.entries(exports)) {
1413
+ // skip anything other than entries
1414
+ if (!key.startsWith('.')) continue;
1415
+
1416
+ // Skip the `.` key, since it’s not an additional entry
1417
+ if (key === '.') continue;
1418
+
1419
+ const resolvedEntry = resolveExportsField(
1420
+ project,
1421
+ value as any,
1422
+ BROWSER_EXPORT_CONDITIONS,
1423
+ );
1424
+
1425
+ if (resolvedEntry) {
1426
+ additionalEntries[key.slice(2)] = resolvedEntry;
1427
+ }
1428
+ }
1429
+ }
1430
+
1431
+ return additionalEntries;
1432
+ }
1433
+
1434
+ function resolveExportsField(
1435
+ project: Project,
1436
+ entry:
1437
+ | string
1438
+ | null
1439
+ | undefined
1440
+ | Record<string, string | null | undefined | Record<string, unknown>>,
1441
+ conditions: Set<string>,
1442
+ ) {
1443
+ if (typeof entry === 'string') {
1444
+ return project.resolve(entry);
1445
+ } else if (typeof entry === 'object' && entry != null) {
1446
+ for (const [condition, value] of Object.entries(entry)) {
1447
+ if (conditions.has(condition) && typeof value === 'string') {
1448
+ return project.resolve(value);
1449
+ }
1450
+ }
1451
+ }
1452
+ }
1453
+
1360
1454
  export async function sourceEntryForAppServer({
1361
1455
  entry,
1362
1456
  root = process.cwd(),
@@ -1368,7 +1462,21 @@ export async function sourceEntryForAppServer({
1368
1462
 
1369
1463
  if (entry) {
1370
1464
  return project.resolve(entry);
1371
- } else {
1465
+ }
1466
+ {
1467
+ const {packageJSON} = project;
1468
+
1469
+ // Try `package.json` `exports` field, if it has a `server` condition or a `.`
1470
+ // enrty with a `server` condition
1471
+ const exports = packageJSON.raw.exports as any;
1472
+
1473
+ const resolvedFromRootServerEntry = resolveExportsField(
1474
+ project,
1475
+ exports?.['server'] ?? exports?.['.']?.['server'],
1476
+ SERVER_EXPORT_CONDITIONS,
1477
+ );
1478
+ if (resolvedFromRootServerEntry) return resolvedFromRootServerEntry;
1479
+
1372
1480
  const files = await project.glob(
1373
1481
  '{server,service,backend}.{ts,tsx,mjs,js,jsx}',
1374
1482
  {
@@ -11,16 +11,14 @@ import type {
11
11
  } from 'rollup';
12
12
  import * as mime from 'mrmime';
13
13
 
14
- import type {
15
- AssetsBuildManifest,
16
- AssetsBuildManifestEntry,
17
- } from '@quilted/assets';
14
+ import type {AssetBuildManifest, AssetBuildAsset} from '@quilted/assets';
18
15
 
19
16
  export interface AssetManifestOptions {
20
17
  file: string;
21
- baseURL: string;
18
+ key?: URLSearchParams;
19
+ base: string;
22
20
  priority?: number;
23
- cacheKey?: URLSearchParams;
21
+ moduleID?(details: {imported: string}): string;
24
22
  }
25
23
 
26
24
  export function assetManifest(manifestOptions: AssetManifestOptions): Plugin {
@@ -35,7 +33,13 @@ export function assetManifest(manifestOptions: AssetManifestOptions): Plugin {
35
33
  async function writeManifestForBundle(
36
34
  this: PluginContext,
37
35
  bundle: OutputBundle,
38
- {file, baseURL, cacheKey, priority}: AssetManifestOptions,
36
+ {
37
+ file,
38
+ base,
39
+ key,
40
+ priority,
41
+ moduleID: getModuleID = defaultModuleID,
42
+ }: AssetManifestOptions,
39
43
  {format}: NormalizedOutputOptions,
40
44
  ) {
41
45
  const outputs = Object.values(bundle);
@@ -49,11 +53,6 @@ async function writeManifestForBundle(
49
53
  throw new Error(`Could not find any entries in your rollup bundle...`);
50
54
  }
51
55
 
52
- // We assume the first entry is the "main" one. There can be
53
- // more than one because each worker script is also listed as an
54
- // entry (though, from a separate build).
55
- const entryChunk = entries[0]!;
56
-
57
56
  const dependencyMap = new Map<string, string[]>();
58
57
 
59
58
  for (const output of outputs) {
@@ -61,14 +60,14 @@ async function writeManifestForBundle(
61
60
  dependencyMap.set(output.fileName, output.imports);
62
61
  }
63
62
 
64
- const assets: string[] = [];
63
+ const assets: AssetBuildAsset[] = [];
65
64
  const assetIdMap = new Map<string, number>();
66
65
 
67
66
  function getAssetId(file: string) {
68
67
  let id = assetIdMap.get(file);
69
68
 
70
69
  if (id == null) {
71
- assets.push(`${baseURL}${file}`);
70
+ assets.push([file.endsWith('.css') ? 1 : 2, file]);
72
71
  id = assets.length - 1;
73
72
  assetIdMap.set(file, id);
74
73
  }
@@ -76,34 +75,41 @@ async function writeManifestForBundle(
76
75
  return id;
77
76
  }
78
77
 
79
- const manifest: AssetsBuildManifest = {
78
+ const manifest: AssetBuildManifest = {
79
+ key: key && key.size > 0 ? key.toString() : undefined,
80
+ base,
80
81
  priority,
81
- cacheKey: cacheKey && cacheKey.size > 0 ? cacheKey.toString() : undefined,
82
82
  assets,
83
- attributes: format === 'es' ? {scripts: {type: 'module'}} : undefined,
84
- entries: {
85
- default: createAssetsEntry([...entryChunk.imports, entryChunk.fileName], {
86
- dependencyMap,
87
- getAssetId,
88
- }),
89
- },
83
+ attributes: format === 'es' ? {2: {type: 'module'}} : undefined,
84
+ entries: {} as any,
90
85
  modules: {},
91
86
  };
92
87
 
93
88
  for (const output of outputs) {
94
- if (output.type !== 'chunk') continue;
89
+ if (
90
+ output.type !== 'chunk' ||
91
+ (!output.isDynamicEntry && !output.isEntry)
92
+ ) {
93
+ continue;
94
+ }
95
95
 
96
- const originalModuleId =
97
- output.facadeModuleId ?? output.moduleIds[output.moduleIds.length - 1];
96
+ const rollupModuleID = output.facadeModuleId ?? output.moduleIds.at(-1);
98
97
 
99
- if (originalModuleId == null) continue;
98
+ if (rollupModuleID == null) continue;
100
99
 
101
- // This metadata is added by the rollup plugin for @quilted/async
102
- const moduleId = this.getModuleInfo(originalModuleId)?.meta.quilt?.moduleID;
100
+ const moduleInfo = this.getModuleInfo(rollupModuleID);
101
+ const imported = moduleInfo?.meta?.quilt?.module ?? rollupModuleID;
103
102
 
104
- if (moduleId == null) continue;
103
+ const moduleID = getModuleID({imported: imported});
105
104
 
106
- manifest.modules[moduleId] = createAssetsEntry(
105
+ if (moduleID == null) continue;
106
+
107
+ if (output.isEntry) {
108
+ const entry = moduleInfo?.meta?.quilt?.entry ?? moduleID;
109
+ manifest.entries[entry] = moduleID;
110
+ }
111
+
112
+ manifest.modules[moduleID] = createAssetsEntry(
107
113
  [...output.imports, output.fileName],
108
114
  {dependencyMap, getAssetId},
109
115
  );
@@ -113,6 +119,14 @@ async function writeManifestForBundle(
113
119
  await fs.writeFile(file, JSON.stringify(manifest, null, 2));
114
120
  }
115
121
 
122
+ function defaultModuleID({imported}: {imported: string}) {
123
+ return imported.startsWith('/')
124
+ ? path.relative(process.cwd(), imported)
125
+ : imported.startsWith('\0')
126
+ ? imported.replace('\0', '')
127
+ : imported;
128
+ }
129
+
116
130
  function createAssetsEntry(
117
131
  files: string[],
118
132
  {
@@ -122,9 +136,8 @@ function createAssetsEntry(
122
136
  dependencyMap: Map<string, string[]>;
123
137
  getAssetId(file: string): number;
124
138
  },
125
- ): AssetsBuildManifestEntry {
126
- const styles: number[] = [];
127
- const scripts: number[] = [];
139
+ ) {
140
+ const assets: number[] = [];
128
141
 
129
142
  const allFiles = new Set<string>();
130
143
  const addFile = (file: string) => {
@@ -141,14 +154,10 @@ function createAssetsEntry(
141
154
  }
142
155
 
143
156
  for (const file of allFiles) {
144
- if (file.endsWith('.css')) {
145
- styles.push(getAssetId(file));
146
- } else {
147
- scripts.push(getAssetId(file));
148
- }
157
+ assets.push(getAssetId(file));
149
158
  }
150
159
 
151
- return {scripts, styles};
160
+ return assets;
152
161
  }
153
162
 
154
163
  const QUERY_PATTERN = /\?.*$/s;
@@ -1,12 +1,11 @@
1
- import {createHash} from 'crypto';
2
- import {posix, sep} from 'path';
1
+ import * as path from 'path';
3
2
 
4
3
  import type {Plugin, OutputChunk, OutputBundle} from 'rollup';
5
4
  import {multiline} from '../shared/strings.ts';
6
5
  import MagicString from 'magic-string';
7
6
 
8
7
  const MODULE_PREFIX = 'quilt-async-module:';
9
- const IMPORT_PREFIX = 'quilt-async-import:';
8
+ export const IMPORT_PREFIX = 'quilt-async-import:';
10
9
 
11
10
  export interface Options {
12
11
  preload?: boolean;
@@ -73,7 +72,7 @@ export function asyncModules({
73
72
  return {
74
73
  code,
75
74
  meta: {
76
- quilt: {moduleID},
75
+ quilt: {module: imported, moduleID},
77
76
  },
78
77
  };
79
78
  }
@@ -102,14 +101,7 @@ export function asyncModules({
102
101
  }
103
102
 
104
103
  function defaultModuleID({imported}: {imported: string}) {
105
- const name = imported.split(sep).pop()!.split('.')[0]!;
106
-
107
- const hash = createHash('sha256')
108
- .update(imported)
109
- .digest('hex')
110
- .substring(0, 8);
111
-
112
- return `${name}_${hash}`;
104
+ return path.relative(process.cwd(), imported).replace(/[\\/]/g, '-');
113
105
  }
114
106
 
115
107
  async function preloadAsyncAssetsInESMBundle(bundle: OutputBundle) {
@@ -213,7 +205,10 @@ function getDependenciesForImport(
213
205
  const dependencies = new Set<string>();
214
206
  const analyzed = new Set<string>();
215
207
 
216
- const normalizedFile = posix.join(posix.dirname(originalFilename), imported);
208
+ const normalizedFile = path.posix.join(
209
+ path.posix.dirname(originalFilename),
210
+ imported,
211
+ );
217
212
 
218
213
  const addDependencies = (filename: string) => {
219
214
  if (filename === originalFilename) return;