@quilted/rollup 0.1.4 → 0.1.6

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.
Files changed (66) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/build/cjs/app.cjs +160 -142
  3. package/build/cjs/features/assets.cjs +130 -0
  4. package/build/cjs/features/css.cjs +71 -0
  5. package/build/cjs/{env.cjs → features/env.cjs} +4 -4
  6. package/build/cjs/{request-router.cjs → features/request-router.cjs} +3 -3
  7. package/build/cjs/{shared → features}/source-code.cjs +7 -2
  8. package/build/cjs/features/system-js.cjs +35 -0
  9. package/build/cjs/index.cjs +0 -7
  10. package/build/cjs/shared/rollup.cjs +0 -4
  11. package/build/esm/app.mjs +162 -144
  12. package/build/esm/features/assets.mjs +107 -0
  13. package/build/esm/features/css.mjs +69 -0
  14. package/build/esm/{env.mjs → features/env.mjs} +4 -4
  15. package/build/esm/{request-router.mjs → features/request-router.mjs} +3 -3
  16. package/build/esm/{shared → features}/source-code.mjs +6 -1
  17. package/build/esm/features/system-js.mjs +33 -0
  18. package/build/esm/index.mjs +1 -3
  19. package/build/esm/shared/rollup.mjs +1 -4
  20. package/build/esnext/app.esnext +162 -144
  21. package/build/esnext/features/assets.esnext +107 -0
  22. package/build/esnext/features/css.esnext +69 -0
  23. package/build/esnext/{env.esnext → features/env.esnext} +4 -4
  24. package/build/esnext/{request-router.esnext → features/request-router.esnext} +3 -3
  25. package/build/esnext/{shared → features}/source-code.esnext +6 -1
  26. package/build/esnext/features/system-js.esnext +33 -0
  27. package/build/esnext/index.esnext +1 -3
  28. package/build/esnext/shared/rollup.esnext +1 -4
  29. package/build/tsconfig.tsbuildinfo +1 -1
  30. package/build/typescript/app.d.ts +33 -144
  31. package/build/typescript/app.d.ts.map +1 -1
  32. package/build/typescript/features/assets.d.ts +13 -0
  33. package/build/typescript/features/assets.d.ts.map +1 -0
  34. package/build/typescript/features/css.d.ts +16 -0
  35. package/build/typescript/features/css.d.ts.map +1 -0
  36. package/build/typescript/features/env.d.ts +57 -0
  37. package/build/typescript/features/env.d.ts.map +1 -0
  38. package/build/typescript/features/graphql/transform.d.ts +17 -0
  39. package/build/typescript/features/graphql/transform.d.ts.map +1 -0
  40. package/build/typescript/features/graphql.d.ts +6 -0
  41. package/build/typescript/features/graphql.d.ts.map +1 -0
  42. package/build/typescript/features/request-router.d.ts +15 -0
  43. package/build/typescript/features/request-router.d.ts.map +1 -0
  44. package/build/typescript/features/source-code.d.ts +5 -0
  45. package/build/typescript/features/source-code.d.ts.map +1 -0
  46. package/build/typescript/features/system-js.d.ts +7 -0
  47. package/build/typescript/features/system-js.d.ts.map +1 -0
  48. package/build/typescript/index.d.ts +1 -3
  49. package/build/typescript/index.d.ts.map +1 -1
  50. package/package.json +5 -2
  51. package/source/app.ts +184 -122
  52. package/source/features/assets.ts +183 -0
  53. package/source/features/css.ts +91 -0
  54. package/source/{env.ts → features/env.ts} +4 -4
  55. package/source/{request-router.ts → features/request-router.ts} +3 -3
  56. package/source/{shared → features}/source-code.ts +3 -0
  57. package/source/features/system-js.ts +36 -0
  58. package/source/index.ts +0 -5
  59. /package/build/cjs/{graphql → features/graphql}/transform.cjs +0 -0
  60. /package/build/cjs/{graphql.cjs → features/graphql.cjs} +0 -0
  61. /package/build/esm/{graphql → features/graphql}/transform.mjs +0 -0
  62. /package/build/esm/{graphql.mjs → features/graphql.mjs} +0 -0
  63. /package/build/esnext/{graphql → features/graphql}/transform.esnext +0 -0
  64. /package/build/esnext/{graphql.esnext → features/graphql.esnext} +0 -0
  65. /package/source/{graphql → features/graphql}/transform.ts +0 -0
  66. /package/source/{graphql.ts → features/graphql.ts} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @quilted/rollup
2
2
 
3
+ ## 0.1.6
4
+
5
+ ### Patch Changes
6
+
7
+ - [`a2615aa0`](https://github.com/lemonmade/quilt/commit/a2615aa06a3cd146111996c8401466c5d8b9be09) Thanks [@lemonmade](https://github.com/lemonmade)! - Default to GraphQL in app server
8
+
9
+ - [`2a0b85fe`](https://github.com/lemonmade/quilt/commit/2a0b85fe4a2d07ce107e52a3f246728c7c38fbf2) Thanks [@lemonmade](https://github.com/lemonmade)! - Add CSS plugin to app
10
+
11
+ - [`a2615aa0`](https://github.com/lemonmade/quilt/commit/a2615aa06a3cd146111996c8401466c5d8b9be09) Thanks [@lemonmade](https://github.com/lemonmade)! - Remove 'use client' warnings
12
+
13
+ ## 0.1.5
14
+
15
+ ### Patch Changes
16
+
17
+ - [`3b3db683`](https://github.com/lemonmade/quilt/commit/3b3db6833608df10274f6335182164856c19cbdc) Thanks [@lemonmade](https://github.com/lemonmade)! - Switch to a config generator function
18
+
19
+ - [`97583dc1`](https://github.com/lemonmade/quilt/commit/97583dc12973cc7e378ffcd9815ecc098f3ecbeb) Thanks [@lemonmade](https://github.com/lemonmade)! - Add CSS plugin
20
+
3
21
  ## 0.1.4
4
22
 
5
23
  ### Patch Changes
package/build/cjs/app.cjs CHANGED
@@ -25,169 +25,187 @@ function _interopNamespaceDefault(e) {
25
25
 
26
26
  var path__namespace = /*#__PURE__*/_interopNamespaceDefault(path);
27
27
 
28
- function quiltAppBrowser({
28
+ async function quiltAppBrowser({
29
29
  app,
30
+ entry = constants.MAGIC_MODULE_ENTRY,
30
31
  env,
31
32
  assets,
32
33
  module,
33
34
  graphql = true
34
35
  } = {}) {
35
36
  const mode = (typeof env === 'object' ? env?.mode : undefined) ?? 'production';
36
- return {
37
- name: '@quilted/app/browser',
38
- async options(originalOptions) {
39
- const newPlugins = rollup.rollupPluginsToArray(originalOptions.plugins);
40
- const newOptions = {
41
- ...originalOptions,
42
- plugins: newPlugins
43
- };
44
- const [{
45
- visualizer
46
- }, {
47
- sourceCode
48
- }, nodePlugins] = await Promise.all([import('rollup-plugin-visualizer'), Promise.resolve().then(function () { return require('./shared/source-code.cjs'); }), rollup.getNodePlugins()]);
49
- newPlugins.push(...nodePlugins);
50
- newPlugins.push(sourceCode({
37
+ const minify = assets?.minify ?? mode === 'production';
38
+ const [{
39
+ visualizer
40
+ }, {
41
+ sourceCode
42
+ }, {
43
+ css
44
+ }, {
45
+ rawAssets,
46
+ staticAssets
47
+ }, {
48
+ systemJS
49
+ }, nodePlugins] = await Promise.all([import('rollup-plugin-visualizer'), Promise.resolve().then(function () { return require('./features/source-code.cjs'); }), Promise.resolve().then(function () { return require('./features/css.cjs'); }), Promise.resolve().then(function () { return require('./features/assets.cjs'); }), Promise.resolve().then(function () { return require('./features/system-js.cjs'); }), rollup.getNodePlugins()]);
50
+ const plugins = [...nodePlugins, systemJS(), sourceCode({
51
+ mode
52
+ }), css({
53
+ minify
54
+ }), rawAssets(), staticAssets()];
55
+ if (env) {
56
+ const {
57
+ magicModuleEnv,
58
+ replaceProcessEnv
59
+ } = await Promise.resolve().then(function () { return require('./features/env.cjs'); });
60
+ if (typeof env === 'boolean') {
61
+ plugins.push(replaceProcessEnv({
51
62
  mode
52
63
  }));
53
- if (env) {
54
- const {
55
- magicModuleEnv,
56
- replaceProcessEnv
57
- } = await Promise.resolve().then(function () { return require('./env.cjs'); });
58
- if (typeof env === 'boolean') {
59
- newPlugins.push(replaceProcessEnv({
60
- mode: 'production'
61
- }));
62
- newPlugins.push(magicModuleEnv({
63
- mode: 'production'
64
- }));
65
- } else {
66
- newPlugins.push(replaceProcessEnv({
67
- mode: env.mode ?? 'production'
68
- }));
69
- newPlugins.push(magicModuleEnv({
70
- mode: 'production',
71
- ...env
72
- }));
73
- }
74
- }
75
- if (app) {
76
- newPlugins.push(magicModuleAppComponent({
77
- entry: app
78
- }));
79
- }
80
- newPlugins.push(magicModuleAppBrowserEntry(module));
81
- if (graphql) {
82
- const {
83
- graphql
84
- } = await Promise.resolve().then(function () { return require('./graphql.cjs'); });
85
- newPlugins.push(graphql({
86
- manifest: path__namespace.resolve(`manifests/graphql.json`)
87
- }));
88
- }
89
- const minify = assets?.minify ?? true;
90
- if (minify) {
91
- const {
92
- minify
93
- } = await import('rollup-plugin-esbuild');
94
- newPlugins.push(minify());
95
- }
96
- newPlugins.push(visualizer({
97
- template: 'treemap',
98
- open: false,
99
- brotliSize: true,
100
- filename: path__namespace.resolve(`reports/bundle-visualizer.html`)
64
+ plugins.push(magicModuleEnv({
65
+ mode
66
+ }));
67
+ } else {
68
+ plugins.push(replaceProcessEnv({
69
+ mode
70
+ }));
71
+ plugins.push(magicModuleEnv({
72
+ mode
101
73
  }));
102
- return newOptions;
74
+ }
75
+ }
76
+ if (app) {
77
+ plugins.push(magicModuleAppComponent({
78
+ entry: app
79
+ }));
80
+ }
81
+ plugins.push(magicModuleAppBrowserEntry(module));
82
+ if (graphql) {
83
+ const {
84
+ graphql
85
+ } = await Promise.resolve().then(function () { return require('./features/graphql.cjs'); });
86
+ plugins.push(graphql({
87
+ manifest: path__namespace.resolve(`manifests/graphql.json`)
88
+ }));
89
+ }
90
+ if (minify) {
91
+ const {
92
+ minify
93
+ } = await import('rollup-plugin-esbuild');
94
+ plugins.push(minify());
95
+ }
96
+ plugins.push(visualizer({
97
+ template: 'treemap',
98
+ open: false,
99
+ brotliSize: true,
100
+ filename: path__namespace.resolve(`reports/bundle-visualizer.html`)
101
+ }));
102
+ return {
103
+ input: entry,
104
+ plugins,
105
+ onwarn(warning, defaultWarn) {
106
+ // Removes annoying warnings for React-focused libraries that
107
+ // include 'use client' directives.
108
+ if (warning.code === 'MODULE_LEVEL_DIRECTIVE' && /['"]use client['"]/.test(warning.message)) {
109
+ return;
110
+ }
111
+ defaultWarn(warning);
103
112
  },
104
- outputOptions(originalOptions) {
105
- return {
106
- ...originalOptions,
107
- // format: isESM ? 'esm' : 'systemjs',
108
- format: 'esm',
109
- dir: path__namespace.resolve(`build/assets`),
110
- entryFileNames: `app.[hash].js`,
111
- assetFileNames: `[name].[hash].[ext]`,
112
- chunkFileNames: `[name].[hash].js`,
113
- manualChunks: createManualChunksSorter()
114
- };
113
+ output: {
114
+ // format: isESM ? 'esm' : 'systemjs',
115
+ format: 'esm',
116
+ dir: path__namespace.resolve(`build/assets`),
117
+ entryFileNames: `app.[hash].js`,
118
+ assetFileNames: `[name].[hash].[ext]`,
119
+ chunkFileNames: `[name].[hash].js`,
120
+ manualChunks: createManualChunksSorter()
115
121
  }
116
122
  };
117
123
  }
118
- function quiltAppServer({
124
+ async function quiltAppServer({
119
125
  app,
120
126
  env,
121
- graphql,
122
- entry
127
+ graphql = true,
128
+ entry = constants.MAGIC_MODULE_ENTRY,
129
+ minify = false
123
130
  } = {}) {
124
131
  const mode = (typeof env === 'object' ? env?.mode : undefined) ?? 'production';
125
- return {
126
- name: '@quilted/app/server',
127
- async options(originalOptions) {
128
- const newPlugins = rollup.rollupPluginsToArray(originalOptions.plugins);
129
- const newOptions = {
130
- ...originalOptions,
131
- plugins: newPlugins
132
- };
133
- const [{
134
- magicModuleRequestRouterEntry
135
- }, {
136
- sourceCode
137
- }, nodePlugins] = await Promise.all([Promise.resolve().then(function () { return require('./request-router.cjs'); }), Promise.resolve().then(function () { return require('./shared/source-code.cjs'); }), rollup.getNodePlugins()]);
138
- newPlugins.push(...nodePlugins);
139
- newPlugins.push(sourceCode({
132
+ const [{
133
+ visualizer
134
+ }, {
135
+ sourceCode
136
+ }, {
137
+ css
138
+ }, {
139
+ rawAssets,
140
+ staticAssets
141
+ }, {
142
+ magicModuleRequestRouterEntry
143
+ }, nodePlugins] = await Promise.all([import('rollup-plugin-visualizer'), Promise.resolve().then(function () { return require('./features/source-code.cjs'); }), Promise.resolve().then(function () { return require('./features/css.cjs'); }), Promise.resolve().then(function () { return require('./features/assets.cjs'); }), Promise.resolve().then(function () { return require('./features/request-router.cjs'); }), rollup.getNodePlugins()]);
144
+ const plugins = [...nodePlugins, sourceCode({
145
+ mode
146
+ }), css({
147
+ emit: false
148
+ }), rawAssets(), staticAssets({
149
+ emit: false
150
+ })];
151
+ if (env) {
152
+ const {
153
+ magicModuleEnv,
154
+ replaceProcessEnv
155
+ } = await Promise.resolve().then(function () { return require('./features/env.cjs'); });
156
+ if (typeof env === 'boolean') {
157
+ plugins.push(replaceProcessEnv({
140
158
  mode
141
159
  }));
142
- if (env) {
143
- const {
144
- magicModuleEnv,
145
- replaceProcessEnv
146
- } = await Promise.resolve().then(function () { return require('./env.cjs'); });
147
- if (typeof env === 'boolean') {
148
- newPlugins.push(replaceProcessEnv({
149
- mode
150
- }));
151
- newPlugins.push(magicModuleEnv({
152
- mode
153
- }));
154
- } else {
155
- newPlugins.push(replaceProcessEnv({
156
- mode
157
- }));
158
- newPlugins.push(magicModuleEnv({
159
- mode,
160
- ...env
161
- }));
162
- }
163
- }
164
- if (app) {
165
- newPlugins.push(magicModuleAppComponent({
166
- entry: app
167
- }));
168
- }
169
- newPlugins.push(magicModuleRequestRouterEntry());
170
- newPlugins.push(magicModuleAppRequestRouter({
171
- entry
160
+ plugins.push(magicModuleEnv({
161
+ mode
172
162
  }));
173
- if (graphql) {
174
- const {
175
- graphql
176
- } = await Promise.resolve().then(function () { return require('./graphql.cjs'); });
177
- newPlugins.push(graphql({
178
- manifest: false
179
- }));
180
- }
181
- return newOptions;
182
- },
183
- outputOptions(originalOptions) {
184
- return {
185
- ...originalOptions,
186
- // format,
187
- format: 'esm',
188
- dir: path__namespace.resolve(`build/server`),
189
- entryFileNames: 'server.js'
190
- };
163
+ } else {
164
+ plugins.push(replaceProcessEnv({
165
+ mode
166
+ }));
167
+ plugins.push(magicModuleEnv({
168
+ mode
169
+ }));
170
+ }
171
+ }
172
+ if (app) {
173
+ plugins.push(magicModuleAppComponent({
174
+ entry: app
175
+ }));
176
+ }
177
+ plugins.push(magicModuleRequestRouterEntry());
178
+ plugins.push(magicModuleAppRequestRouter({
179
+ entry
180
+ }));
181
+ if (graphql) {
182
+ const {
183
+ graphql
184
+ } = await Promise.resolve().then(function () { return require('./features/graphql.cjs'); });
185
+ plugins.push(graphql({
186
+ manifest: false
187
+ }));
188
+ }
189
+ if (minify) {
190
+ const {
191
+ minify
192
+ } = await import('rollup-plugin-esbuild');
193
+ plugins.push(minify());
194
+ }
195
+ plugins.push(visualizer({
196
+ template: 'treemap',
197
+ open: false,
198
+ brotliSize: true,
199
+ filename: path__namespace.resolve(`reports/bundle-visualizer.html`)
200
+ }));
201
+ return {
202
+ input: entry,
203
+ plugins,
204
+ output: {
205
+ // format: isESM ? 'esm' : 'systemjs',
206
+ format: 'esm',
207
+ dir: path__namespace.resolve(`build/server`),
208
+ entryFileNames: 'server.js'
191
209
  }
192
210
  };
193
211
  }
@@ -0,0 +1,130 @@
1
+ 'use strict';
2
+
3
+ var path = require('node:path');
4
+ var promises = require('node:fs/promises');
5
+ var node_crypto = require('node:crypto');
6
+ var mime = require('mrmime');
7
+
8
+ function _interopNamespaceDefault(e) {
9
+ var n = Object.create(null);
10
+ if (e) {
11
+ Object.keys(e).forEach(function (k) {
12
+ if (k !== 'default') {
13
+ var d = Object.getOwnPropertyDescriptor(e, k);
14
+ Object.defineProperty(n, k, d.get ? d : {
15
+ enumerable: true,
16
+ get: function () { return e[k]; }
17
+ });
18
+ }
19
+ });
20
+ }
21
+ n["default"] = e;
22
+ return Object.freeze(n);
23
+ }
24
+
25
+ var path__namespace = /*#__PURE__*/_interopNamespaceDefault(path);
26
+ var mime__namespace = /*#__PURE__*/_interopNamespaceDefault(mime);
27
+
28
+ const QUERY_PATTERN = /\?.*$/s;
29
+ const HASH_PATTERN = /#.*$/s;
30
+ const RAW_PATTERN = /(\?|&)raw(?:&|$)/;
31
+ const DEFAULT_INLINE_LIMIT = 4096;
32
+ const DEFAULT_OUTPUT_PATTERN = '[name].[hash].[ext]';
33
+ const DEFAULT_STATIC_ASSET_EXTENSIONS = [
34
+ // images
35
+ '.png', '.jpg', '.jpeg', '.gif', '.svg', '.ico', '.webp', '.avif',
36
+ // media
37
+ '.mp4', '.webm', '.ogg', '.mp3', '.wav', '.flac', '.aac',
38
+ // fonts
39
+ '.woff', '.woff2', '.eot', '.ttf', '.otf',
40
+ // other
41
+ '.webmanifest', '.pdf', '.txt'];
42
+ function rawAssets() {
43
+ return {
44
+ name: '@quilted/raw-assets',
45
+ async load(id) {
46
+ if (id.startsWith('\0') || !RAW_PATTERN.test(id)) {
47
+ return null;
48
+ }
49
+ const moduleId = cleanModuleIdentifier(id);
50
+ this.addWatchFile(moduleId);
51
+ const file = await promises.readFile(moduleId, {
52
+ encoding: 'utf-8'
53
+ });
54
+ return `export default ${JSON.stringify(file)}`;
55
+ }
56
+ };
57
+ }
58
+ function staticAssets({
59
+ emit = true,
60
+ baseURL = '/',
61
+ extensions = DEFAULT_STATIC_ASSET_EXTENSIONS,
62
+ inlineLimit = DEFAULT_INLINE_LIMIT,
63
+ outputPattern = DEFAULT_OUTPUT_PATTERN
64
+ } = {}) {
65
+ const assetCache = new Map();
66
+ const assetMatcher = new RegExp(`\\.(` + extensions.map(extension => extension.startsWith('.') ? extension.slice(1) : extension).join('|') + `)(\\?.*)?$`);
67
+ return {
68
+ name: '@quilted/static-assets',
69
+ async load(id) {
70
+ if (id.startsWith('\0') || !assetMatcher.test(id)) {
71
+ return null;
72
+ }
73
+ const cached = assetCache.get(id);
74
+ if (cached) {
75
+ return cached;
76
+ }
77
+ const file = cleanModuleIdentifier(id);
78
+ const content = await promises.readFile(file);
79
+ let url;
80
+ if (!file.endsWith('.svg') && content.length < inlineLimit) {
81
+ // base64 inlined as a string
82
+ url = `data:${mime__namespace.lookup(file)};base64,${content.toString('base64')}`;
83
+ } else {
84
+ const contentHash = getHash(content);
85
+ const filename = assetFileNamesToFileName(outputPattern, file, contentHash);
86
+ url = `${baseURL.endsWith('/') ? baseURL.slice(0, -1) : baseURL}/${filename}`;
87
+ if (emit) {
88
+ this.emitFile({
89
+ name: file,
90
+ type: 'asset',
91
+ fileName: filename,
92
+ source: content
93
+ });
94
+ }
95
+ }
96
+ const source = `export default ${JSON.stringify(url)};`;
97
+ assetCache.set(id, source);
98
+ return source;
99
+ }
100
+ };
101
+ }
102
+ function assetFileNamesToFileName(pattern, file, contentHash) {
103
+ const basename = path__namespace.basename(file);
104
+ const extname = path__namespace.extname(basename);
105
+ const ext = extname.substring(1);
106
+ const name = basename.slice(0, -extname.length);
107
+ const hash = contentHash;
108
+ return pattern.replace(/\[\w+\]/g, placeholder => {
109
+ switch (placeholder) {
110
+ case '[ext]':
111
+ return ext;
112
+ case '[extname]':
113
+ return extname;
114
+ case '[hash]':
115
+ return hash;
116
+ case '[name]':
117
+ return name;
118
+ }
119
+ throw new Error(`invalid placeholder ${placeholder} in assetFileNames "${pattern}"`);
120
+ });
121
+ }
122
+ function getHash(text) {
123
+ return node_crypto.createHash('sha256').update(text).digest('hex').substring(0, 8);
124
+ }
125
+ function cleanModuleIdentifier(url) {
126
+ return url.replace(HASH_PATTERN, '').replace(QUERY_PATTERN, '');
127
+ }
128
+
129
+ exports.rawAssets = rawAssets;
130
+ exports.staticAssets = staticAssets;
@@ -0,0 +1,71 @@
1
+ 'use strict';
2
+
3
+ const CSS_REGEX = /\.css$/;
4
+ const CSS_MODULE_REGEX = /\.module\.css$/;
5
+ function css({
6
+ minify = true,
7
+ emit = true
8
+ }) {
9
+ const styles = new Map();
10
+ return {
11
+ name: '@quilted/css',
12
+ async transform(code, id) {
13
+ if (!CSS_REGEX.test(id)) return;
14
+ const {
15
+ transform
16
+ } = await import('lightningcss');
17
+ const transformed = transform({
18
+ filename: id,
19
+ code: new TextEncoder().encode(code),
20
+ cssModules: CSS_MODULE_REGEX.test(id),
21
+ minify: emit && minify
22
+ });
23
+ styles.set(id, new TextDecoder().decode(transformed.code));
24
+ const exports = transformed.exports ? Object.fromEntries(Object.entries(transformed.exports).map(([key, exported]) => [key, exported.name])) : undefined;
25
+ return {
26
+ code: exports ? `export default JSON.parse(${JSON.stringify(JSON.stringify(exports))})` : `export default undefined;`,
27
+ map: {
28
+ mappings: ''
29
+ },
30
+ moduleSideEffects: 'no-treeshake'
31
+ };
32
+ },
33
+ async renderChunk(_, chunk) {
34
+ if (!emit) return null;
35
+ let chunkCss = '';
36
+ for (const id of Object.keys(chunk.modules)) {
37
+ if (CSS_REGEX.test(id) && styles.has(id)) {
38
+ chunkCss += styles.get(id);
39
+ }
40
+ }
41
+ if (chunkCss.length === 0) return null;
42
+ const code = chunkCss;
43
+
44
+ // if (minify) {
45
+ // const {default: CleanCSS} = await import('clean-css');
46
+
47
+ // const cleaner = new CleanCSS({
48
+ // rebase: false,
49
+ // });
50
+
51
+ // const minified = cleaner.minify(chunkCss);
52
+
53
+ // if (minified.errors.length > 0) {
54
+ // throw minified.errors[0];
55
+ // }
56
+
57
+ // code = minified.styles;
58
+ // }
59
+
60
+ const fileHandle = this.emitFile({
61
+ type: 'asset',
62
+ name: `${chunk.fileName.split('.')[0]}.css`,
63
+ source: code
64
+ });
65
+ chunk.imports.push(this.getFileName(fileHandle));
66
+ return null;
67
+ }
68
+ };
69
+ }
70
+
71
+ exports.css = css;
@@ -2,10 +2,10 @@
2
2
 
3
3
  var path = require('node:path');
4
4
  var fs = require('node:fs');
5
- var constants = require('./constants.cjs');
6
- var strings = require('./shared/strings.cjs');
7
- var rollup = require('./shared/rollup.cjs');
8
- var magicModule = require('./shared/magic-module.cjs');
5
+ var constants = require('../constants.cjs');
6
+ var strings = require('../shared/strings.cjs');
7
+ var rollup = require('../shared/rollup.cjs');
8
+ var magicModule = require('../shared/magic-module.cjs');
9
9
 
10
10
  function _interopNamespaceDefault(e) {
11
11
  var n = Object.create(null);
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var constants = require('./constants.cjs');
4
- var magicModule = require('./shared/magic-module.cjs');
5
- var strings = require('./shared/strings.cjs');
3
+ var constants = require('../constants.cjs');
4
+ var magicModule = require('../shared/magic-module.cjs');
5
+ var strings = require('../shared/strings.cjs');
6
6
 
7
7
  function magicModuleRequestRouterEntry({
8
8
  host,
@@ -3,12 +3,13 @@
3
3
  var node_module = require('node:module');
4
4
  var babel = require('@rollup/plugin-babel');
5
5
 
6
- const require$1 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (document.currentScript && document.currentScript.src || new URL('shared/source-code.cjs', document.baseURI).href)));
6
+ const require$1 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (document.currentScript && document.currentScript.src || new URL('features/source-code.cjs', document.baseURI).href)));
7
7
  function sourceCode({
8
8
  mode,
9
9
  targets
10
10
  }) {
11
11
  return babel({
12
+ envName: mode,
12
13
  configFile: false,
13
14
  babelrc: false,
14
15
  presets: [require$1.resolve('@babel/preset-typescript'), [require$1.resolve('@babel/preset-react'), {
@@ -33,7 +34,11 @@ function sourceCode({
33
34
  extensions: ['.ts', '.tsx', '.mts', '.mtsx', '.js', '.jsx', '.es6', '.es', '.mjs'],
34
35
  exclude: 'node_modules/**',
35
36
  babelHelpers: 'bundled',
36
- skipPreflightCheck: true
37
+ skipPreflightCheck: true,
38
+ // Babel doesn’t like this option being set to `undefined`.
39
+ ...(targets ? {
40
+ targets
41
+ } : {})
37
42
  });
38
43
  }
39
44
 
@@ -0,0 +1,35 @@
1
+ 'use strict';
2
+
3
+ var promises = require('node:fs/promises');
4
+ var node_module = require('node:module');
5
+
6
+ function systemJS({
7
+ minify = false
8
+ } = {}) {
9
+ return {
10
+ name: '@quilted/system-js',
11
+ async renderChunk(_, chunk, options) {
12
+ if (options.format !== 'system' || !chunk.isEntry) return null;
13
+ const require$1 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (document.currentScript && document.currentScript.src || new URL('features/system-js.cjs', document.baseURI).href)));
14
+ const systemjs = minify ? require$1.resolve('systemjs/dist/s.min.js') : require$1.resolve('systemjs/dist/s.js');
15
+
16
+ // We write the systemjs loader to a dedicated file, and we make it the
17
+ // "first import" of the chunk so that it is the first file listed in
18
+ // the manifest.
19
+ const fileHandle = this.emitFile({
20
+ type: 'asset',
21
+ name: 'loader.js',
22
+ source: (await promises.readFile(systemjs, {
23
+ encoding: 'utf8'
24
+ })).replace(
25
+ // Remove the source map comment, if it is present, because we don’t upload the
26
+ // sourcemap for this file.
27
+ /\n?[/][/]# sourceMappingURL=s.*\.map\n?$/, '')
28
+ });
29
+ chunk.imports.unshift(this.getFileName(fileHandle));
30
+ return null;
31
+ }
32
+ };
33
+ }
34
+
35
+ exports.systemJS = systemJS;
@@ -1,15 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var env = require('./env.cjs');
4
3
  var app = require('./app.cjs');
5
- var requestRouter = require('./request-router.cjs');
6
4
 
7
5
 
8
6
 
9
- exports.magicModuleEnv = env.magicModuleEnv;
10
- exports.magicModuleAppBrowserEntry = app.magicModuleAppBrowserEntry;
11
- exports.magicModuleAppComponent = app.magicModuleAppComponent;
12
- exports.magicModuleAppRequestRouter = app.magicModuleAppRequestRouter;
13
7
  exports.quiltAppBrowser = app.quiltAppBrowser;
14
8
  exports.quiltAppServer = app.quiltAppServer;
15
- exports.magicModuleRequestRouterEntry = requestRouter.magicModuleRequestRouterEntry;
@@ -28,10 +28,6 @@ async function getNodePlugins() {
28
28
  // exportConditions,
29
29
  }), commonjs(), json()];
30
30
  }
31
- function rollupPluginsToArray(plugins) {
32
- return Array.isArray(plugins) ? [...plugins] : plugins ? [plugins] : [];
33
- }
34
31
 
35
32
  exports.getNodePlugins = getNodePlugins;
36
- exports.rollupPluginsToArray = rollupPluginsToArray;
37
33
  exports.smartReplace = smartReplace;