@quilted/rollup 0.2.25 → 0.2.27

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/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @quilted/rollup
2
2
 
3
+ ## 0.2.27
4
+
5
+ ### Patch Changes
6
+
7
+ - [`4fac90a`](https://github.com/lemonmade/quilt/commit/4fac90a52b8efff96572b5f2ae93b40eac2fcf34) Thanks [@lemonmade](https://github.com/lemonmade)! - Fix async module import resolution
8
+
9
+ - [`fb45f13`](https://github.com/lemonmade/quilt/commit/fb45f13ef3d4be82f7edde567ed3247931957701) Thanks [@lemonmade](https://github.com/lemonmade)! - Fix usage of magic "env" module
10
+
11
+ ## 0.2.26
12
+
13
+ ### Patch Changes
14
+
15
+ - [`473928a`](https://github.com/lemonmade/quilt/commit/473928a44115f8c27521d66cfe68cc5e213c5a54) Thanks [@lemonmade](https://github.com/lemonmade)! - Update development dependencies
16
+
3
17
  ## 0.2.25
4
18
 
5
19
  ### Patch Changes
package/build/esm/app.mjs CHANGED
@@ -732,8 +732,7 @@ function createManualChunksSorter() {
732
732
  let relativeId;
733
733
  if (id.includes("/node_modules/")) {
734
734
  const moduleInfo = getModuleInfo(id);
735
- if (moduleInfo == null)
736
- return;
735
+ if (moduleInfo == null) return;
737
736
  if (moduleInfo.importers.length > 0 && moduleInfo.importers.every(
738
737
  (importer) => importer.includes("/node_modules/")
739
738
  )) {
@@ -22,8 +22,7 @@ async function writeManifestForBundle(bundle, { file, baseURL, cacheKey, priorit
22
22
  const entryChunk = entries[0];
23
23
  const dependencyMap = /* @__PURE__ */ new Map();
24
24
  for (const output of outputs) {
25
- if (output.type !== "chunk")
26
- continue;
25
+ if (output.type !== "chunk") continue;
27
26
  dependencyMap.set(output.fileName, output.imports);
28
27
  }
29
28
  const assets = [];
@@ -51,14 +50,11 @@ async function writeManifestForBundle(bundle, { file, baseURL, cacheKey, priorit
51
50
  modules: {}
52
51
  };
53
52
  for (const output of outputs) {
54
- if (output.type !== "chunk")
55
- continue;
53
+ if (output.type !== "chunk") continue;
56
54
  const originalModuleId = output.facadeModuleId ?? output.moduleIds[output.moduleIds.length - 1];
57
- if (originalModuleId == null)
58
- continue;
55
+ if (originalModuleId == null) continue;
59
56
  const moduleId = this.getModuleInfo(originalModuleId)?.meta.quilt?.moduleID;
60
- if (moduleId == null)
61
- continue;
57
+ if (moduleId == null) continue;
62
58
  manifest.modules[moduleId] = createAssetsEntry(
63
59
  [...output.imports, output.fileName],
64
60
  { dependencyMap, getAssetId }
@@ -75,8 +71,7 @@ function createAssetsEntry(files, {
75
71
  const scripts = [];
76
72
  const allFiles = /* @__PURE__ */ new Set();
77
73
  const addFile = (file) => {
78
- if (allFiles.has(file))
79
- return;
74
+ if (allFiles.has(file)) return;
80
75
  allFiles.add(file);
81
76
  for (const dependency of dependencyMap.get(file) ?? []) {
82
77
  addFile(dependency);
@@ -25,16 +25,9 @@ function asyncModules({
25
25
  const resolved = await this.resolve(imported, importer, {
26
26
  skipSelf: true
27
27
  });
28
- if (resolved == null)
29
- return null;
28
+ if (resolved == null) return null;
30
29
  return `\0${prefix}${resolved.id}`;
31
30
  },
32
- resolveDynamicImport(specifier) {
33
- if (typeof specifier === "string" && specifier.startsWith(IMPORT_PREFIX)) {
34
- return `\0${specifier}`;
35
- }
36
- return null;
37
- },
38
31
  async load(id) {
39
32
  if (id.startsWith(`\0${MODULE_PREFIX}`)) {
40
33
  const imported = id.replace(`\0${MODULE_PREFIX}`, "");
@@ -92,25 +85,21 @@ function defaultModuleID({ imported }) {
92
85
  async function preloadAsyncAssetsInESMBundle(bundle) {
93
86
  const { parse: parseImports } = await import('es-module-lexer');
94
87
  for (const chunk of Object.values(bundle)) {
95
- if (chunk.type !== "chunk")
96
- continue;
97
- if (chunk.dynamicImports.length === 0)
98
- continue;
88
+ if (chunk.type !== "chunk") continue;
89
+ if (chunk.dynamicImports.length === 0) continue;
99
90
  const { code } = chunk;
100
91
  const newCode = new MagicString(code);
101
92
  const imports = (await parseImports(code))[0];
102
93
  for (const imported of imports) {
103
94
  const { s: start, e: end, ss: importStart, d: dynamicStart } = imported;
104
- if (dynamicStart < 0)
105
- continue;
95
+ if (dynamicStart < 0) continue;
106
96
  const importSource = code.slice(start + 1, end - 1);
107
97
  const dependencies = getDependenciesForImport(
108
98
  importSource,
109
99
  chunk,
110
100
  bundle
111
101
  );
112
- if (dependencies.size === 1)
113
- continue;
102
+ if (dependencies.size === 1) continue;
114
103
  const originalImport = code.slice(importStart, end + 1);
115
104
  newCode.overwrite(
116
105
  importStart,
@@ -123,10 +112,8 @@ async function preloadAsyncAssetsInESMBundle(bundle) {
123
112
  }
124
113
  async function preloadAsyncAssetsInSystemJSBundle(bundle) {
125
114
  for (const chunk of Object.values(bundle)) {
126
- if (chunk.type !== "chunk")
127
- continue;
128
- if (chunk.dynamicImports.length === 0)
129
- continue;
115
+ if (chunk.type !== "chunk") continue;
116
+ if (chunk.dynamicImports.length === 0) continue;
130
117
  const { code } = chunk;
131
118
  const newCode = new MagicString(code);
132
119
  const systemDynamicImportRegex = /\bmodule\.import\(([^)]*)\)/g;
@@ -139,8 +126,7 @@ async function preloadAsyncAssetsInSystemJSBundle(bundle) {
139
126
  chunk,
140
127
  bundle
141
128
  );
142
- if (dependencies.size === 1)
143
- continue;
129
+ if (dependencies.size === 1) continue;
144
130
  newCode.overwrite(
145
131
  match.index,
146
132
  match.index + originalImport.length,
@@ -161,17 +147,13 @@ function getDependenciesForImport(imported, chunk, bundle) {
161
147
  const analyzed = /* @__PURE__ */ new Set();
162
148
  const normalizedFile = posix.join(posix.dirname(originalFilename), imported);
163
149
  const addDependencies = (filename) => {
164
- if (filename === originalFilename)
165
- return;
166
- if (analyzed.has(filename))
167
- return;
150
+ if (filename === originalFilename) return;
151
+ if (analyzed.has(filename)) return;
168
152
  analyzed.add(filename);
169
153
  const chunk2 = bundle[filename];
170
- if (chunk2 == null)
171
- return;
154
+ if (chunk2 == null) return;
172
155
  dependencies.add(chunk2.fileName);
173
- if (chunk2.type !== "chunk")
174
- return;
156
+ if (chunk2.type !== "chunk") return;
175
157
  for (const imported2 of chunk2.imports) {
176
158
  addDependencies(imported2);
177
159
  }
@@ -5,8 +5,7 @@ function css({ minify = true, emit = true, targets }) {
5
5
  return {
6
6
  name: "@quilted/css",
7
7
  async transform(code, id) {
8
- if (!CSS_REGEX.test(id))
9
- return;
8
+ if (!CSS_REGEX.test(id)) return;
10
9
  const { transform, browserslistToTargets } = await import('lightningcss');
11
10
  const transformed = transform({
12
11
  filename: id,
@@ -31,16 +30,14 @@ function css({ minify = true, emit = true, targets }) {
31
30
  };
32
31
  },
33
32
  async renderChunk(_, chunk) {
34
- if (!emit)
35
- return null;
33
+ if (!emit) return null;
36
34
  let chunkCss = "";
37
35
  for (const id of Object.keys(chunk.modules)) {
38
36
  if (CSS_REGEX.test(id) && styles.has(id)) {
39
37
  chunkCss += styles.get(id);
40
38
  }
41
39
  }
42
- if (chunkCss.length === 0)
43
- return null;
40
+ if (chunkCss.length === 0) return null;
44
41
  const code = chunkCss;
45
42
  const fileHandle = this.emitFile({
46
43
  type: "asset",
@@ -33,7 +33,7 @@ function magicModuleEnv({
33
33
  } = {}) {
34
34
  return createMagicModulePlugin({
35
35
  name: "@quilted/magic-module/env",
36
- module: MAGIC_MODULE_ENV,
36
+ module: [MAGIC_MODULE_ENV, "@quilted/quilt/env"],
37
37
  async source() {
38
38
  const inlineEnv = {};
39
39
  if (mode) {
@@ -41,11 +41,9 @@ function magicModuleEnv({
41
41
  }
42
42
  const loadedEnv = await loadEnv.call(this, { mode, dotenv });
43
43
  for (const inlineVariable of inline.sort()) {
44
- if (inlineVariable in inlineEnv)
45
- continue;
44
+ if (inlineVariable in inlineEnv) continue;
46
45
  const value = process.env[inlineVariable] ?? loadedEnv[inlineVariable];
47
- if (value == null)
48
- continue;
46
+ if (value == null) continue;
49
47
  inlineEnv[inlineVariable] = typeof value === "string" && value[0] === '"' && value[value.length - 1] === '"' ? JSON.parse(value) : value;
50
48
  }
51
49
  return multiline`
@@ -107,8 +105,7 @@ async function loadEnv({ root, mode, dotenv }) {
107
105
  })
108
106
  );
109
107
  for (const envFileResult of envFileResults) {
110
- if (envFileResult == null)
111
- continue;
108
+ if (envFileResult == null) continue;
112
109
  Object.assign(env, envFileResult);
113
110
  }
114
111
  }
@@ -121,8 +118,7 @@ function findWorkspaceRoot(start = process.cwd()) {
121
118
  return current;
122
119
  }
123
120
  const next = path.dirname(current);
124
- if (next === current)
125
- return void 0;
121
+ if (next === current) return void 0;
126
122
  current = next;
127
123
  }
128
124
  }
@@ -9,16 +9,14 @@ function graphql({ manifest } = {}) {
9
9
  return {
10
10
  name: "@quilted/graphql",
11
11
  async transform(code, id) {
12
- if (!id.endsWith(".graphql") && !id.endsWith(".gql"))
13
- return null;
12
+ if (!id.endsWith(".graphql") && !id.endsWith(".gql")) return null;
14
13
  const topLevelDefinitions = /* @__PURE__ */ new Set();
15
14
  const loadedDocument = await loadDocument(
16
15
  code,
17
16
  id,
18
17
  this,
19
18
  (document2, level) => {
20
- if (level !== 0)
21
- return;
19
+ if (level !== 0) return;
22
20
  for (const definition of document2.definitions) {
23
21
  if ("name" in definition && definition.name != null) {
24
22
  topLevelDefinitions.add(definition.name.value);
@@ -41,8 +39,7 @@ function graphql({ manifest } = {}) {
41
39
  };
42
40
  },
43
41
  async generateBundle() {
44
- if (!shouldWriteManifest)
45
- return;
42
+ if (!shouldWriteManifest) return;
46
43
  const operations = {};
47
44
  for (const moduleId of this.getModuleIds()) {
48
45
  const operation = this.getModuleInfo(moduleId)?.meta?.quilt?.graphql;
@@ -50,8 +47,7 @@ function graphql({ manifest } = {}) {
50
47
  operations[operation.id] = operation.source;
51
48
  }
52
49
  }
53
- if (Object.keys(operations).length === 0)
54
- return;
50
+ if (Object.keys(operations).length === 0) return;
55
51
  await mkdir(dirname(manifestPath), { recursive: true });
56
52
  await writeFile(manifestPath, JSON.stringify(operations, null, 2));
57
53
  }
@@ -66,8 +62,7 @@ async function loadDocument(code, file, plugin, add, level = 0, seen = /* @__PUR
66
62
  }
67
63
  const resolvedImports = await Promise.all(
68
64
  imports.map(async (imported) => {
69
- if (seen.has(imported))
70
- return;
65
+ if (seen.has(imported)) return;
71
66
  seen.add(imported);
72
67
  const resolvedId = await plugin.resolve(imported, file);
73
68
  if (resolvedId == null) {
@@ -92,8 +87,7 @@ async function loadDocument(code, file, plugin, add, level = 0, seen = /* @__PUR
92
87
  })
93
88
  );
94
89
  for (const importedDocument of resolvedImports) {
95
- if (importedDocument == null)
96
- continue;
90
+ if (importedDocument == null) continue;
97
91
  document.definitions.push(...importedDocument.definitions);
98
92
  }
99
93
  return document;
@@ -10,8 +10,7 @@ async function monorepoPackageAliases({
10
10
  function processProject(project2) {
11
11
  const { dependencies, devDependencies } = project2.packageJSON.raw;
12
12
  for (const pkg of Object.keys({ ...dependencies, ...devDependencies })) {
13
- if (seenDependencies.has(pkg))
14
- continue;
13
+ if (seenDependencies.has(pkg)) continue;
15
14
  seenDependencies.add(pkg);
16
15
  let packageRoot;
17
16
  try {
@@ -22,8 +21,7 @@ async function monorepoPackageAliases({
22
21
  continue;
23
22
  }
24
23
  const packageProject = Project.load(packageRoot);
25
- if (seenProjects.has(packageProject))
26
- continue;
24
+ if (seenProjects.has(packageProject)) continue;
27
25
  seenProjects.add(packageProject);
28
26
  processProject(packageProject);
29
27
  }
@@ -7,8 +7,7 @@ function systemJS({ minify = false } = {}) {
7
7
  return {
8
8
  name: "@quilted/system-js",
9
9
  async renderChunk(code, chunk, options) {
10
- if (options.format !== "system" || !chunk.isEntry)
11
- return null;
10
+ if (options.format !== "system" || !chunk.isEntry) return null;
12
11
  const require = createRequire(import.meta.url);
13
12
  const systemjs = minify ? require.resolve("systemjs/dist/s.min.js") : require.resolve("systemjs/dist/s.js");
14
13
  const fileHandle = this.emitFile({
@@ -9,8 +9,7 @@ async function tsconfigAliases({
9
9
  getTSConfig(root)
10
10
  ]);
11
11
  const tsconfigPaths = tsconfig?.compilerOptions?.paths;
12
- if (tsconfigPaths == null)
13
- return void 0;
12
+ if (tsconfigPaths == null) return void 0;
14
13
  return alias({
15
14
  entries: Object.entries(tsconfigPaths).map(([name, aliases]) => {
16
15
  return {
@@ -23,19 +23,16 @@ function workers({
23
23
  },
24
24
  async resolveId(source, importer) {
25
25
  const context = parseWorkerImport(source);
26
- if (context == null)
27
- return null;
26
+ if (context == null) return null;
28
27
  const resolvedModule = await this.resolve(context.module, importer, {
29
28
  skipSelf: true
30
29
  });
31
- if (resolvedModule == null)
32
- return null;
30
+ if (resolvedModule == null) return null;
33
31
  return serializeWorkerImport({ ...context, module: resolvedModule.id });
34
32
  },
35
33
  async load(id) {
36
34
  const context = parseWorkerImport(id);
37
- if (context == null)
38
- return null;
35
+ if (context == null) return null;
39
36
  const { module } = context;
40
37
  const workerPlugins = [
41
38
  workerMagicModules(),
@@ -98,11 +95,9 @@ function workers({
98
95
  })};`;
99
96
  },
100
97
  generateBundle(_, bundle) {
101
- if (write)
102
- return;
98
+ if (write) return;
103
99
  for (const chunk of workerMap.values()) {
104
- if (chunk.fileName in bundle)
105
- continue;
100
+ if (chunk.fileName in bundle) continue;
106
101
  bundle[chunk.fileName] = chunk;
107
102
  }
108
103
  }
@@ -119,15 +114,13 @@ function workerMagicModules() {
119
114
  },
120
115
  async load(id) {
121
116
  const context = parseWorkerImport(id, ENTRY_PREFIX);
122
- if (context == null)
123
- return null;
117
+ if (context == null) return null;
124
118
  return contentForWorker(context);
125
119
  }
126
120
  };
127
121
  }
128
122
  function parseWorkerImport(id, prefix = PREFIX) {
129
- if (!id.startsWith(prefix))
130
- return void 0;
123
+ if (!id.startsWith(prefix)) return void 0;
131
124
  const [module, searchString] = id.slice(prefix.length).split("?");
132
125
  const searchParams = new URLSearchParams(searchString);
133
126
  const wrapperModule = searchParams.get("module");
@@ -284,8 +284,7 @@ function sourceForEntries(entries, { root }) {
284
284
  let sourceRoot = root;
285
285
  const sourceEntryFiles = Object.values(entries);
286
286
  for (const entry of sourceEntryFiles) {
287
- if (!entry.startsWith(root))
288
- continue;
287
+ if (!entry.startsWith(root)) continue;
289
288
  sourceRoot = path.resolve(
290
289
  root,
291
290
  path.relative(root, entry).split(path.sep)[0] ?? "."
@@ -16,8 +16,7 @@ async function getBrowserGroups({
16
16
  } = {}) {
17
17
  const { default: browserslist } = await import('browserslist');
18
18
  const config = browserslist.findConfig(root);
19
- if (config == null)
20
- return { default: browserslist(["defaults"]) };
19
+ if (config == null) return { default: browserslist(["defaults"]) };
21
20
  const { defaults, ...rest } = config;
22
21
  const browserGroups = {};
23
22
  const groupsWithFullList = Object.entries(rest).map(([name, browsers]) => ({
@@ -41,8 +40,7 @@ async function getBrowserGroupRegularExpressions(groups) {
41
40
  name,
42
41
  browsers: browserslist(browsers)
43
42
  })).sort((first, second) => first.browsers.length - second.browsers.length);
44
- if (groupsWithFullList.length === 0)
45
- return {};
43
+ if (groupsWithFullList.length === 0) return {};
46
44
  const lastGroup = groupsWithFullList.pop();
47
45
  const regexes = {};
48
46
  for (const { name, browsers } of groupsWithFullList) {
@@ -135,21 +133,17 @@ function* mdnBrowserVersions(browsers, semver) {
135
133
  for (const browser of browsers) {
136
134
  const [name, version] = browser.split(" ");
137
135
  const mdnBrowser = BROWSESLIST_BROWSER_TO_MDN_BROWSER.get(name);
138
- if (mdnBrowser == null)
139
- continue;
136
+ if (mdnBrowser == null) continue;
140
137
  const semverVersion = semver.coerce(version);
141
- if (semverVersion == null)
142
- continue;
138
+ if (semverVersion == null) continue;
143
139
  yield { name: mdnBrowser, version: semverVersion };
144
140
  }
145
141
  }
146
142
  function isSupported(supportList, browser, version, semver) {
147
143
  const supportedVersionDetails = supportList[browser];
148
- if (supportedVersionDetails == null)
149
- return false;
144
+ if (supportedVersionDetails == null) return false;
150
145
  const supportedVersion = semver.coerce(supportedVersionDetails.version_added);
151
- if (supportedVersion == null)
152
- return false;
146
+ if (supportedVersion == null) return false;
153
147
  return semver.gte(version, supportedVersion);
154
148
  }
155
149
 
@@ -11,8 +11,10 @@ function createMagicModulePlugin({
11
11
  return {
12
12
  name,
13
13
  async resolveId(id) {
14
- if (id !== module)
14
+ const matches = Array.isArray(module) ? module.some((moduleID) => moduleID === id) : id === module;
15
+ if (!matches) {
15
16
  return null;
17
+ }
16
18
  const resolved = (typeof alias === "function" ? await alias() : alias) ?? virtualModuleAlias;
17
19
  return {
18
20
  id: resolved,
@@ -20,8 +22,7 @@ function createMagicModulePlugin({
20
22
  };
21
23
  },
22
24
  load: getSource ? async function load(source) {
23
- if (source !== virtualModuleAlias)
24
- return null;
25
+ if (source !== virtualModuleAlias) return null;
25
26
  const code = await getSource.call(this);
26
27
  return {
27
28
  code,
@@ -73,8 +73,7 @@ async function sourceEntriesForProject(project) {
73
73
  exports
74
74
  )) {
75
75
  let targetFile = null;
76
- if (exportCondition == null)
77
- continue;
76
+ if (exportCondition == null) continue;
78
77
  if (typeof exportCondition === "string") {
79
78
  targetFile = exportCondition;
80
79
  } else {
@@ -82,8 +81,7 @@ async function sourceEntriesForProject(project) {
82
81
  (condition) => typeof condition === "string" && condition.startsWith("./build/")
83
82
  );
84
83
  }
85
- if (targetFile == null)
86
- continue;
84
+ if (targetFile == null) continue;
87
85
  const sourceFile = await resolveTargetFileAsSource(targetFile, project);
88
86
  entries[exportPath] = sourceFile;
89
87
  }