@quilted/rollup 0.2.6 → 0.2.8

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,23 @@
1
1
  # @quilted/rollup
2
2
 
3
+ ## 0.2.8
4
+
5
+ ### Patch Changes
6
+
7
+ - [`8f5849b0`](https://github.com/lemonmade/quilt/commit/8f5849b0f9fae9f817d269ce763461f4d6ce409c) Thanks [@lemonmade](https://github.com/lemonmade)! - Fix incorrect browser support for UC and QQ browsers
8
+
9
+ ## 0.2.7
10
+
11
+ ### Patch Changes
12
+
13
+ - [`6c7371f7`](https://github.com/lemonmade/quilt/commit/6c7371f7a34ce89383adec9501ca31db5ce4d3c7) Thanks [@lemonmade](https://github.com/lemonmade)! - Fix asset references during development
14
+
15
+ - [`807b8e66`](https://github.com/lemonmade/quilt/commit/807b8e6644ef79d00dc631da4633647d119f0cd6) Thanks [@lemonmade](https://github.com/lemonmade)! - Add support for multi-entry modules
16
+
17
+ - [`274e09ea`](https://github.com/lemonmade/quilt/commit/274e09eaf9ecd0626298941a68a9984b6ca6f488) Thanks [@lemonmade](https://github.com/lemonmade)! - Fix monorepo aliases plugin
18
+
19
+ - [`85c21b4f`](https://github.com/lemonmade/quilt/commit/85c21b4f35b1b7949fe445f25b25282f326d4833) Thanks [@lemonmade](https://github.com/lemonmade)! - Clean up internal imports in apps and packages
20
+
3
21
  ## 0.2.6
4
22
 
5
23
  ### Patch Changes
package/build/esm/app.mjs CHANGED
@@ -85,7 +85,8 @@ async function quiltAppBrowserOptions(options = {}) {
85
85
  assetFileNames: `[name]${targetFilenamePart}.[hash].[ext]`,
86
86
  chunkFileNames: `[name]${targetFilenamePart}.[hash].js`,
87
87
  manualChunks: createManualChunksSorter(),
88
- generatedCode
88
+ generatedCode,
89
+ minifyInternalExports: true
89
90
  }
90
91
  };
91
92
  }
@@ -242,7 +243,7 @@ function quiltAppBrowserInput({
242
243
  return {
243
244
  name: "@quilted/app-browser/input",
244
245
  async options(options) {
245
- const finalEntry = normalizeRollupInput(options.input) ?? await sourceForAppBrowser({ entry, root }) ?? MAGIC_MODULE_ENTRY;
246
+ const finalEntry = normalizeRollupInput(options.input) ?? await sourceEntryForAppBrowser({ entry, root }) ?? MAGIC_MODULE_ENTRY;
246
247
  return {
247
248
  ...options,
248
249
  // If we are using the "magic entry", give it an explicit name of `browser`.
@@ -609,7 +610,7 @@ function magicModuleAppAssetManifests() {
609
610
  }
610
611
  });
611
612
  }
612
- async function sourceForAppBrowser({
613
+ async function sourceEntryForAppBrowser({
613
614
  entry,
614
615
  root = process.cwd()
615
616
  }) {
@@ -703,4 +704,4 @@ function createManualChunksSorter() {
703
704
  };
704
705
  }
705
706
 
706
- export { MAGIC_MODULE_APP_COMPONENT, MAGIC_MODULE_BROWSER_ASSETS, MAGIC_MODULE_ENTRY, MAGIC_MODULE_REQUEST_ROUTER, magicModuleAppAssetManifests, magicModuleAppBrowserEntry, magicModuleAppComponent, magicModuleAppRequestRouter, magicModuleAppServerEntry, quiltAppBrowser, quiltAppBrowserInput, quiltAppBrowserOptions, quiltAppOptions, quiltAppServer, quiltAppServerInput, quiltAppServerOptions, sourceForAppBrowser };
707
+ export { MAGIC_MODULE_APP_COMPONENT, MAGIC_MODULE_BROWSER_ASSETS, MAGIC_MODULE_ENTRY, MAGIC_MODULE_REQUEST_ROUTER, magicModuleAppAssetManifests, magicModuleAppBrowserEntry, magicModuleAppComponent, magicModuleAppRequestRouter, magicModuleAppServerEntry, quiltAppBrowser, quiltAppBrowserInput, quiltAppBrowserOptions, quiltAppOptions, quiltAppServer, quiltAppServerInput, quiltAppServerOptions, sourceEntryForAppBrowser };
@@ -42,7 +42,7 @@ async function monorepoPackageAliases({
42
42
  for (const { project: project2, entries } of projectsWithEntries) {
43
43
  const { name } = project2;
44
44
  for (const [entry, source] of Object.entries(entries)) {
45
- const entryName = entry === "." ? name : `${name}/${entry}`;
45
+ const entryName = entry === "." ? name : `${name}/${entry.startsWith("./") ? entry.slice(2) : entry}`;
46
46
  aliases.push({
47
47
  find: new RegExp(`^${entryName}$`),
48
48
  replacement: source
@@ -1,4 +1,4 @@
1
- import { Project } from './shared/project.mjs';
1
+ import { Project, sourceEntriesForProject } from './shared/project.mjs';
2
2
  import { getNodePlugins, removeBuildFiles } from './shared/rollup.mjs';
3
3
  import { getBrowserGroupTargetDetails, rollupGenerateOptionsForBrowsers } from './shared/browserslist.mjs';
4
4
  import { resolveEnvOption } from './features/env.mjs';
@@ -48,8 +48,7 @@ async function quiltModule({
48
48
  tsconfigAliases({ root: project.root }),
49
49
  monorepoPackageAliases({ root: project.root }),
50
50
  esnext({ mode, targets: browserGroup.browsers }),
51
- react(),
52
- removeBuildFiles(["build/assets", "build/reports"], { root: project.root })
51
+ react()
53
52
  ];
54
53
  if (graphql) {
55
54
  const { graphql: graphql2 } = await import('./features/graphql.mjs');
@@ -59,6 +58,13 @@ async function quiltModule({
59
58
  const { minify: minify2 } = await import('rollup-plugin-esbuild');
60
59
  plugins.push(minify2());
61
60
  }
61
+ if (assets?.clean ?? true) {
62
+ plugins.push(
63
+ removeBuildFiles(["build/assets", "build/reports"], {
64
+ root: project.root
65
+ })
66
+ );
67
+ }
62
68
  plugins.push(
63
69
  visualizer({
64
70
  template: "treemap",
@@ -80,27 +86,40 @@ async function quiltModule({
80
86
  assetFileNames: `[name]${targetFilenamePart}${hash === true ? `.[hash]` : ""}.[ext]`,
81
87
  generatedCode: await rollupGenerateOptionsForBrowsers(
82
88
  browserGroup.browsers
83
- )
89
+ ),
90
+ minifyInternalExports: minify
84
91
  }
85
92
  };
86
93
  }
87
94
  async function resolveModuleEntry(entry, project) {
88
95
  if (entry) {
89
- return project.resolve(entry);
96
+ if (typeof entry === "string") {
97
+ const absolutePath = project.resolve(entry);
98
+ return { [project.relative(absolutePath)]: absolutePath };
99
+ } else {
100
+ return Object.fromEntries(
101
+ Object.entries(entry).map(([key, value]) => [
102
+ normalizeEntryName(key),
103
+ project.resolve(value)
104
+ ])
105
+ );
106
+ }
90
107
  }
91
- const { main, exports } = project.packageJSON.raw;
92
- const entryFromPackageJSON = main ?? exports?.["."];
93
- if (entryFromPackageJSON) {
94
- return project.resolve(entryFromPackageJSON);
108
+ const entries = await sourceEntriesForProject(project);
109
+ const entryArray = Object.entries(entries);
110
+ if (entryArray.length > 0) {
111
+ return Object.fromEntries(
112
+ entryArray.map(([key, value]) => [normalizeEntryName(key), value])
113
+ );
95
114
  }
96
- const possibleSourceFiles = await project.glob(
97
- "{index,module,entry,input}.{ts,tsx,mjs,js,jsx}",
98
- {
99
- nodir: true,
100
- absolute: true
101
- }
102
- );
103
- return possibleSourceFiles[0];
115
+ const sourceFile = (await project.glob("{index,module,entry,input}.{ts,tsx,mjs,js,jsx}", {
116
+ nodir: true,
117
+ absolute: true
118
+ }))[0];
119
+ return { [normalizeEntryName(project.relative(sourceFile))]: sourceFile };
120
+ }
121
+ function normalizeEntryName(name) {
122
+ return name === "." ? "index" : name.startsWith("./") ? name.slice(2) : name;
104
123
  }
105
124
 
106
125
  export { quiltModule };
@@ -102,6 +102,7 @@ async function quiltPackageESModules({
102
102
  entryFileNames: `[name].mjs`,
103
103
  assetFileNames: `[name].[ext]`,
104
104
  generatedCode,
105
+ minifyInternalExports: false,
105
106
  // We only want to preserve the original directory structure if there
106
107
  // are actual package entries.
107
108
  ...hasEntries ? {
@@ -118,7 +119,8 @@ async function quiltPackageESModules({
118
119
  assetFileNames: `[name].[ext]`,
119
120
  preserveModules: true,
120
121
  preserveModulesRoot: source.root,
121
- generatedCode
122
+ generatedCode,
123
+ minifyInternalExports: false
122
124
  });
123
125
  }
124
126
  const options = {
@@ -73,8 +73,6 @@ async function targetsSupportModules(targets) {
73
73
  const BROWSESLIST_BROWSER_TO_MDN_BROWSER = /* @__PURE__ */ new Map([
74
74
  ["and_chr", "chrome_android"],
75
75
  ["and_ff", "firefox_android"],
76
- ["and_qq", "qq_android"],
77
- ["and_uc", "uc_android"],
78
76
  ["android", "webview_android"],
79
77
  ["chrome", "chrome"],
80
78
  ["edge", "edge"],
@@ -32,6 +32,9 @@ class Project {
32
32
  resolve(...segments) {
33
33
  return path.resolve(this.root, ...segments);
34
34
  }
35
+ relative(to) {
36
+ return path.relative(this.root, to);
37
+ }
35
38
  glob(pattern, options) {
36
39
  return glob(pattern, {
37
40
  ...options,