@quilted/rollup 0.1.15 → 0.1.17

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.1.17
4
+
5
+ ### Patch Changes
6
+
7
+ - [`aff6bdd6`](https://github.com/lemonmade/quilt/commit/aff6bdd615f35d788ef4345ca34df079d4ff4d2f) Thanks [@lemonmade](https://github.com/lemonmade)! - Improve module hash logic
8
+
9
+ - [`48beeccb`](https://github.com/lemonmade/quilt/commit/48beeccb4366c73ee1040221414af690ccba0958) Thanks [@lemonmade](https://github.com/lemonmade)! - Fix module template and rollup build
10
+
11
+ ## 0.1.16
12
+
13
+ ### Patch Changes
14
+
15
+ - [`ddd42cdd`](https://github.com/lemonmade/quilt/commit/ddd42cdd8c3e15a511579b327bde31c0234f4c16) Thanks [@lemonmade](https://github.com/lemonmade)! - Add module rollup plugin
16
+
3
17
  ## 0.1.15
4
18
 
5
19
  ### Patch Changes
package/build/cjs/app.cjs CHANGED
@@ -8,6 +8,7 @@ var constants = require('./constants.cjs');
8
8
  var strings = require('./shared/strings.cjs');
9
9
  var rollup = require('./shared/rollup.cjs');
10
10
  var magicModule = require('./shared/magic-module.cjs');
11
+ var browserslist = require('./shared/browserslist.cjs');
11
12
 
12
13
  function _interopNamespaceDefault(e) {
13
14
  var n = Object.create(null);
@@ -42,23 +43,15 @@ async function quiltAppBrowser({
42
43
  const mode = (typeof env === 'object' ? env?.mode : undefined) ?? 'production';
43
44
  const minify = assets?.minify ?? mode === 'production';
44
45
  const baseURL = assets?.baseURL ?? '/assets/';
45
- const assetTargets = assets?.targets ?? {};
46
- const targets = Array.isArray(assetTargets) ? {
47
- browsers: assetTargets
48
- } : assetTargets;
49
- const targetBrowsers = targets.browsers ?? (await (async () => {
50
- const {
51
- default: browserslist
52
- } = await import('browserslist');
53
- const config = browserslist.findConfig(root);
54
- if (config == null) return ['defaults'];
55
- const targetName = targets.name ?? 'defaults';
56
- return config[targetName] ?? ['defaults'];
57
- })());
58
- const normalizedTargetName = targets.name === 'defaults' ? 'default' : targets.name;
59
- const targetFilenamePart = normalizedTargetName ? `.${normalizedTargetName}` : '';
46
+ const browserTarget = await browserslist.getBrowserTargetDetails(assets?.targets, {
47
+ root
48
+ });
49
+ const targetFilenamePart = browserTarget.name ? `.${browserTarget.name}` : '';
60
50
  const [{
61
51
  visualizer
52
+ }, {
53
+ magicModuleEnv,
54
+ replaceProcessEnv
62
55
  }, {
63
56
  sourceCode
64
57
  }, {
@@ -71,12 +64,17 @@ async function quiltAppBrowser({
71
64
  staticAssets
72
65
  }, {
73
66
  systemJS
74
- }, 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/typescript.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()]);
67
+ }, nodePlugins] = await Promise.all([import('rollup-plugin-visualizer'), Promise.resolve().then(function () { return require('./features/env.cjs'); }), Promise.resolve().then(function () { return require('./features/source-code.cjs'); }), Promise.resolve().then(function () { return require('./features/typescript.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()]);
75
68
  const plugins = [...nodePlugins, systemJS({
76
69
  minify
70
+ }), replaceProcessEnv({
71
+ mode
72
+ }), magicModuleEnv({
73
+ ...env,
74
+ mode
77
75
  }), sourceCode({
78
76
  mode,
79
- targets: targetBrowsers
77
+ targets: browserTarget.browsers
80
78
  }), css({
81
79
  minify,
82
80
  emit: true
@@ -90,27 +88,6 @@ async function quiltAppBrowser({
90
88
  if (tsconfigAliases) {
91
89
  plugins.push(tsconfigAliases);
92
90
  }
93
- if (env) {
94
- const {
95
- magicModuleEnv,
96
- replaceProcessEnv
97
- } = await Promise.resolve().then(function () { return require('./features/env.cjs'); });
98
- if (typeof env === 'boolean') {
99
- plugins.push(replaceProcessEnv({
100
- mode
101
- }));
102
- plugins.push(magicModuleEnv({
103
- mode
104
- }));
105
- } else {
106
- plugins.push(replaceProcessEnv({
107
- mode
108
- }));
109
- plugins.push(magicModuleEnv({
110
- mode
111
- }));
112
- }
113
- }
114
91
  const appEntry = app ?? (await glob.glob('{App,app,input}.{ts,tsx,mjs,js,jsx}', {
115
92
  cwd: root,
116
93
  nodir: true,
@@ -136,10 +113,10 @@ async function quiltAppBrowser({
136
113
  } = await import('rollup-plugin-esbuild');
137
114
  plugins.push(minify());
138
115
  }
139
- const cacheKey = targets.name ? {
140
- browserTarget: targets.name
116
+ const cacheKey = browserTarget.name ? {
117
+ browserTarget: browserTarget.name
141
118
  } : undefined;
142
- const id = targets.name ? targets.name : undefined;
119
+ const id = browserTarget.name ? browserTarget.name : undefined;
143
120
  plugins.push(assetManifest({
144
121
  id,
145
122
  cacheKey,
@@ -1,11 +1,13 @@
1
1
  'use strict';
2
2
 
3
3
  var app = require('./app.cjs');
4
+ var module$1 = require('./module.cjs');
4
5
  var _package = require('./package.cjs');
5
6
 
6
7
 
7
8
 
8
9
  exports.quiltAppBrowser = app.quiltAppBrowser;
9
10
  exports.quiltAppServer = app.quiltAppServer;
11
+ exports.quiltModule = module$1.quiltModule;
10
12
  exports.quiltPackageESModules = _package.quiltPackageESModules;
11
13
  exports.quiltPackageESNext = _package.quiltPackageESNext;
@@ -0,0 +1,120 @@
1
+ 'use strict';
2
+
3
+ var path = require('node:path');
4
+ var glob = require('glob');
5
+ var node_url = require('node:url');
6
+ var rollup = require('./shared/rollup.cjs');
7
+ var packageJson = require('./shared/package-json.cjs');
8
+ var browserslist = require('./shared/browserslist.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
+
29
+ async function quiltModule({
30
+ root: rootPath = process.cwd(),
31
+ env,
32
+ assets,
33
+ graphql = true
34
+ } = {}) {
35
+ const root = typeof rootPath === 'string' ? rootPath : node_url.fileURLToPath(rootPath);
36
+ const mode = (typeof env === 'object' ? env?.mode : undefined) ?? 'production';
37
+ const outputDirectory = path__namespace.join(root, 'build/assets');
38
+ const minify = assets?.minify ?? true;
39
+ const hash = assets?.hash ?? 'async-only';
40
+ const browserTarget = await browserslist.getBrowserTargetDetails(assets?.targets, {
41
+ root
42
+ });
43
+ const targetFilenamePart = browserTarget.name ? `.${browserTarget.name}` : '';
44
+ const [{
45
+ visualizer
46
+ }, {
47
+ magicModuleEnv,
48
+ replaceProcessEnv
49
+ }, {
50
+ sourceCode
51
+ }, nodePlugins, packageJSON] = await Promise.all([import('rollup-plugin-visualizer'), Promise.resolve().then(function () { return require('./features/env.cjs'); }), Promise.resolve().then(function () { return require('./features/source-code.cjs'); }), rollup.getNodePlugins(), packageJson.loadPackageJSON(root)]);
52
+ const source = await sourceForModule(root, packageJSON);
53
+ const plugins = [...nodePlugins, replaceProcessEnv({
54
+ mode
55
+ }), magicModuleEnv({
56
+ ...env,
57
+ mode
58
+ }), sourceCode({
59
+ mode: 'production'
60
+ }), rollup.removeBuildFiles(['build/assets', 'build/reports'], {
61
+ root
62
+ })];
63
+ if (graphql) {
64
+ const {
65
+ graphql
66
+ } = await Promise.resolve().then(function () { return require('./features/graphql.cjs'); });
67
+ plugins.push(graphql({
68
+ manifest: false
69
+ }));
70
+ }
71
+ if (minify) {
72
+ const {
73
+ minify
74
+ } = await import('rollup-plugin-esbuild');
75
+ plugins.push(minify());
76
+ }
77
+ plugins.push(visualizer({
78
+ template: 'treemap',
79
+ open: false,
80
+ brotliSize: true,
81
+ filename: path__namespace.resolve(root, `build/reports/bundle-visualizer${targetFilenamePart}.html`)
82
+ }));
83
+ return {
84
+ input: source,
85
+ plugins,
86
+ onwarn(warning, defaultWarn) {
87
+ // Removes annoying warnings for React-focused libraries that
88
+ // include 'use client' directives.
89
+ if (warning.code === 'MODULE_LEVEL_DIRECTIVE' && /['"]use client['"]/.test(warning.message)) {
90
+ return;
91
+ }
92
+ defaultWarn(warning);
93
+ },
94
+ output: {
95
+ format: 'esm',
96
+ dir: outputDirectory,
97
+ entryFileNames: `[name]${targetFilenamePart}${hash === true ? `.[hash]` : ''}.js`,
98
+ chunkFileNames: `[name]${targetFilenamePart}${hash === true || hash === 'async-only' ? `.[hash]` : ''}.js`,
99
+ assetFileNames: `[name]${targetFilenamePart}${hash === true ? `.[hash]` : ''}.[ext]`
100
+ }
101
+ };
102
+ }
103
+ async function sourceForModule(root, packageJSON) {
104
+ const {
105
+ main,
106
+ exports
107
+ } = packageJSON;
108
+ const entryFromPackageJSON = main ?? exports?.['.'];
109
+ if (entryFromPackageJSON) {
110
+ return path__namespace.resolve(root, entryFromPackageJSON);
111
+ }
112
+ const possibleSourceFiles = await glob.glob('{App,app,input}.{ts,tsx,mjs,js,jsx}', {
113
+ cwd: root,
114
+ nodir: true,
115
+ absolute: true
116
+ });
117
+ return possibleSourceFiles[0];
118
+ }
119
+
120
+ exports.quiltModule = quiltModule;
@@ -0,0 +1,25 @@
1
+ 'use strict';
2
+
3
+ async function getBrowserTargetDetails(targetSelection = {}, {
4
+ root
5
+ } = {}) {
6
+ const targets = Array.isArray(targetSelection) ? {
7
+ browsers: targetSelection
8
+ } : targetSelection;
9
+ const targetBrowsers = targets.browsers ?? (await (async () => {
10
+ const {
11
+ default: browserslist
12
+ } = await import('browserslist');
13
+ const config = browserslist.findConfig(root);
14
+ if (config == null) return ['defaults'];
15
+ const targetName = targets.name ?? 'defaults';
16
+ return config[targetName] ?? ['defaults'];
17
+ })());
18
+ const name = targets.name === 'defaults' ? 'default' : targets.name;
19
+ return {
20
+ name,
21
+ browsers: targetBrowsers
22
+ };
23
+ }
24
+
25
+ exports.getBrowserTargetDetails = getBrowserTargetDetails;
package/build/esm/app.mjs CHANGED
@@ -6,6 +6,7 @@ import { MAGIC_MODULE_ENTRY, MAGIC_MODULE_APP_COMPONENT, MAGIC_MODULE_REQUEST_RO
6
6
  import { multiline } from './shared/strings.mjs';
7
7
  import { getNodePlugins, removeBuildFiles } from './shared/rollup.mjs';
8
8
  import { createMagicModulePlugin } from './shared/magic-module.mjs';
9
+ import { getBrowserTargetDetails } from './shared/browserslist.mjs';
9
10
 
10
11
  async function quiltAppBrowser({
11
12
  root: rootPath = process.cwd(),
@@ -20,23 +21,15 @@ async function quiltAppBrowser({
20
21
  const mode = (typeof env === 'object' ? env?.mode : undefined) ?? 'production';
21
22
  const minify = assets?.minify ?? mode === 'production';
22
23
  const baseURL = assets?.baseURL ?? '/assets/';
23
- const assetTargets = assets?.targets ?? {};
24
- const targets = Array.isArray(assetTargets) ? {
25
- browsers: assetTargets
26
- } : assetTargets;
27
- const targetBrowsers = targets.browsers ?? (await (async () => {
28
- const {
29
- default: browserslist
30
- } = await import('browserslist');
31
- const config = browserslist.findConfig(root);
32
- if (config == null) return ['defaults'];
33
- const targetName = targets.name ?? 'defaults';
34
- return config[targetName] ?? ['defaults'];
35
- })());
36
- const normalizedTargetName = targets.name === 'defaults' ? 'default' : targets.name;
37
- const targetFilenamePart = normalizedTargetName ? `.${normalizedTargetName}` : '';
24
+ const browserTarget = await getBrowserTargetDetails(assets?.targets, {
25
+ root
26
+ });
27
+ const targetFilenamePart = browserTarget.name ? `.${browserTarget.name}` : '';
38
28
  const [{
39
29
  visualizer
30
+ }, {
31
+ magicModuleEnv,
32
+ replaceProcessEnv
40
33
  }, {
41
34
  sourceCode
42
35
  }, {
@@ -49,12 +42,17 @@ async function quiltAppBrowser({
49
42
  staticAssets
50
43
  }, {
51
44
  systemJS
52
- }, nodePlugins] = await Promise.all([import('rollup-plugin-visualizer'), import('./features/source-code.mjs'), import('./features/typescript.mjs'), import('./features/css.mjs'), import('./features/assets.mjs'), import('./features/system-js.mjs'), getNodePlugins()]);
45
+ }, nodePlugins] = await Promise.all([import('rollup-plugin-visualizer'), import('./features/env.mjs'), import('./features/source-code.mjs'), import('./features/typescript.mjs'), import('./features/css.mjs'), import('./features/assets.mjs'), import('./features/system-js.mjs'), getNodePlugins()]);
53
46
  const plugins = [...nodePlugins, systemJS({
54
47
  minify
48
+ }), replaceProcessEnv({
49
+ mode
50
+ }), magicModuleEnv({
51
+ ...env,
52
+ mode
55
53
  }), sourceCode({
56
54
  mode,
57
- targets: targetBrowsers
55
+ targets: browserTarget.browsers
58
56
  }), css({
59
57
  minify,
60
58
  emit: true
@@ -68,27 +66,6 @@ async function quiltAppBrowser({
68
66
  if (tsconfigAliases) {
69
67
  plugins.push(tsconfigAliases);
70
68
  }
71
- if (env) {
72
- const {
73
- magicModuleEnv,
74
- replaceProcessEnv
75
- } = await import('./features/env.mjs');
76
- if (typeof env === 'boolean') {
77
- plugins.push(replaceProcessEnv({
78
- mode
79
- }));
80
- plugins.push(magicModuleEnv({
81
- mode
82
- }));
83
- } else {
84
- plugins.push(replaceProcessEnv({
85
- mode
86
- }));
87
- plugins.push(magicModuleEnv({
88
- mode
89
- }));
90
- }
91
- }
92
69
  const appEntry = app ?? (await glob('{App,app,input}.{ts,tsx,mjs,js,jsx}', {
93
70
  cwd: root,
94
71
  nodir: true,
@@ -114,10 +91,10 @@ async function quiltAppBrowser({
114
91
  } = await import('rollup-plugin-esbuild');
115
92
  plugins.push(minify());
116
93
  }
117
- const cacheKey = targets.name ? {
118
- browserTarget: targets.name
94
+ const cacheKey = browserTarget.name ? {
95
+ browserTarget: browserTarget.name
119
96
  } : undefined;
120
- const id = targets.name ? targets.name : undefined;
97
+ const id = browserTarget.name ? browserTarget.name : undefined;
121
98
  plugins.push(assetManifest({
122
99
  id,
123
100
  cacheKey,
@@ -1,2 +1,3 @@
1
1
  export { quiltAppBrowser, quiltAppServer } from './app.mjs';
2
+ export { quiltModule } from './module.mjs';
2
3
  export { quiltPackageESModules, quiltPackageESNext } from './package.mjs';
@@ -0,0 +1,99 @@
1
+ import * as path from 'node:path';
2
+ import { glob } from 'glob';
3
+ import { fileURLToPath } from 'node:url';
4
+ import { getNodePlugins, removeBuildFiles } from './shared/rollup.mjs';
5
+ import { loadPackageJSON } from './shared/package-json.mjs';
6
+ import { getBrowserTargetDetails } from './shared/browserslist.mjs';
7
+
8
+ async function quiltModule({
9
+ root: rootPath = process.cwd(),
10
+ env,
11
+ assets,
12
+ graphql = true
13
+ } = {}) {
14
+ const root = typeof rootPath === 'string' ? rootPath : fileURLToPath(rootPath);
15
+ const mode = (typeof env === 'object' ? env?.mode : undefined) ?? 'production';
16
+ const outputDirectory = path.join(root, 'build/assets');
17
+ const minify = assets?.minify ?? true;
18
+ const hash = assets?.hash ?? 'async-only';
19
+ const browserTarget = await getBrowserTargetDetails(assets?.targets, {
20
+ root
21
+ });
22
+ const targetFilenamePart = browserTarget.name ? `.${browserTarget.name}` : '';
23
+ const [{
24
+ visualizer
25
+ }, {
26
+ magicModuleEnv,
27
+ replaceProcessEnv
28
+ }, {
29
+ sourceCode
30
+ }, nodePlugins, packageJSON] = await Promise.all([import('rollup-plugin-visualizer'), import('./features/env.mjs'), import('./features/source-code.mjs'), getNodePlugins(), loadPackageJSON(root)]);
31
+ const source = await sourceForModule(root, packageJSON);
32
+ const plugins = [...nodePlugins, replaceProcessEnv({
33
+ mode
34
+ }), magicModuleEnv({
35
+ ...env,
36
+ mode
37
+ }), sourceCode({
38
+ mode: 'production'
39
+ }), removeBuildFiles(['build/assets', 'build/reports'], {
40
+ root
41
+ })];
42
+ if (graphql) {
43
+ const {
44
+ graphql
45
+ } = await import('./features/graphql.mjs');
46
+ plugins.push(graphql({
47
+ manifest: false
48
+ }));
49
+ }
50
+ if (minify) {
51
+ const {
52
+ minify
53
+ } = await import('rollup-plugin-esbuild');
54
+ plugins.push(minify());
55
+ }
56
+ plugins.push(visualizer({
57
+ template: 'treemap',
58
+ open: false,
59
+ brotliSize: true,
60
+ filename: path.resolve(root, `build/reports/bundle-visualizer${targetFilenamePart}.html`)
61
+ }));
62
+ return {
63
+ input: source,
64
+ plugins,
65
+ onwarn(warning, defaultWarn) {
66
+ // Removes annoying warnings for React-focused libraries that
67
+ // include 'use client' directives.
68
+ if (warning.code === 'MODULE_LEVEL_DIRECTIVE' && /['"]use client['"]/.test(warning.message)) {
69
+ return;
70
+ }
71
+ defaultWarn(warning);
72
+ },
73
+ output: {
74
+ format: 'esm',
75
+ dir: outputDirectory,
76
+ entryFileNames: `[name]${targetFilenamePart}${hash === true ? `.[hash]` : ''}.js`,
77
+ chunkFileNames: `[name]${targetFilenamePart}${hash === true || hash === 'async-only' ? `.[hash]` : ''}.js`,
78
+ assetFileNames: `[name]${targetFilenamePart}${hash === true ? `.[hash]` : ''}.[ext]`
79
+ }
80
+ };
81
+ }
82
+ async function sourceForModule(root, packageJSON) {
83
+ const {
84
+ main,
85
+ exports
86
+ } = packageJSON;
87
+ const entryFromPackageJSON = main ?? exports?.['.'];
88
+ if (entryFromPackageJSON) {
89
+ return path.resolve(root, entryFromPackageJSON);
90
+ }
91
+ const possibleSourceFiles = await glob('{App,app,input}.{ts,tsx,mjs,js,jsx}', {
92
+ cwd: root,
93
+ nodir: true,
94
+ absolute: true
95
+ });
96
+ return possibleSourceFiles[0];
97
+ }
98
+
99
+ export { quiltModule };
@@ -0,0 +1,23 @@
1
+ async function getBrowserTargetDetails(targetSelection = {}, {
2
+ root
3
+ } = {}) {
4
+ const targets = Array.isArray(targetSelection) ? {
5
+ browsers: targetSelection
6
+ } : targetSelection;
7
+ const targetBrowsers = targets.browsers ?? (await (async () => {
8
+ const {
9
+ default: browserslist
10
+ } = await import('browserslist');
11
+ const config = browserslist.findConfig(root);
12
+ if (config == null) return ['defaults'];
13
+ const targetName = targets.name ?? 'defaults';
14
+ return config[targetName] ?? ['defaults'];
15
+ })());
16
+ const name = targets.name === 'defaults' ? 'default' : targets.name;
17
+ return {
18
+ name,
19
+ browsers: targetBrowsers
20
+ };
21
+ }
22
+
23
+ export { getBrowserTargetDetails };
@@ -6,6 +6,7 @@ import { MAGIC_MODULE_ENTRY, MAGIC_MODULE_APP_COMPONENT, MAGIC_MODULE_REQUEST_RO
6
6
  import { multiline } from './shared/strings.esnext';
7
7
  import { getNodePlugins, removeBuildFiles } from './shared/rollup.esnext';
8
8
  import { createMagicModulePlugin } from './shared/magic-module.esnext';
9
+ import { getBrowserTargetDetails } from './shared/browserslist.esnext';
9
10
 
10
11
  async function quiltAppBrowser({
11
12
  root: rootPath = process.cwd(),
@@ -20,23 +21,15 @@ async function quiltAppBrowser({
20
21
  const mode = (typeof env === 'object' ? env?.mode : undefined) ?? 'production';
21
22
  const minify = assets?.minify ?? mode === 'production';
22
23
  const baseURL = assets?.baseURL ?? '/assets/';
23
- const assetTargets = assets?.targets ?? {};
24
- const targets = Array.isArray(assetTargets) ? {
25
- browsers: assetTargets
26
- } : assetTargets;
27
- const targetBrowsers = targets.browsers ?? (await (async () => {
28
- const {
29
- default: browserslist
30
- } = await import('browserslist');
31
- const config = browserslist.findConfig(root);
32
- if (config == null) return ['defaults'];
33
- const targetName = targets.name ?? 'defaults';
34
- return config[targetName] ?? ['defaults'];
35
- })());
36
- const normalizedTargetName = targets.name === 'defaults' ? 'default' : targets.name;
37
- const targetFilenamePart = normalizedTargetName ? `.${normalizedTargetName}` : '';
24
+ const browserTarget = await getBrowserTargetDetails(assets?.targets, {
25
+ root
26
+ });
27
+ const targetFilenamePart = browserTarget.name ? `.${browserTarget.name}` : '';
38
28
  const [{
39
29
  visualizer
30
+ }, {
31
+ magicModuleEnv,
32
+ replaceProcessEnv
40
33
  }, {
41
34
  sourceCode
42
35
  }, {
@@ -49,12 +42,17 @@ async function quiltAppBrowser({
49
42
  staticAssets
50
43
  }, {
51
44
  systemJS
52
- }, nodePlugins] = await Promise.all([import('rollup-plugin-visualizer'), import('./features/source-code.esnext'), import('./features/typescript.esnext'), import('./features/css.esnext'), import('./features/assets.esnext'), import('./features/system-js.esnext'), getNodePlugins()]);
45
+ }, nodePlugins] = await Promise.all([import('rollup-plugin-visualizer'), import('./features/env.esnext'), import('./features/source-code.esnext'), import('./features/typescript.esnext'), import('./features/css.esnext'), import('./features/assets.esnext'), import('./features/system-js.esnext'), getNodePlugins()]);
53
46
  const plugins = [...nodePlugins, systemJS({
54
47
  minify
48
+ }), replaceProcessEnv({
49
+ mode
50
+ }), magicModuleEnv({
51
+ ...env,
52
+ mode
55
53
  }), sourceCode({
56
54
  mode,
57
- targets: targetBrowsers
55
+ targets: browserTarget.browsers
58
56
  }), css({
59
57
  minify,
60
58
  emit: true
@@ -68,27 +66,6 @@ async function quiltAppBrowser({
68
66
  if (tsconfigAliases) {
69
67
  plugins.push(tsconfigAliases);
70
68
  }
71
- if (env) {
72
- const {
73
- magicModuleEnv,
74
- replaceProcessEnv
75
- } = await import('./features/env.esnext');
76
- if (typeof env === 'boolean') {
77
- plugins.push(replaceProcessEnv({
78
- mode
79
- }));
80
- plugins.push(magicModuleEnv({
81
- mode
82
- }));
83
- } else {
84
- plugins.push(replaceProcessEnv({
85
- mode
86
- }));
87
- plugins.push(magicModuleEnv({
88
- mode
89
- }));
90
- }
91
- }
92
69
  const appEntry = app ?? (await glob('{App,app,input}.{ts,tsx,mjs,js,jsx}', {
93
70
  cwd: root,
94
71
  nodir: true,
@@ -114,10 +91,10 @@ async function quiltAppBrowser({
114
91
  } = await import('rollup-plugin-esbuild');
115
92
  plugins.push(minify());
116
93
  }
117
- const cacheKey = targets.name ? {
118
- browserTarget: targets.name
94
+ const cacheKey = browserTarget.name ? {
95
+ browserTarget: browserTarget.name
119
96
  } : undefined;
120
- const id = targets.name ? targets.name : undefined;
97
+ const id = browserTarget.name ? browserTarget.name : undefined;
121
98
  plugins.push(assetManifest({
122
99
  id,
123
100
  cacheKey,
@@ -1,2 +1,3 @@
1
1
  export { quiltAppBrowser, quiltAppServer } from './app.esnext';
2
+ export { quiltModule } from './module.esnext';
2
3
  export { quiltPackageESModules, quiltPackageESNext } from './package.esnext';