@shopify/cli-hydrogen 8.0.2 → 8.0.4
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/dist/commands/hydrogen/build.js +75 -98
- package/dist/commands/hydrogen/deploy.js +2 -2
- package/dist/commands/hydrogen/dev.js +149 -218
- package/dist/commands/hydrogen/init.js +2 -10
- package/dist/commands/hydrogen/upgrade.js +79 -66
- package/dist/generator-templates/starter/CHANGELOG.md +28 -0
- package/dist/generator-templates/starter/app/routes/products.$handle.tsx +2 -14
- package/dist/generator-templates/starter/customer-accountapi.generated.d.ts +1 -1
- package/dist/generator-templates/starter/package.json +8 -8
- package/dist/generator-templates/starter/storefrontapi.generated.d.ts +1 -1
- package/dist/lib/classic-compiler/build.js +132 -0
- package/dist/lib/classic-compiler/dev.js +262 -0
- package/dist/lib/flags.js +1 -1
- package/dist/lib/onboarding/index.js +16 -2
- package/dist/lib/onboarding/setup-template.mocks.js +72 -0
- package/dist/lib/template-diff.js +7 -3
- package/oclif.manifest.json +35 -244
- package/package.json +6 -6
- package/dist/commands/hydrogen/build-vite.js +0 -140
- package/dist/commands/hydrogen/dev-vite.js +0 -228
package/oclif.manifest.json
CHANGED
|
@@ -1,89 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"commands": {
|
|
3
3
|
"hydrogen:build": {
|
|
4
|
-
"aliases": [],
|
|
5
|
-
"args": {},
|
|
6
|
-
"description": "Builds a Hydrogen storefront for production.",
|
|
7
|
-
"flags": {
|
|
8
|
-
"path": {
|
|
9
|
-
"description": "The path to the directory of the Hydrogen storefront. Defaults to the current directory where the command is run.",
|
|
10
|
-
"env": "SHOPIFY_HYDROGEN_FLAG_PATH",
|
|
11
|
-
"name": "path",
|
|
12
|
-
"hasDynamicHelp": false,
|
|
13
|
-
"multiple": false,
|
|
14
|
-
"type": "option"
|
|
15
|
-
},
|
|
16
|
-
"sourcemap": {
|
|
17
|
-
"description": "Controls whether sourcemaps are generated. Default to `true`. Deactivate `--no-sourcemaps`.",
|
|
18
|
-
"env": "SHOPIFY_HYDROGEN_FLAG_SOURCEMAP",
|
|
19
|
-
"name": "sourcemap",
|
|
20
|
-
"allowNo": true,
|
|
21
|
-
"type": "boolean"
|
|
22
|
-
},
|
|
23
|
-
"bundle-stats": {
|
|
24
|
-
"description": "Show a bundle size summary after building. Defaults to true, use `--no-bundle-stats` to disable.",
|
|
25
|
-
"name": "bundle-stats",
|
|
26
|
-
"allowNo": true,
|
|
27
|
-
"type": "boolean"
|
|
28
|
-
},
|
|
29
|
-
"lockfile-check": {
|
|
30
|
-
"description": "Checks that there is exactly one valid lockfile in the project. Defaults to `true`. Deactivate with `--no-lockfile-check`.",
|
|
31
|
-
"env": "SHOPIFY_HYDROGEN_FLAG_LOCKFILE_CHECK",
|
|
32
|
-
"name": "lockfile-check",
|
|
33
|
-
"allowNo": true,
|
|
34
|
-
"type": "boolean"
|
|
35
|
-
},
|
|
36
|
-
"disable-route-warning": {
|
|
37
|
-
"description": "Disables any warnings about missing standard routes.",
|
|
38
|
-
"env": "SHOPIFY_HYDROGEN_FLAG_DISABLE_ROUTE_WARNING",
|
|
39
|
-
"name": "disable-route-warning",
|
|
40
|
-
"allowNo": false,
|
|
41
|
-
"type": "boolean"
|
|
42
|
-
},
|
|
43
|
-
"codegen": {
|
|
44
|
-
"description": "Automatically generates GraphQL types for your project’s Storefront API queries.",
|
|
45
|
-
"name": "codegen",
|
|
46
|
-
"required": false,
|
|
47
|
-
"allowNo": false,
|
|
48
|
-
"type": "boolean"
|
|
49
|
-
},
|
|
50
|
-
"codegen-config-path": {
|
|
51
|
-
"dependsOn": [
|
|
52
|
-
"codegen"
|
|
53
|
-
],
|
|
54
|
-
"description": "Specifies a path to a codegen configuration file. Defaults to `<root>/codegen.ts` if this file exists.",
|
|
55
|
-
"name": "codegen-config-path",
|
|
56
|
-
"required": false,
|
|
57
|
-
"hasDynamicHelp": false,
|
|
58
|
-
"multiple": false,
|
|
59
|
-
"type": "option"
|
|
60
|
-
},
|
|
61
|
-
"diff": {
|
|
62
|
-
"description": "Applies the current files on top of Hydrogen's starter template in a temporary directory.",
|
|
63
|
-
"hidden": true,
|
|
64
|
-
"name": "diff",
|
|
65
|
-
"required": false,
|
|
66
|
-
"allowNo": false,
|
|
67
|
-
"type": "boolean"
|
|
68
|
-
}
|
|
69
|
-
},
|
|
70
|
-
"hasDynamicHelp": false,
|
|
71
|
-
"hiddenAliases": [],
|
|
72
|
-
"id": "hydrogen:build",
|
|
73
|
-
"pluginAlias": "@shopify/cli-hydrogen",
|
|
74
|
-
"pluginName": "@shopify/cli-hydrogen",
|
|
75
|
-
"pluginType": "core",
|
|
76
|
-
"strict": true,
|
|
77
|
-
"descriptionWithMarkdown": "Builds a Hydrogen storefront for production. The client and app worker files are compiled to a `/dist` folder in your Hydrogen project directory.",
|
|
78
|
-
"isESM": true,
|
|
79
|
-
"relativePath": [
|
|
80
|
-
"dist",
|
|
81
|
-
"commands",
|
|
82
|
-
"hydrogen",
|
|
83
|
-
"build.js"
|
|
84
|
-
]
|
|
85
|
-
},
|
|
86
|
-
"hydrogen:build-vite": {
|
|
87
4
|
"aliases": [],
|
|
88
5
|
"args": {},
|
|
89
6
|
"description": "Builds a Hydrogen storefront for production.",
|
|
@@ -150,22 +67,28 @@
|
|
|
150
67
|
"required": false,
|
|
151
68
|
"allowNo": false,
|
|
152
69
|
"type": "boolean"
|
|
70
|
+
},
|
|
71
|
+
"bundle-stats": {
|
|
72
|
+
"description": "[Classic Remix Compiler] Show a bundle size summary after building. Defaults to true, use `--no-bundle-stats` to disable.",
|
|
73
|
+
"name": "bundle-stats",
|
|
74
|
+
"allowNo": true,
|
|
75
|
+
"type": "boolean"
|
|
153
76
|
}
|
|
154
77
|
},
|
|
155
78
|
"hasDynamicHelp": false,
|
|
156
|
-
"hidden": true,
|
|
157
79
|
"hiddenAliases": [],
|
|
158
|
-
"id": "hydrogen:build
|
|
80
|
+
"id": "hydrogen:build",
|
|
159
81
|
"pluginAlias": "@shopify/cli-hydrogen",
|
|
160
82
|
"pluginName": "@shopify/cli-hydrogen",
|
|
161
83
|
"pluginType": "core",
|
|
162
84
|
"strict": true,
|
|
85
|
+
"descriptionWithMarkdown": "Builds a Hydrogen storefront for production. The client and app worker files are compiled to a `/dist` folder in your Hydrogen project directory.",
|
|
163
86
|
"isESM": true,
|
|
164
87
|
"relativePath": [
|
|
165
88
|
"dist",
|
|
166
89
|
"commands",
|
|
167
90
|
"hydrogen",
|
|
168
|
-
"build
|
|
91
|
+
"build.js"
|
|
169
92
|
]
|
|
170
93
|
},
|
|
171
94
|
"hydrogen:check": {
|
|
@@ -555,26 +478,23 @@
|
|
|
555
478
|
"multiple": false,
|
|
556
479
|
"type": "option"
|
|
557
480
|
},
|
|
481
|
+
"entry": {
|
|
482
|
+
"description": "Entry file for the worker. Defaults to `./server`.",
|
|
483
|
+
"env": "SHOPIFY_HYDROGEN_FLAG_ENTRY",
|
|
484
|
+
"name": "entry",
|
|
485
|
+
"hasDynamicHelp": false,
|
|
486
|
+
"multiple": false,
|
|
487
|
+
"type": "option"
|
|
488
|
+
},
|
|
558
489
|
"port": {
|
|
559
490
|
"description": "The port to run the server on. Defaults to 3000.",
|
|
560
491
|
"env": "SHOPIFY_HYDROGEN_FLAG_PORT",
|
|
561
492
|
"name": "port",
|
|
493
|
+
"required": false,
|
|
562
494
|
"hasDynamicHelp": false,
|
|
563
495
|
"multiple": false,
|
|
564
496
|
"type": "option"
|
|
565
497
|
},
|
|
566
|
-
"worker": {
|
|
567
|
-
"hidden": true,
|
|
568
|
-
"name": "worker",
|
|
569
|
-
"type": "boolean"
|
|
570
|
-
},
|
|
571
|
-
"legacy-runtime": {
|
|
572
|
-
"description": "Runs the app in a Node.js sandbox instead of an Oxygen worker.",
|
|
573
|
-
"env": "SHOPIFY_HYDROGEN_FLAG_WORKER",
|
|
574
|
-
"name": "legacy-runtime",
|
|
575
|
-
"allowNo": false,
|
|
576
|
-
"type": "boolean"
|
|
577
|
-
},
|
|
578
498
|
"codegen": {
|
|
579
499
|
"description": "Automatically generates GraphQL types for your project’s Storefront API queries.",
|
|
580
500
|
"name": "codegen",
|
|
@@ -593,13 +513,6 @@
|
|
|
593
513
|
"multiple": false,
|
|
594
514
|
"type": "option"
|
|
595
515
|
},
|
|
596
|
-
"sourcemap": {
|
|
597
|
-
"description": "Controls whether sourcemaps are generated. Default to `true`. Deactivate `--no-sourcemaps`.",
|
|
598
|
-
"env": "SHOPIFY_HYDROGEN_FLAG_SOURCEMAP",
|
|
599
|
-
"name": "sourcemap",
|
|
600
|
-
"allowNo": true,
|
|
601
|
-
"type": "boolean"
|
|
602
|
-
},
|
|
603
516
|
"disable-virtual-routes": {
|
|
604
517
|
"description": "Disable rendering fallback routes when a route file doesn't exist.",
|
|
605
518
|
"env": "SHOPIFY_HYDROGEN_FLAG_DISABLE_VIRTUAL_ROUTES",
|
|
@@ -675,170 +588,48 @@
|
|
|
675
588
|
"required": false,
|
|
676
589
|
"allowNo": false,
|
|
677
590
|
"type": "boolean"
|
|
678
|
-
}
|
|
679
|
-
},
|
|
680
|
-
"hasDynamicHelp": false,
|
|
681
|
-
"hiddenAliases": [],
|
|
682
|
-
"id": "hydrogen:dev",
|
|
683
|
-
"pluginAlias": "@shopify/cli-hydrogen",
|
|
684
|
-
"pluginName": "@shopify/cli-hydrogen",
|
|
685
|
-
"pluginType": "core",
|
|
686
|
-
"strict": true,
|
|
687
|
-
"descriptionWithMarkdown": "Runs a Hydrogen storefront in a local runtime that emulates an Oxygen worker for development.\n\n If your project is [linked](https://shopify.dev/docs/api/shopify-cli/hydrogen/hydrogen-link) to a Hydrogen storefront, then its environment variables will be loaded with the runtime.",
|
|
688
|
-
"isESM": true,
|
|
689
|
-
"relativePath": [
|
|
690
|
-
"dist",
|
|
691
|
-
"commands",
|
|
692
|
-
"hydrogen",
|
|
693
|
-
"dev.js"
|
|
694
|
-
]
|
|
695
|
-
},
|
|
696
|
-
"hydrogen:dev-vite": {
|
|
697
|
-
"aliases": [],
|
|
698
|
-
"args": {},
|
|
699
|
-
"description": "Runs Hydrogen storefront in an Oxygen worker for development.",
|
|
700
|
-
"flags": {
|
|
701
|
-
"path": {
|
|
702
|
-
"description": "The path to the directory of the Hydrogen storefront. Defaults to the current directory where the command is run.",
|
|
703
|
-
"env": "SHOPIFY_HYDROGEN_FLAG_PATH",
|
|
704
|
-
"name": "path",
|
|
705
|
-
"hasDynamicHelp": false,
|
|
706
|
-
"multiple": false,
|
|
707
|
-
"type": "option"
|
|
708
|
-
},
|
|
709
|
-
"entry": {
|
|
710
|
-
"description": "Entry file for the worker. Defaults to `./server`.",
|
|
711
|
-
"env": "SHOPIFY_HYDROGEN_FLAG_ENTRY",
|
|
712
|
-
"name": "entry",
|
|
713
|
-
"hasDynamicHelp": false,
|
|
714
|
-
"multiple": false,
|
|
715
|
-
"type": "option"
|
|
716
|
-
},
|
|
717
|
-
"port": {
|
|
718
|
-
"description": "The port to run the server on. Defaults to 3000.",
|
|
719
|
-
"env": "SHOPIFY_HYDROGEN_FLAG_PORT",
|
|
720
|
-
"name": "port",
|
|
721
|
-
"required": false,
|
|
722
|
-
"hasDynamicHelp": false,
|
|
723
|
-
"multiple": false,
|
|
724
|
-
"type": "option"
|
|
725
|
-
},
|
|
726
|
-
"codegen": {
|
|
727
|
-
"description": "Automatically generates GraphQL types for your project’s Storefront API queries.",
|
|
728
|
-
"name": "codegen",
|
|
729
|
-
"required": false,
|
|
730
|
-
"allowNo": false,
|
|
731
|
-
"type": "boolean"
|
|
732
|
-
},
|
|
733
|
-
"codegen-config-path": {
|
|
734
|
-
"dependsOn": [
|
|
735
|
-
"codegen"
|
|
736
|
-
],
|
|
737
|
-
"description": "Specifies a path to a codegen configuration file. Defaults to `<root>/codegen.ts` if this file exists.",
|
|
738
|
-
"name": "codegen-config-path",
|
|
739
|
-
"required": false,
|
|
740
|
-
"hasDynamicHelp": false,
|
|
741
|
-
"multiple": false,
|
|
742
|
-
"type": "option"
|
|
743
|
-
},
|
|
744
|
-
"disable-virtual-routes": {
|
|
745
|
-
"description": "Disable rendering fallback routes when a route file doesn't exist.",
|
|
746
|
-
"env": "SHOPIFY_HYDROGEN_FLAG_DISABLE_VIRTUAL_ROUTES",
|
|
747
|
-
"name": "disable-virtual-routes",
|
|
748
|
-
"allowNo": false,
|
|
749
|
-
"type": "boolean"
|
|
750
|
-
},
|
|
751
|
-
"debug": {
|
|
752
|
-
"description": "Enables inspector connections to the server with a debugger such as Visual Studio Code or Chrome DevTools.",
|
|
753
|
-
"env": "SHOPIFY_HYDROGEN_FLAG_DEBUG",
|
|
754
|
-
"name": "debug",
|
|
755
|
-
"allowNo": false,
|
|
756
|
-
"type": "boolean"
|
|
757
|
-
},
|
|
758
|
-
"inspector-port": {
|
|
759
|
-
"description": "The port where the inspector is available. Defaults to 9229.",
|
|
760
|
-
"env": "SHOPIFY_HYDROGEN_FLAG_INSPECTOR_PORT",
|
|
761
|
-
"name": "inspector-port",
|
|
762
|
-
"hasDynamicHelp": false,
|
|
763
|
-
"multiple": false,
|
|
764
|
-
"type": "option"
|
|
765
591
|
},
|
|
766
592
|
"host": {
|
|
767
|
-
"description": "Expose the server to the network",
|
|
593
|
+
"description": "Expose the server to the local network",
|
|
768
594
|
"name": "host",
|
|
769
595
|
"required": false,
|
|
770
596
|
"allowNo": false,
|
|
771
597
|
"type": "boolean"
|
|
772
598
|
},
|
|
773
|
-
"
|
|
774
|
-
"description": "Specifies the environment to perform the operation using its handle. Fetch the handle using the `env list` command.",
|
|
775
|
-
"exclusive": [
|
|
776
|
-
"env-branch"
|
|
777
|
-
],
|
|
778
|
-
"name": "env",
|
|
779
|
-
"hasDynamicHelp": false,
|
|
780
|
-
"multiple": false,
|
|
781
|
-
"type": "option"
|
|
782
|
-
},
|
|
783
|
-
"env-branch": {
|
|
784
|
-
"deprecated": {
|
|
785
|
-
"to": "env",
|
|
786
|
-
"message": "--env-branch is deprecated. Use --env instead."
|
|
787
|
-
},
|
|
788
|
-
"description": "Specifies the environment to perform the operation using its Git branch name.",
|
|
789
|
-
"env": "SHOPIFY_HYDROGEN_ENVIRONMENT_BRANCH",
|
|
790
|
-
"name": "env-branch",
|
|
791
|
-
"hasDynamicHelp": false,
|
|
792
|
-
"multiple": false,
|
|
793
|
-
"type": "option"
|
|
794
|
-
},
|
|
795
|
-
"disable-version-check": {
|
|
796
|
-
"description": "Skip the version check when running `hydrogen dev`",
|
|
797
|
-
"name": "disable-version-check",
|
|
798
|
-
"required": false,
|
|
799
|
-
"allowNo": false,
|
|
800
|
-
"type": "boolean"
|
|
801
|
-
},
|
|
802
|
-
"diff": {
|
|
803
|
-
"description": "Applies the current files on top of Hydrogen's starter template in a temporary directory.",
|
|
599
|
+
"worker": {
|
|
804
600
|
"hidden": true,
|
|
805
|
-
"name": "
|
|
806
|
-
"required": false,
|
|
807
|
-
"allowNo": false,
|
|
601
|
+
"name": "worker",
|
|
808
602
|
"type": "boolean"
|
|
809
603
|
},
|
|
810
|
-
"
|
|
811
|
-
"description": "
|
|
812
|
-
"env": "
|
|
813
|
-
"
|
|
814
|
-
"name": "customer-account-push__unstable",
|
|
815
|
-
"required": false,
|
|
604
|
+
"legacy-runtime": {
|
|
605
|
+
"description": "[Classic Remix Compiler] Runs the app in a Node.js sandbox instead of an Oxygen worker.",
|
|
606
|
+
"env": "SHOPIFY_HYDROGEN_FLAG_LEGACY_RUNTIME",
|
|
607
|
+
"name": "legacy-runtime",
|
|
816
608
|
"allowNo": false,
|
|
817
609
|
"type": "boolean"
|
|
818
610
|
},
|
|
819
|
-
"
|
|
820
|
-
"description": "
|
|
821
|
-
"env": "
|
|
822
|
-
"name": "
|
|
823
|
-
"
|
|
824
|
-
"allowNo": false,
|
|
611
|
+
"sourcemap": {
|
|
612
|
+
"description": "[Classic Remix Compiler] Controls whether sourcemaps are generated. Default to `true`. Deactivate `--no-sourcemaps`.",
|
|
613
|
+
"env": "SHOPIFY_HYDROGEN_FLAG_SOURCEMAP",
|
|
614
|
+
"name": "sourcemap",
|
|
615
|
+
"allowNo": true,
|
|
825
616
|
"type": "boolean"
|
|
826
617
|
}
|
|
827
618
|
},
|
|
828
619
|
"hasDynamicHelp": false,
|
|
829
|
-
"hidden": true,
|
|
830
620
|
"hiddenAliases": [],
|
|
831
|
-
"id": "hydrogen:dev
|
|
621
|
+
"id": "hydrogen:dev",
|
|
832
622
|
"pluginAlias": "@shopify/cli-hydrogen",
|
|
833
623
|
"pluginName": "@shopify/cli-hydrogen",
|
|
834
624
|
"pluginType": "core",
|
|
835
625
|
"strict": true,
|
|
626
|
+
"descriptionWithMarkdown": "Runs a Hydrogen storefront in a local runtime that emulates an Oxygen worker for development.\n\n If your project is [linked](https://shopify.dev/docs/api/shopify-cli/hydrogen/hydrogen-link) to a Hydrogen storefront, then its environment variables will be loaded with the runtime.",
|
|
836
627
|
"isESM": true,
|
|
837
628
|
"relativePath": [
|
|
838
629
|
"dist",
|
|
839
630
|
"commands",
|
|
840
631
|
"hydrogen",
|
|
841
|
-
"dev
|
|
632
|
+
"dev.js"
|
|
842
633
|
]
|
|
843
634
|
},
|
|
844
635
|
"hydrogen:env:list": {
|
|
@@ -1435,7 +1226,7 @@
|
|
|
1435
1226
|
},
|
|
1436
1227
|
"legacy-runtime": {
|
|
1437
1228
|
"description": "Runs the app in a Node.js sandbox instead of an Oxygen worker.",
|
|
1438
|
-
"env": "
|
|
1229
|
+
"env": "SHOPIFY_HYDROGEN_FLAG_LEGACY_RUNTIME",
|
|
1439
1230
|
"name": "legacy-runtime",
|
|
1440
1231
|
"allowNo": false,
|
|
1441
1232
|
"type": "boolean"
|
|
@@ -1788,5 +1579,5 @@
|
|
|
1788
1579
|
]
|
|
1789
1580
|
}
|
|
1790
1581
|
},
|
|
1791
|
-
"version": "8.0.
|
|
1582
|
+
"version": "8.0.4"
|
|
1792
1583
|
}
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"access": "public",
|
|
5
5
|
"@shopify:registry": "https://registry.npmjs.org"
|
|
6
6
|
},
|
|
7
|
-
"version": "8.0.
|
|
7
|
+
"version": "8.0.4",
|
|
8
8
|
"license": "MIT",
|
|
9
9
|
"type": "module",
|
|
10
10
|
"scripts": {
|
|
@@ -34,10 +34,10 @@
|
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@ast-grep/napi": "0.11.0",
|
|
37
|
-
"@oclif/core": "3.
|
|
38
|
-
"@shopify/cli-kit": "3.
|
|
37
|
+
"@oclif/core": "3.23.0",
|
|
38
|
+
"@shopify/cli-kit": "3.59.2",
|
|
39
39
|
"@shopify/oxygen-cli": "~4.4.0",
|
|
40
|
-
"@shopify/plugin-cloudflare": "3.
|
|
40
|
+
"@shopify/plugin-cloudflare": "3.59.2",
|
|
41
41
|
"ansi-escapes": "^6.2.0",
|
|
42
42
|
"cli-truncate": "^4.0.0",
|
|
43
43
|
"diff": "^5.1.0",
|
|
@@ -59,8 +59,8 @@
|
|
|
59
59
|
"peerDependencies": {
|
|
60
60
|
"@graphql-codegen/cli": "^5.0.2",
|
|
61
61
|
"@remix-run/dev": "^2.1.0",
|
|
62
|
-
"@shopify/hydrogen-codegen": "^0.3.
|
|
63
|
-
"@shopify/mini-oxygen": "^3.0.
|
|
62
|
+
"@shopify/hydrogen-codegen": "^0.3.1",
|
|
63
|
+
"@shopify/mini-oxygen": "^3.0.2",
|
|
64
64
|
"graphql-config": "^5.0.3",
|
|
65
65
|
"vite": "^5.1.0"
|
|
66
66
|
},
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import Command from '@shopify/cli-kit/node/base-command';
|
|
2
|
-
import { collectLog, outputWarn } from '@shopify/cli-kit/node/output';
|
|
3
|
-
import { removeFile, fileSize } from '@shopify/cli-kit/node/fs';
|
|
4
|
-
import { resolvePath, joinPath } from '@shopify/cli-kit/node/path';
|
|
5
|
-
import { getPackageManager } from '@shopify/cli-kit/node/node-package-manager';
|
|
6
|
-
import { commonFlags, flagsToCamelObject } from '../../lib/flags.js';
|
|
7
|
-
import { checkLockfileStatus } from '../../lib/check-lockfile.js';
|
|
8
|
-
import { findMissingRoutes } from '../../lib/missing-routes.js';
|
|
9
|
-
import { codegen } from '../../lib/codegen.js';
|
|
10
|
-
import { isCI } from '../../lib/is-ci.js';
|
|
11
|
-
import { prepareDiffDirectory, copyDiffBuild } from '../../lib/template-diff.js';
|
|
12
|
-
import { getViteConfig } from '../../lib/vite-config.js';
|
|
13
|
-
|
|
14
|
-
const WORKER_BUILD_SIZE_LIMIT = 5;
|
|
15
|
-
class Build extends Command {
|
|
16
|
-
static description = "Builds a Hydrogen storefront for production.";
|
|
17
|
-
static flags = {
|
|
18
|
-
...commonFlags.path,
|
|
19
|
-
...commonFlags.entry,
|
|
20
|
-
...commonFlags.sourcemap,
|
|
21
|
-
...commonFlags.lockfileCheck,
|
|
22
|
-
...commonFlags.disableRouteWarning,
|
|
23
|
-
...commonFlags.codegen,
|
|
24
|
-
...commonFlags.diff
|
|
25
|
-
};
|
|
26
|
-
static hidden = true;
|
|
27
|
-
async run() {
|
|
28
|
-
const { flags } = await this.parse(Build);
|
|
29
|
-
const originalDirectory = flags.path ? resolvePath(flags.path) : process.cwd();
|
|
30
|
-
let directory = originalDirectory;
|
|
31
|
-
if (flags.diff) {
|
|
32
|
-
directory = await prepareDiffDirectory(originalDirectory, false);
|
|
33
|
-
}
|
|
34
|
-
await runViteBuild({
|
|
35
|
-
...flagsToCamelObject(flags),
|
|
36
|
-
useCodegen: flags.codegen,
|
|
37
|
-
directory
|
|
38
|
-
});
|
|
39
|
-
if (flags.diff) {
|
|
40
|
-
await copyDiffBuild(directory, originalDirectory);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
async function runViteBuild({
|
|
45
|
-
entry: ssrEntry,
|
|
46
|
-
directory,
|
|
47
|
-
useCodegen = false,
|
|
48
|
-
codegenConfigPath,
|
|
49
|
-
sourcemap = false,
|
|
50
|
-
disableRouteWarning = false,
|
|
51
|
-
lockfileCheck = true,
|
|
52
|
-
assetPath = "/"
|
|
53
|
-
}) {
|
|
54
|
-
if (!process.env.NODE_ENV) {
|
|
55
|
-
process.env.NODE_ENV = "production";
|
|
56
|
-
}
|
|
57
|
-
const root = directory ?? process.cwd();
|
|
58
|
-
if (lockfileCheck) {
|
|
59
|
-
await checkLockfileStatus(root, isCI());
|
|
60
|
-
}
|
|
61
|
-
const [
|
|
62
|
-
vite,
|
|
63
|
-
{ userViteConfig, remixConfig, clientOutDir, serverOutDir, serverOutFile }
|
|
64
|
-
] = await Promise.all([
|
|
65
|
-
// Avoid static imports because this file is imported by `deploy` command,
|
|
66
|
-
// which must have a hard dependency on 'vite'.
|
|
67
|
-
import('vite'),
|
|
68
|
-
getViteConfig(root, ssrEntry)
|
|
69
|
-
]);
|
|
70
|
-
const customLogger = vite.createLogger();
|
|
71
|
-
if (process.env.SHOPIFY_UNIT_TEST) {
|
|
72
|
-
customLogger.info = (msg) => collectLog("info", msg);
|
|
73
|
-
customLogger.warn = (msg) => collectLog("warn", msg);
|
|
74
|
-
customLogger.error = (msg) => collectLog("error", msg);
|
|
75
|
-
}
|
|
76
|
-
const serverMinify = userViteConfig.build?.minify ?? true;
|
|
77
|
-
const commonConfig = {
|
|
78
|
-
root,
|
|
79
|
-
mode: process.env.NODE_ENV,
|
|
80
|
-
base: assetPath,
|
|
81
|
-
customLogger
|
|
82
|
-
};
|
|
83
|
-
await vite.build({
|
|
84
|
-
...commonConfig,
|
|
85
|
-
build: {
|
|
86
|
-
emptyOutDir: true,
|
|
87
|
-
copyPublicDir: true,
|
|
88
|
-
// Disable client sourcemaps in production
|
|
89
|
-
sourcemap: process.env.NODE_ENV !== "production" && sourcemap
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
console.log("");
|
|
93
|
-
await vite.build({
|
|
94
|
-
...commonConfig,
|
|
95
|
-
build: {
|
|
96
|
-
sourcemap,
|
|
97
|
-
ssr: ssrEntry ?? true,
|
|
98
|
-
emptyOutDir: false,
|
|
99
|
-
copyPublicDir: false,
|
|
100
|
-
minify: serverMinify
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
await Promise.all([
|
|
104
|
-
removeFile(joinPath(clientOutDir, ".vite")),
|
|
105
|
-
removeFile(joinPath(serverOutDir, ".vite")),
|
|
106
|
-
removeFile(joinPath(serverOutDir, "assets"))
|
|
107
|
-
]);
|
|
108
|
-
if (useCodegen) {
|
|
109
|
-
await codegen({
|
|
110
|
-
rootDirectory: root,
|
|
111
|
-
appDirectory: remixConfig.appDirectory,
|
|
112
|
-
configFilePath: codegenConfigPath
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
if (process.env.NODE_ENV !== "development") {
|
|
116
|
-
const sizeMB = await fileSize(serverOutFile) / (1024 * 1024);
|
|
117
|
-
if (sizeMB >= WORKER_BUILD_SIZE_LIMIT) {
|
|
118
|
-
outputWarn(
|
|
119
|
-
`\u{1F6A8} Smaller worker bundles are faster to deploy and run.${serverMinify ? "" : "\n Minify your bundle by adding `build.minify: true` to vite.config.js."}
|
|
120
|
-
Learn more about optimizing your worker bundle file: https://h2o.fyi/debugging/bundle-size
|
|
121
|
-
`
|
|
122
|
-
);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
if (!disableRouteWarning) {
|
|
126
|
-
const missingRoutes = findMissingRoutes(remixConfig);
|
|
127
|
-
if (missingRoutes.length) {
|
|
128
|
-
const packageManager = await getPackageManager(root);
|
|
129
|
-
const exec = packageManager === "npm" ? "npx" : packageManager;
|
|
130
|
-
outputWarn(
|
|
131
|
-
`Heads up: Shopify stores have a number of standard routes that aren\u2019t set up yet.
|
|
132
|
-
Some functionality and backlinks might not work as expected until these are created or redirects are set up.
|
|
133
|
-
This build is missing ${missingRoutes.length} route${missingRoutes.length > 1 ? "s" : ""}. For more details, run \`${exec} shopify hydrogen check routes\`.
|
|
134
|
-
`
|
|
135
|
-
);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
export { Build as default, runViteBuild };
|