handoff-app 2.0.0-8 → 2.0.0-9

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 (34) hide show
  1. package/README.md +19 -3
  2. package/dist/catalog/normalize.js +3 -0
  3. package/dist/catalog/previews.js +5 -4
  4. package/dist/catalog/types.d.ts +8 -0
  5. package/dist/config/loader.js +2 -0
  6. package/dist/config/runtime.js +8 -10
  7. package/dist/handlebars.d.ts +10 -2
  8. package/dist/transformers/plugins/ssr-render.js +40 -15
  9. package/dist/transformers/preview/component/css.d.ts +1 -0
  10. package/dist/transformers/preview/component/css.js +85 -47
  11. package/dist/transformers/preview/pattern/html.js +3 -1
  12. package/dist/transformers/preview/types.d.ts +13 -0
  13. package/dist/transformers/utils/build.d.ts +19 -0
  14. package/dist/transformers/utils/build.js +83 -1
  15. package/dist/transformers/utils/module.js +2 -1
  16. package/dist/types/config.d.ts +6 -0
  17. package/package.json +1 -1
  18. package/src/app/components/Component/PageSliceResolver.tsx +1 -0
  19. package/src/app/components/Component/Preview.tsx +380 -189
  20. package/src/app/components/Component/slices/ComponentDisplaySlice.tsx +4 -0
  21. package/src/catalog/README.md +3 -0
  22. package/src/catalog/normalize.ts +2 -0
  23. package/src/catalog/previews.ts +6 -3
  24. package/src/catalog/types.ts +8 -0
  25. package/src/config/loader.ts +2 -0
  26. package/src/config/runtime.ts +9 -4
  27. package/src/handlebars.ts +8 -2
  28. package/src/transformers/plugins/ssr-render.ts +53 -16
  29. package/src/transformers/preview/component/css.ts +93 -50
  30. package/src/transformers/preview/pattern/html.ts +3 -1
  31. package/src/transformers/preview/types.ts +14 -0
  32. package/src/transformers/utils/build.ts +80 -0
  33. package/src/transformers/utils/module.ts +4 -2
  34. package/src/types/config.ts +6 -0
@@ -1,6 +1,6 @@
1
1
  import esbuild from 'esbuild';
2
2
  import { ModuleEvaluationResult } from '../types';
3
- import { DEFAULT_SSR_BUILD_CONFIG } from './build';
3
+ import { DEFAULT_SSR_BUILD_CONFIG, withStyleLoaders } from './build';
4
4
 
5
5
  function createModuleBuildConfig(entryPath: string, handoff: any): esbuild.BuildOptions {
6
6
  const defaultBuildConfig: esbuild.BuildOptions = {
@@ -8,9 +8,11 @@ function createModuleBuildConfig(entryPath: string, handoff: any): esbuild.Build
8
8
  entryPoints: [entryPath],
9
9
  };
10
10
 
11
- return handoff.config?.hooks?.ssrBuildConfig
11
+ const hookedBuildConfig = handoff.config?.hooks?.ssrBuildConfig
12
12
  ? handoff.config.hooks.ssrBuildConfig(defaultBuildConfig)
13
13
  : defaultBuildConfig;
14
+
15
+ return withStyleLoaders(hookedBuildConfig);
14
16
  }
15
17
 
16
18
  function evaluateBuiltModule(code: string): ModuleEvaluationResult {
@@ -275,6 +275,9 @@ export interface Config {
275
275
 
276
276
  /**
277
277
  * Optional hook to override the SSR build configuration used in the ssrRenderPlugin
278
+ *
279
+ * Stylesheet loaders are re-applied after this hook, so a `.css`/`.scss`/`.sass` import stays out
280
+ * of the JavaScript graph whatever the hook returns.
278
281
  * @param config - The default esbuild configuration
279
282
  * @returns Modified esbuild configuration
280
283
  * @example
@@ -289,6 +292,9 @@ export interface Config {
289
292
 
290
293
  /**
291
294
  * Optional hook to override the client-side build configuration used in the ssrRenderPlugin
295
+ *
296
+ * Stylesheet loaders are re-applied after this hook, so a `.css`/`.scss`/`.sass` import stays out
297
+ * of the JavaScript graph whatever the hook returns.
292
298
  * @param config - The default esbuild configuration
293
299
  * @returns Modified esbuild configuration
294
300
  * @example