shopify-accelerate-app 1.0.32 → 1.0.34

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shopify-accelerate-app",
3
- "version": "1.0.32",
3
+ "version": "1.0.34",
4
4
  "description": "Shopify App development with full Typescript Support",
5
5
  "author": "Felix Tellmann",
6
6
  "license": "MIT",
@@ -114,6 +114,36 @@ export const transformContent = (input, final = false, cssOutput = "") => {
114
114
 
115
115
  const current = { timeout: null };
116
116
 
117
+ import { Plugin } from "esbuild";
118
+
119
+ export const aliasReactPlugin: Plugin = {
120
+ name: "alias-react",
121
+ setup(build) {
122
+ const resolvePath = (mod: string) => path.dirname(require.resolve(`${mod}/package.json`, { paths: [process.cwd()] }));
123
+
124
+ const compatDir = resolvePath("preact");
125
+
126
+ const createAlias = (from: string, to: string) => {
127
+ build.onResolve({ filter: new RegExp(`^${from}$`) }, () => ({
128
+ path: to,
129
+ namespace: "alias",
130
+ }));
131
+ };
132
+
133
+ createAlias("react", "preact/compat");
134
+ createAlias("react-dom", "preact/compat");
135
+ createAlias("react-dom/test-utils", "preact/test-utils");
136
+
137
+ build.onLoad({ filter: /.*/, namespace: "alias" }, async (args) => {
138
+ return {
139
+ contents: `export * from '${args.path}'; export { default } from '${args.path}';`,
140
+ resolveDir: compatDir,
141
+ loader: "js",
142
+ };
143
+ });
144
+ },
145
+ };
146
+
117
147
  const runBlockJsEsbuild = async (entryFile, block: ShopifyAppBlock & { path: string; folder: string }) => {
118
148
  const startTime = Date.now();
119
149
  const folder = block.folder;
@@ -161,7 +191,9 @@ const runBlockJsEsbuild = async (entryFile, block: ShopifyAppBlock & { path: str
161
191
  jsxImportSource: "preact",
162
192
  jsxSideEffects: false,
163
193
  keepNames: false,
164
- plugins: [
194
+ plugins: [aliasReactPlugin],
195
+ external: ["preact"], // ← VERY IMPORTANT
196
+ /*plugins: [
165
197
  {
166
198
  name: "alias-react",
167
199
  setup(build) {
@@ -182,7 +214,7 @@ const runBlockJsEsbuild = async (entryFile, block: ShopifyAppBlock & { path: str
182
214
  namespace: "alias",
183
215
  }));
184
216
 
185
- build.onLoad({ filter: /.*/, namespace: "alias" }, async (args) => {
217
+ build.onLoad({ filter: /.*!/, namespace: "alias" }, async (args) => {
186
218
  const actualPath = require.resolve(args.path, {
187
219
  paths: [process.cwd()],
188
220
  });
@@ -195,7 +227,7 @@ const runBlockJsEsbuild = async (entryFile, block: ShopifyAppBlock & { path: str
195
227
  });
196
228
  },
197
229
  },
198
- ],
230
+ ],*/
199
231
 
200
232
  // splitting: true,
201
233
  })