@quilted/rollup 0.1.19 → 0.2.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.
Files changed (126) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/build/esm/app.mjs +443 -219
  3. package/build/esm/constants.mjs +5 -5
  4. package/build/esm/features/assets.mjs +93 -81
  5. package/build/esm/features/async.mjs +186 -0
  6. package/build/esm/features/css.mjs +26 -39
  7. package/build/esm/features/env.mjs +47 -44
  8. package/build/esm/features/esnext.mjs +57 -0
  9. package/build/esm/features/graphql/transform.mjs +60 -56
  10. package/build/esm/features/graphql.mjs +65 -47
  11. package/build/esm/features/request-router.mjs +6 -4
  12. package/build/esm/features/source-code.mjs +54 -28
  13. package/build/esm/features/system-js.mjs +13 -18
  14. package/build/esm/features/typescript.mjs +13 -10
  15. package/build/esm/features/workers.mjs +173 -0
  16. package/build/esm/index.mjs +3 -2
  17. package/build/esm/module.mjs +69 -62
  18. package/build/esm/package.mjs +275 -84
  19. package/build/esm/server.mjs +118 -0
  20. package/build/esm/shared/browserslist.mjs +141 -16
  21. package/build/esm/shared/magic-module.mjs +9 -7
  22. package/build/esm/shared/package-json.mjs +7 -1
  23. package/build/esm/shared/path.mjs +7 -0
  24. package/build/esm/shared/rollup.mjs +89 -25
  25. package/build/esm/shared/strings.mjs +7 -6
  26. package/build/tsconfig.tsbuildinfo +1 -1
  27. package/build/typescript/app.d.ts +126 -27
  28. package/build/typescript/app.d.ts.map +1 -1
  29. package/build/typescript/features/assets.d.ts +1 -2
  30. package/build/typescript/features/assets.d.ts.map +1 -1
  31. package/build/typescript/features/async.d.ts +10 -0
  32. package/build/typescript/features/async.d.ts.map +1 -0
  33. package/build/typescript/features/css.d.ts +2 -1
  34. package/build/typescript/features/css.d.ts.map +1 -1
  35. package/build/typescript/features/env.d.ts +1 -0
  36. package/build/typescript/features/env.d.ts.map +1 -1
  37. package/build/typescript/features/esnext.d.ts +9 -0
  38. package/build/typescript/features/esnext.d.ts.map +1 -0
  39. package/build/typescript/features/graphql.d.ts +2 -2
  40. package/build/typescript/features/graphql.d.ts.map +1 -1
  41. package/build/typescript/features/source-code.d.ts +9 -3
  42. package/build/typescript/features/source-code.d.ts.map +1 -1
  43. package/build/typescript/features/workers.d.ts +52 -0
  44. package/build/typescript/features/workers.d.ts.map +1 -0
  45. package/build/typescript/index.d.ts +3 -2
  46. package/build/typescript/index.d.ts.map +1 -1
  47. package/build/typescript/module.d.ts +24 -6
  48. package/build/typescript/module.d.ts.map +1 -1
  49. package/build/typescript/package.d.ts +196 -4
  50. package/build/typescript/package.d.ts.map +1 -1
  51. package/build/typescript/server.d.ts +98 -0
  52. package/build/typescript/server.d.ts.map +1 -0
  53. package/build/typescript/shared/browserslist.d.ts +20 -3
  54. package/build/typescript/shared/browserslist.d.ts.map +1 -1
  55. package/build/typescript/shared/path.d.ts +2 -0
  56. package/build/typescript/shared/path.d.ts.map +1 -0
  57. package/build/typescript/shared/rollup.d.ts +27 -1
  58. package/build/typescript/shared/rollup.d.ts.map +1 -1
  59. package/configuration/rollup.config.js +40 -0
  60. package/package.json +61 -8
  61. package/source/app.ts +466 -96
  62. package/source/features/assets.ts +5 -7
  63. package/source/features/async.ts +249 -0
  64. package/source/features/css.ts +4 -2
  65. package/source/features/env.ts +6 -0
  66. package/source/features/esnext.ts +70 -0
  67. package/source/features/graphql.ts +4 -2
  68. package/source/features/source-code.ts +26 -8
  69. package/source/features/workers.ts +292 -0
  70. package/source/index.ts +4 -0
  71. package/source/module.ts +45 -19
  72. package/source/package.ts +394 -36
  73. package/source/server.ts +245 -0
  74. package/source/shared/browserslist.ts +208 -18
  75. package/source/shared/path.ts +5 -0
  76. package/source/shared/rollup.ts +102 -4
  77. package/tsconfig.json +6 -2
  78. package/build/cjs/app.cjs +0 -441
  79. package/build/cjs/constants.cjs +0 -13
  80. package/build/cjs/features/assets.cjs +0 -240
  81. package/build/cjs/features/css.cjs +0 -71
  82. package/build/cjs/features/env.cjs +0 -135
  83. package/build/cjs/features/graphql/transform.cjs +0 -186
  84. package/build/cjs/features/graphql.cjs +0 -86
  85. package/build/cjs/features/request-router.cjs +0 -31
  86. package/build/cjs/features/source-code.cjs +0 -54
  87. package/build/cjs/features/system-js.cjs +0 -36
  88. package/build/cjs/features/typescript.cjs +0 -56
  89. package/build/cjs/index.cjs +0 -13
  90. package/build/cjs/module.cjs +0 -121
  91. package/build/cjs/package.cjs +0 -170
  92. package/build/cjs/shared/browserslist.cjs +0 -25
  93. package/build/cjs/shared/magic-module.cjs +0 -32
  94. package/build/cjs/shared/package-json.cjs +0 -31
  95. package/build/cjs/shared/rollup.cjs +0 -72
  96. package/build/cjs/shared/strings.cjs +0 -16
  97. package/build/esnext/app.esnext +0 -414
  98. package/build/esnext/constants.esnext +0 -7
  99. package/build/esnext/features/assets.esnext +0 -215
  100. package/build/esnext/features/css.esnext +0 -69
  101. package/build/esnext/features/env.esnext +0 -112
  102. package/build/esnext/features/graphql/transform.esnext +0 -181
  103. package/build/esnext/features/graphql.esnext +0 -84
  104. package/build/esnext/features/request-router.esnext +0 -29
  105. package/build/esnext/features/source-code.esnext +0 -51
  106. package/build/esnext/features/system-js.esnext +0 -33
  107. package/build/esnext/features/typescript.esnext +0 -34
  108. package/build/esnext/index.esnext +0 -3
  109. package/build/esnext/module.esnext +0 -100
  110. package/build/esnext/package.esnext +0 -148
  111. package/build/esnext/shared/browserslist.esnext +0 -23
  112. package/build/esnext/shared/magic-module.esnext +0 -30
  113. package/build/esnext/shared/package-json.esnext +0 -10
  114. package/build/esnext/shared/rollup.esnext +0 -49
  115. package/build/esnext/shared/strings.esnext +0 -14
  116. package/build/typescript/env.d.ts +0 -55
  117. package/build/typescript/env.d.ts.map +0 -1
  118. package/build/typescript/graphql/transform.d.ts +0 -17
  119. package/build/typescript/graphql/transform.d.ts.map +0 -1
  120. package/build/typescript/graphql.d.ts +0 -6
  121. package/build/typescript/graphql.d.ts.map +0 -1
  122. package/build/typescript/request-router.d.ts +0 -15
  123. package/build/typescript/request-router.d.ts.map +0 -1
  124. package/build/typescript/shared/source-code.d.ts +0 -5
  125. package/build/typescript/shared/source-code.d.ts.map +0 -1
  126. package/quilt.project.ts +0 -5
@@ -1,71 +0,0 @@
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;
@@ -1,135 +0,0 @@
1
- 'use strict';
2
-
3
- var path = require('node:path');
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');
9
-
10
- function _interopNamespaceDefault(e) {
11
- var n = Object.create(null);
12
- if (e) {
13
- Object.keys(e).forEach(function (k) {
14
- if (k !== 'default') {
15
- var d = Object.getOwnPropertyDescriptor(e, k);
16
- Object.defineProperty(n, k, d.get ? d : {
17
- enumerable: true,
18
- get: function () { return e[k]; }
19
- });
20
- }
21
- });
22
- }
23
- n["default"] = e;
24
- return Object.freeze(n);
25
- }
26
-
27
- var path__namespace = /*#__PURE__*/_interopNamespaceDefault(path);
28
- var fs__namespace = /*#__PURE__*/_interopNamespaceDefault(fs);
29
-
30
- const EMPTY_PROCESS_ENV_OBJECT = {
31
- 'globalThis.process.env.': `({}).`,
32
- 'global.process.env.': `({}).`,
33
- 'process.env.': `({}).`
34
- };
35
- function replaceProcessEnv({
36
- mode,
37
- preserve = true
38
- }) {
39
- return rollup.smartReplace({
40
- // @see https://github.com/vitejs/vite/blob/2b1ffe86328f9d06ef9528ee117b61889893ddcc/packages/vite/src/node/plugins/define.ts#L112
41
- 'globalThis.process.env.NODE_ENV': JSON.stringify(mode),
42
- 'global.process.env.NODE_ENV': JSON.stringify(mode),
43
- 'process.env.NODE_ENV': JSON.stringify(mode),
44
- ...(preserve ? {} : EMPTY_PROCESS_ENV_OBJECT)
45
- });
46
- }
47
- function magicModuleEnv({
48
- mode,
49
- dotenv = {
50
- roots: ['.', 'configuration']
51
- },
52
- inline = [],
53
- runtime = '{}'
54
- } = {}) {
55
- return magicModule.createMagicModulePlugin({
56
- name: '@quilted/magic-module/env',
57
- module: constants.MAGIC_MODULE_ENV,
58
- async source() {
59
- const inlineEnv = {};
60
- if (mode) {
61
- inlineEnv.MODE = mode;
62
- }
63
- const loadedEnv = await loadEnv.call(this, {
64
- mode,
65
- dotenv
66
- });
67
- for (const inlineVariable of inline.sort()) {
68
- if (inlineVariable in inlineEnv) continue;
69
- const value = process.env[inlineVariable] ?? loadedEnv[inlineVariable];
70
- if (value == null) continue;
71
- inlineEnv[inlineVariable] = typeof value === 'string' && value[0] === '"' && value[value.length - 1] === '"' ? JSON.parse(value) : value;
72
- }
73
- return strings.multiline`
74
- const runtime = (${runtime});
75
- const inline = JSON.parse(${JSON.stringify(JSON.stringify(inlineEnv))});
76
-
77
- const Env = new Proxy(
78
- {},
79
- {
80
- get(_, property) {
81
- return runtime[property] ?? inline[property];
82
- },
83
- },
84
- );
85
-
86
- export default Env;
87
- `;
88
- }
89
- });
90
- }
91
-
92
- // Inspired by https://github.com/vitejs/vite/blob/e0a4d810598d1834933ed437ac5a2168cbbbf2f8/packages/vite/source/node/config.ts#L1050-L1113
93
- async function loadEnv({
94
- mode,
95
- dotenv
96
- }) {
97
- const env = {
98
- ...process.env
99
- };
100
- if (dotenv !== false) {
101
- const {
102
- parse
103
- } = await import('dotenv');
104
- let files = dotenv.files;
105
- if (files == null) {
106
- const testFiles = [
107
- // default file
108
- `.env`,
109
- // local file
110
- `.env.local`];
111
- if (mode) {
112
- testFiles.push(
113
- // mode file
114
- `.env.${mode}`,
115
- // mode local file
116
- `.env.${mode}.local`);
117
- }
118
- files = testFiles.flatMap(file => (dotenv.roots ?? ['.', 'configuration']).map(root => path__namespace.resolve(root, file)));
119
- }
120
- const envFileResults = await Promise.all(files.map(async file => {
121
- if (fs__namespace.existsSync(file)) {
122
- this.addWatchFile(file);
123
- return parse(await fs__namespace.promises.readFile(file, 'utf-8'));
124
- }
125
- }));
126
- for (const envFileResult of envFileResults) {
127
- if (envFileResult == null) continue;
128
- Object.assign(env, envFileResult);
129
- }
130
- }
131
- return env;
132
- }
133
-
134
- exports.magicModuleEnv = magicModuleEnv;
135
- exports.replaceProcessEnv = replaceProcessEnv;
@@ -1,186 +0,0 @@
1
- 'use strict';
2
-
3
- var node_crypto = require('node:crypto');
4
- var graphql = require('graphql');
5
-
6
- const IMPORT_REGEX = /^#import\s+['"]([^'"]*)['"];?[\s\n]*/gm;
7
- const DEFAULT_NAME = 'Operation';
8
- function cleanGraphQLDocument(document, {
9
- removeUnused = true
10
- } = {}) {
11
- if (removeUnused) {
12
- removeUnusedDefinitions(document, {
13
- exclude: removeUnused === true ? new Set() : removeUnused.exclude
14
- });
15
- }
16
- for (const definition of document.definitions) {
17
- addTypename(definition);
18
- }
19
- const normalizedSource = minifyGraphQLSource(graphql.print(document));
20
- const normalizedDocument = graphql.parse(normalizedSource);
21
- for (const definition of normalizedDocument.definitions) {
22
- stripLoc(definition);
23
- }
24
-
25
- // This ID is a hash of the full file contents that are part of the document,
26
- // including other documents that are injected in, but excluding any unused
27
- // fragments. This is useful for things like persisted queries.
28
- const id = node_crypto.createHash('sha256').update(normalizedSource).digest('hex');
29
- Reflect.defineProperty(normalizedDocument, 'id', {
30
- value: id,
31
- enumerable: true,
32
- writable: false,
33
- configurable: false
34
- });
35
- Reflect.defineProperty(normalizedDocument, 'loc', {
36
- value: stripDocumentLoc(normalizedDocument.loc),
37
- enumerable: true,
38
- writable: false,
39
- configurable: false
40
- });
41
- return normalizedDocument;
42
- }
43
- function extractGraphQLImports(rawSource) {
44
- const imports = new Set();
45
- const source = rawSource.replace(IMPORT_REGEX, (_, imported) => {
46
- imports.add(imported);
47
- return '';
48
- });
49
- return {
50
- imports: [...imports],
51
- source
52
- };
53
- }
54
- function toGraphQLOperation(documentOrSource) {
55
- const document = typeof documentOrSource === 'string' ? cleanGraphQLDocument(graphql.parse(documentOrSource)) : documentOrSource;
56
- return {
57
- id: document.id,
58
- name: operationNameForDocument(document),
59
- source: document.loc.source.body
60
- };
61
- }
62
- function operationNameForDocument(document) {
63
- return document.definitions.find(definition => definition.kind === 'OperationDefinition')?.name?.value;
64
- }
65
- function removeUnusedDefinitions(document, {
66
- exclude
67
- }) {
68
- const usedDefinitions = new Set();
69
- const dependencies = definitionDependencies(document.definitions);
70
- const markAsUsed = definition => {
71
- if (usedDefinitions.has(definition)) {
72
- return;
73
- }
74
- usedDefinitions.add(definition);
75
- for (const dependency of dependencies.get(definition) || []) {
76
- markAsUsed(dependency);
77
- }
78
- };
79
- for (const definition of document.definitions) {
80
- if (definition.kind === 'FragmentDefinition') {
81
- if (exclude.has(definition.name.value)) {
82
- markAsUsed(definition);
83
- }
84
- } else {
85
- markAsUsed(definition);
86
- }
87
- }
88
- document.definitions = [...usedDefinitions];
89
- }
90
- function definitionDependencies(definitions) {
91
- const executableDefinitions = definitions.filter(definition => definition.kind === 'OperationDefinition' || definition.kind === 'FragmentDefinition');
92
- const definitionsByName = new Map(executableDefinitions.map(definition => [definition.name ? definition.name.value : DEFAULT_NAME, definition]));
93
- return new Map(executableDefinitions.map(executableNode => [executableNode, [...collectUsedFragmentSpreads(executableNode, new Set())].map(usedFragment => {
94
- const definition = definitionsByName.get(usedFragment);
95
- if (definition == null) {
96
- throw new Error(`You attempted to use the fragment '${usedFragment}' (in '${executableNode.name ? executableNode.name.value : DEFAULT_NAME}'), but it does not exist. Maybe you forgot to import it from another document?`);
97
- }
98
- return definition;
99
- })]));
100
- }
101
- const TYPENAME_FIELD = {
102
- kind: 'Field',
103
- alias: null,
104
- name: {
105
- kind: 'Name',
106
- value: '__typename'
107
- }
108
- };
109
- function addTypename(definition) {
110
- for (const {
111
- selections
112
- } of selectionSetsForDefinition(definition)) {
113
- const hasTypename = selections.some(selection => selection.kind === 'Field' && selection.name.value === '__typename');
114
- if (!hasTypename) {
115
- selections.push(TYPENAME_FIELD);
116
- }
117
- }
118
- }
119
- function collectUsedFragmentSpreads(definition, usedSpreads) {
120
- for (const selection of selectionsForDefinition(definition)) {
121
- if (selection.kind === 'FragmentSpread') {
122
- usedSpreads.add(selection.name.value);
123
- }
124
- }
125
- return usedSpreads;
126
- }
127
- function selectionsForDefinition(definition) {
128
- if (!('selectionSet' in definition) || definition.selectionSet == null) {
129
- return [][Symbol.iterator]();
130
- }
131
- return selectionsForSelectionSet(definition.selectionSet);
132
- }
133
- function* selectionSetsForDefinition(definition) {
134
- if (!('selectionSet' in definition) || definition.selectionSet == null) {
135
- return [][Symbol.iterator]();
136
- }
137
- if (definition.kind !== 'OperationDefinition') {
138
- yield definition.selectionSet;
139
- }
140
- for (const nestedSelection of selectionsForDefinition(definition)) {
141
- if ('selectionSet' in nestedSelection && nestedSelection.selectionSet != null) {
142
- yield nestedSelection.selectionSet;
143
- }
144
- }
145
- }
146
- function* selectionsForSelectionSet({
147
- selections
148
- }) {
149
- for (const selection of selections) {
150
- yield selection;
151
- if ('selectionSet' in selection && selection.selectionSet != null) {
152
- yield* selectionsForSelectionSet(selection.selectionSet);
153
- }
154
- }
155
- }
156
- function stripDocumentLoc(loc) {
157
- const normalizedLoc = {
158
- ...loc
159
- };
160
- delete normalizedLoc.endToken;
161
- delete normalizedLoc.startToken;
162
- return normalizedLoc;
163
- }
164
- function stripLoc(value) {
165
- if (Array.isArray(value)) {
166
- value.forEach(stripLoc);
167
- } else if (typeof value === 'object') {
168
- if (value == null) {
169
- return;
170
- }
171
- if ('loc' in value) {
172
- delete value.loc;
173
- }
174
- for (const key of Object.keys(value)) {
175
- stripLoc(value[key]);
176
- }
177
- }
178
- }
179
- function minifyGraphQLSource(source) {
180
- return source.replace(/#.*/g, '').replace(/\\n/g, ' ').replace(/\s\s+/g, ' ').replace(/\s*({|}|\(|\)|\.|:|,)\s*/g, '$1');
181
- }
182
-
183
- exports.cleanGraphQLDocument = cleanGraphQLDocument;
184
- exports.extractGraphQLImports = extractGraphQLImports;
185
- exports.minifyGraphQLSource = minifyGraphQLSource;
186
- exports.toGraphQLOperation = toGraphQLOperation;
@@ -1,86 +0,0 @@
1
- 'use strict';
2
-
3
- var path = require('node:path');
4
- var fs = require('node:fs/promises');
5
- var graphql$1 = require('graphql');
6
- var transform = require('./graphql/transform.cjs');
7
-
8
- function graphql({
9
- manifest
10
- } = {}) {
11
- const shouldWriteManifest = Boolean(manifest);
12
- const manifestPath = typeof manifest === 'string' ? manifest : `manifests/graphql.json`;
13
- return {
14
- name: '@quilted/graphql',
15
- async transform(code, id) {
16
- if (!id.endsWith('.graphql') && !id.endsWith('.gql')) return null;
17
- const topLevelDefinitions = new Set();
18
- const loadedDocument = await loadDocument(code, id, this, (document, level) => {
19
- if (level !== 0) return;
20
- for (const definition of document.definitions) {
21
- if ('name' in definition && definition.name != null) {
22
- topLevelDefinitions.add(definition.name.value);
23
- }
24
- }
25
- });
26
- const document = transform.toGraphQLOperation(transform.cleanGraphQLDocument(loadedDocument, {
27
- removeUnused: {
28
- exclude: topLevelDefinitions
29
- }
30
- }));
31
- return {
32
- code: `export default JSON.parse(${JSON.stringify(JSON.stringify(document))})`,
33
- meta: shouldWriteManifest ? {
34
- quilt: {
35
- graphql: document
36
- }
37
- } : undefined
38
- };
39
- },
40
- async generateBundle() {
41
- if (!shouldWriteManifest) return;
42
- const operations = {};
43
- for (const moduleId of this.getModuleIds()) {
44
- const operation = this.getModuleInfo(moduleId)?.meta?.quilt?.graphql;
45
- if (operation != null && typeof operation.id === 'string' && typeof operation.source === 'string') {
46
- operations[operation.id] = operation.source;
47
- }
48
- }
49
- await fs.mkdir(path.dirname(manifestPath), {
50
- recursive: true
51
- });
52
- await fs.writeFile(manifestPath, JSON.stringify(operations, null, 2));
53
- }
54
- };
55
- }
56
- async function loadDocument(code, file, plugin, add, level = 0, seen = new Set()) {
57
- const {
58
- imports,
59
- source
60
- } = transform.extractGraphQLImports(code);
61
- const document = graphql$1.parse(source);
62
- add?.(document, level);
63
- if (imports.length === 0) {
64
- return document;
65
- }
66
- const resolvedImports = await Promise.all(imports.map(async imported => {
67
- if (seen.has(imported)) return;
68
- seen.add(imported);
69
- const resolvedId = await plugin.resolve(imported, file);
70
- if (resolvedId == null) {
71
- throw new Error(`Could not find ${JSON.stringify(imported)} from ${JSON.stringify(file)}`);
72
- }
73
- plugin.addWatchFile(resolvedId.id);
74
- const contents = await fs.readFile(resolvedId.id, {
75
- encoding: 'utf8'
76
- });
77
- return loadDocument(contents, resolvedId.id, plugin, add, level + 1, seen);
78
- }));
79
- for (const importedDocument of resolvedImports) {
80
- if (importedDocument == null) continue;
81
- document.definitions.push(...importedDocument.definitions);
82
- }
83
- return document;
84
- }
85
-
86
- exports.graphql = graphql;
@@ -1,31 +0,0 @@
1
- 'use strict';
2
-
3
- var constants = require('../constants.cjs');
4
- var magicModule = require('../shared/magic-module.cjs');
5
- var strings = require('../shared/strings.cjs');
6
-
7
- function magicModuleRequestRouterEntry({
8
- host,
9
- port
10
- } = {}) {
11
- return magicModule.createMagicModulePlugin({
12
- name: '@quilted/request-router',
13
- sideEffects: true,
14
- module: constants.MAGIC_MODULE_ENTRY,
15
- async source() {
16
- const initialContent = strings.multiline`
17
- import requestRouter from ${JSON.stringify(constants.MAGIC_MODULE_REQUEST_ROUTER)};
18
-
19
- import {createHttpServer} from '@quilted/quilt/request-router/node';
20
-
21
- const port = ${port ?? 'Number.parseInt(process.env.PORT, 10)'};
22
- const host = ${host ? JSON.stringify(host) : 'process.env.HOST'};
23
-
24
- createHttpServer(requestRouter).listen(port, host);
25
- `;
26
- return initialContent;
27
- }
28
- });
29
- }
30
-
31
- exports.magicModuleRequestRouterEntry = magicModuleRequestRouterEntry;
@@ -1,54 +0,0 @@
1
- 'use strict';
2
-
3
- var node_module = require('node:module');
4
- var babel = require('@rollup/plugin-babel');
5
- var esbuild = require('rollup-plugin-esbuild');
6
-
7
- var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
8
- const require$1 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('features/source-code.cjs', document.baseURI).href)));
9
- function sourceCode({
10
- mode,
11
- targets,
12
- babel: useBabel = true
13
- }) {
14
- if (!useBabel) {
15
- return esbuild({
16
- // Support very modern features
17
- target: 'es2022',
18
- jsx: 'automatic',
19
- jsxImportSource: 'react',
20
- exclude: 'node_modules/**'
21
- });
22
- }
23
- return babel({
24
- envName: mode,
25
- configFile: false,
26
- babelrc: false,
27
- presets: [require$1.resolve('@babel/preset-typescript'), [require$1.resolve('@babel/preset-react'), {
28
- runtime: 'automatic',
29
- importSource: 'react',
30
- development: mode === 'development'
31
- }], [require$1.resolve('@babel/preset-env'), {
32
- useBuiltIns: false,
33
- bugfixes: true,
34
- shippedProposals: true
35
- // I thought I wanted this, but it seems to break the `targets` option
36
- // passed as a root argument.
37
- // ignoreBrowserslistConfig: targets != null,
38
- }]],
39
-
40
- plugins: [[require$1.resolve('@babel/plugin-proposal-decorators'), {
41
- version: '2023-01'
42
- }]],
43
- extensions: ['.ts', '.tsx', '.mts', '.mtsx', '.js', '.jsx', '.es6', '.es', '.mjs'],
44
- exclude: 'node_modules/**',
45
- babelHelpers: 'bundled',
46
- skipPreflightCheck: true,
47
- // Babel doesn’t like this option being set to `undefined`.
48
- ...(targets ? {
49
- targets
50
- } : {})
51
- });
52
- }
53
-
54
- exports.sourceCode = sourceCode;
@@ -1,36 +0,0 @@
1
- 'use strict';
2
-
3
- var fs = require('node:fs/promises');
4
- var node_module = require('node:module');
5
-
6
- var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
7
- function systemJS({
8
- minify = false
9
- } = {}) {
10
- return {
11
- name: '@quilted/system-js',
12
- async renderChunk(_, chunk, options) {
13
- if (options.format !== 'system' || !chunk.isEntry) return null;
14
- const require$1 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('features/system-js.cjs', document.baseURI).href)));
15
- const systemjs = minify ? require$1.resolve('systemjs/dist/s.min.js') : require$1.resolve('systemjs/dist/s.js');
16
-
17
- // We write the systemjs loader to a dedicated file, and we make it the
18
- // "first import" of the chunk so that it is the first file listed in
19
- // the manifest.
20
- const fileHandle = this.emitFile({
21
- type: 'asset',
22
- name: 'loader.js',
23
- source: (await fs.readFile(systemjs, {
24
- encoding: 'utf8'
25
- })).replace(
26
- // Remove the source map comment, if it is present, because we don’t upload the
27
- // sourcemap for this file.
28
- /\n?[/][/]# sourceMappingURL=s.*\.map\n?$/, '')
29
- });
30
- chunk.imports.unshift(this.getFileName(fileHandle));
31
- return null;
32
- }
33
- };
34
- }
35
-
36
- exports.systemJS = systemJS;
@@ -1,56 +0,0 @@
1
- 'use strict';
2
-
3
- var path = require('node:path');
4
- var fs = require('node:fs');
5
-
6
- function _interopNamespaceDefault(e) {
7
- var n = Object.create(null);
8
- if (e) {
9
- Object.keys(e).forEach(function (k) {
10
- if (k !== 'default') {
11
- var d = Object.getOwnPropertyDescriptor(e, k);
12
- Object.defineProperty(n, k, d.get ? d : {
13
- enumerable: true,
14
- get: function () { return e[k]; }
15
- });
16
- }
17
- });
18
- }
19
- n["default"] = e;
20
- return Object.freeze(n);
21
- }
22
-
23
- var path__namespace = /*#__PURE__*/_interopNamespaceDefault(path);
24
- var fs__namespace = /*#__PURE__*/_interopNamespaceDefault(fs);
25
-
26
- async function createTSConfigAliasPlugin({
27
- root = process.cwd()
28
- } = {}) {
29
- const [{
30
- default: alias
31
- }, tsconfig] = await Promise.all([import('@rollup/plugin-alias'), getTSConfig(root)]);
32
- const tsconfigPaths = tsconfig?.compilerOptions?.paths;
33
- if (tsconfigPaths == null) return undefined;
34
- return alias({
35
- entries: Object.entries(tsconfigPaths).map(([name, aliases]) => {
36
- return {
37
- find: name.includes('*') ? new RegExp(`^${name.replace(/\*/, '(.*)')}$`) : name,
38
- replacement: aliases[0].replace('*', '$1')
39
- };
40
- })
41
- });
42
- }
43
- async function getTSConfig(root) {
44
- const tsconfigPath = path__namespace.join(root, 'tsconfig.json');
45
- if (!fs__namespace.existsSync(tsconfigPath)) {
46
- return undefined;
47
- }
48
- try {
49
- const tsconfig = JSON.parse(await fs__namespace.promises.readFile(tsconfigPath, 'utf8'));
50
- return tsconfig;
51
- } catch {
52
- // intentional noop
53
- }
54
- }
55
-
56
- exports.createTSConfigAliasPlugin = createTSConfigAliasPlugin;
@@ -1,13 +0,0 @@
1
- 'use strict';
2
-
3
- var app = require('./app.cjs');
4
- var module$1 = require('./module.cjs');
5
- var _package = require('./package.cjs');
6
-
7
-
8
-
9
- exports.quiltAppBrowser = app.quiltAppBrowser;
10
- exports.quiltAppServer = app.quiltAppServer;
11
- exports.quiltModule = module$1.quiltModule;
12
- exports.quiltPackageESModules = _package.quiltPackageESModules;
13
- exports.quiltPackageESNext = _package.quiltPackageESNext;