@ecopages/core 0.2.0-alpha.8 → 0.2.1
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 +18 -11
- package/README.md +23 -26
- package/package.json +76 -58
- package/src/adapters/README.md +2 -2
- package/src/adapters/abstract/application-adapter.d.ts +28 -2
- package/src/adapters/abstract/application-adapter.js +14 -2
- package/src/adapters/abstract/router-adapter.d.ts +1 -1
- package/src/adapters/abstract/server-adapter.d.ts +2 -2
- package/src/adapters/bun/client-bridge.d.ts +1 -1
- package/src/adapters/bun/create-app.d.ts +4 -12
- package/src/adapters/bun/create-app.js +4 -5
- package/src/adapters/bun/hmr-manager.d.ts +4 -4
- package/src/adapters/bun/hmr-manager.js +8 -8
- package/src/adapters/bun/index.d.ts +1 -1
- package/src/adapters/bun/index.js +2 -2
- package/src/adapters/bun/server-adapter.d.ts +5 -5
- package/src/adapters/bun/server-adapter.js +6 -5
- package/src/adapters/bun/server-lifecycle.d.ts +4 -4
- package/src/adapters/bun/server-lifecycle.js +2 -2
- package/src/{create-app.d.ts → adapters/create-app.d.ts} +9 -6
- package/src/{create-app.js → adapters/create-app.js} +4 -4
- package/src/adapters/index.d.ts +1 -5
- package/src/adapters/index.js +1 -7
- package/src/adapters/node/create-app.d.ts +6 -9
- package/src/adapters/node/create-app.js +12 -6
- package/src/adapters/node/node-client-bridge.d.ts +1 -1
- package/src/adapters/node/node-hmr-manager.d.ts +2 -2
- package/src/adapters/node/node-hmr-manager.js +3 -3
- package/src/adapters/node/server-adapter.d.ts +4 -4
- package/src/adapters/node/server-adapter.js +13 -12
- package/src/adapters/node/static-content-server.d.ts +1 -1
- package/src/adapters/node/static-content-server.js +1 -1
- package/src/adapters/shared/application-adapter.d.ts +1 -1
- package/src/adapters/shared/define-api-handler.d.ts +1 -1
- package/src/adapters/shared/explicit-static-route-matcher.d.ts +2 -2
- package/src/adapters/shared/file-route-middleware-pipeline.d.ts +1 -1
- package/src/adapters/shared/fs-server-response-factory.d.ts +2 -2
- package/src/adapters/shared/fs-server-response-factory.js +1 -1
- package/src/adapters/shared/fs-server-response-matcher.d.ts +1 -1
- package/src/adapters/shared/hmr-entrypoint-registrar.js +1 -1
- package/src/adapters/shared/hmr-html-response.d.ts +1 -1
- package/src/adapters/shared/render-context.d.ts +2 -1
- package/src/adapters/shared/render-context.js +3 -1
- package/src/adapters/shared/runtime-bootstrap.d.ts +1 -1
- package/src/adapters/shared/runtime-bootstrap.js +1 -1
- package/src/adapters/shared/server-adapter.d.ts +1 -1
- package/src/adapters/shared/server-adapter.js +5 -1
- package/src/adapters/shared/server-route-handler.d.ts +4 -4
- package/src/adapters/shared/server-route-handler.js +3 -3
- package/src/adapters/shared/server-static-builder.d.ts +5 -5
- package/src/adapters/shared/server-static-builder.js +5 -4
- package/src/build/README.md +19 -13
- package/src/build/build-adapter.d.ts +67 -20
- package/src/build/build-adapter.js +420 -19
- package/src/build/dev-build-coordinator.d.ts +10 -12
- package/src/build/dev-build-coordinator.js +8 -15
- package/src/build/esbuild-build-adapter.d.ts +6 -0
- package/src/build/esbuild-build-adapter.js +94 -11
- package/src/build/runtime-build-executor.d.ts +5 -4
- package/src/build/runtime-build-executor.js +5 -3
- package/src/build/runtime-specifier-alias-plugin.js +19 -15
- package/src/build/runtime-specifier-aliases.d.ts +5 -0
- package/src/build/runtime-specifier-aliases.js +95 -0
- package/src/config/README.md +5 -2
- package/src/config/config-builder.d.ts +25 -2
- package/src/config/config-builder.js +44 -7
- package/src/declarations.d.ts +1 -1
- package/src/dev/sc-server.d.ts +1 -1
- package/src/dev/sc-server.js +1 -1
- package/src/eco/eco.browser.d.ts +2 -0
- package/src/eco/eco.browser.js +83 -0
- package/src/eco/eco.js +19 -48
- package/src/eco/eco.types.d.ts +1 -1
- package/src/eco/eco.utils.d.ts +1 -40
- package/src/eco/eco.utils.js +5 -35
- package/src/eco/global-injector-map.d.ts +1 -1
- package/src/eco/lazy-injector-map.d.ts +1 -1
- package/src/hmr/hmr-strategy.d.ts +16 -13
- package/src/hmr/hmr-strategy.js +22 -7
- package/src/hmr/strategies/default-hmr-strategy.d.ts +2 -2
- package/src/hmr/strategies/default-hmr-strategy.js +1 -1
- package/src/hmr/strategies/js-hmr-strategy.d.ts +2 -2
- package/src/hmr/strategies/js-hmr-strategy.js +2 -2
- package/src/index.browser.d.ts +2 -2
- package/src/index.browser.js +1 -1
- package/src/index.d.ts +3 -2
- package/src/index.js +15 -4
- package/src/integrations/ghtml/ghtml-renderer.d.ts +6 -1
- package/src/integrations/ghtml/ghtml-renderer.js +29 -28
- package/src/integrations/ghtml/ghtml.plugin.d.ts +2 -2
- package/src/integrations/ghtml/ghtml.plugin.js +2 -2
- package/src/plugins/README.md +1 -0
- package/src/plugins/eco-component-meta-plugin.d.ts +12 -1
- package/src/plugins/eco-component-meta-plugin.js +26 -20
- package/src/plugins/foreign-jsx-override-plugin.d.ts +31 -0
- package/src/plugins/foreign-jsx-override-plugin.js +35 -0
- package/src/plugins/integration-plugin.d.ts +99 -33
- package/src/plugins/integration-plugin.js +68 -21
- package/src/plugins/processor.d.ts +2 -2
- package/src/plugins/processor.js +2 -2
- package/src/plugins/source-transform.d.ts +46 -0
- package/src/plugins/source-transform.js +71 -0
- package/src/route-renderer/GRAPH.md +54 -84
- package/src/route-renderer/README.md +14 -20
- package/src/route-renderer/orchestration/component-render-context.d.ts +83 -0
- package/src/route-renderer/orchestration/component-render-context.js +147 -0
- package/src/route-renderer/orchestration/integration-renderer.d.ts +233 -76
- package/src/route-renderer/orchestration/integration-renderer.js +500 -143
- package/src/route-renderer/orchestration/queued-boundary-runtime.service.d.ts +93 -0
- package/src/route-renderer/orchestration/queued-boundary-runtime.service.js +155 -0
- package/src/route-renderer/orchestration/render-execution.service.d.ts +11 -71
- package/src/route-renderer/orchestration/render-execution.service.js +65 -80
- package/src/{eco/eco.utils.ts → route-renderer/orchestration/render-output.utils.d.ts} +10 -53
- package/src/route-renderer/orchestration/render-output.utils.js +65 -0
- package/src/route-renderer/orchestration/render-preparation.service.d.ts +2 -8
- package/src/route-renderer/orchestration/render-preparation.service.js +10 -17
- package/src/route-renderer/orchestration/template-serialization.d.ts +38 -0
- package/src/route-renderer/orchestration/template-serialization.js +45 -0
- package/src/route-renderer/page-loading/dependency-resolver.d.ts +2 -2
- package/src/route-renderer/page-loading/dependency-resolver.js +10 -8
- package/src/route-renderer/page-loading/page-module-loader.d.ts +6 -4
- package/src/route-renderer/page-loading/page-module-loader.js +7 -5
- package/src/route-renderer/route-renderer.d.ts +5 -3
- package/src/route-renderer/route-renderer.js +13 -3
- package/src/router/README.md +79 -8
- package/src/router/client/navigation-coordinator.js +2 -2
- package/src/router/server/fs-router-scanner.d.ts +1 -1
- package/src/router/server/fs-router-scanner.js +6 -1
- package/src/router/server/fs-router.d.ts +1 -1
- package/src/services/assets/asset-processing-service/asset-processing.service.d.ts +3 -3
- package/src/services/assets/asset-processing-service/asset-processing.service.js +6 -6
- package/src/services/assets/asset-processing-service/asset.factory.d.ts +1 -1
- package/src/services/assets/asset-processing-service/asset.factory.js +2 -2
- package/src/services/assets/asset-processing-service/index.d.ts +5 -5
- package/src/services/assets/asset-processing-service/index.js +5 -5
- package/src/services/assets/asset-processing-service/processor.interface.d.ts +2 -2
- package/src/services/assets/asset-processing-service/processor.registry.d.ts +2 -2
- package/src/services/assets/asset-processing-service/processors/base/base-processor.d.ts +1 -1
- package/src/services/assets/asset-processing-service/processors/base/base-processor.js +1 -1
- package/src/services/assets/asset-processing-service/processors/base/base-script-processor.d.ts +3 -3
- package/src/services/assets/asset-processing-service/processors/base/base-script-processor.js +2 -2
- package/src/services/assets/asset-processing-service/processors/index.d.ts +5 -5
- package/src/services/assets/asset-processing-service/processors/index.js +5 -5
- package/src/services/assets/asset-processing-service/processors/script/content-script.processor.d.ts +2 -2
- package/src/services/assets/asset-processing-service/processors/script/content-script.processor.js +1 -1
- package/src/services/assets/asset-processing-service/processors/script/file-script.processor.d.ts +4 -3
- package/src/services/assets/asset-processing-service/processors/script/file-script.processor.js +15 -3
- package/src/services/assets/asset-processing-service/processors/script/node-module-script.processor.d.ts +3 -3
- package/src/services/assets/asset-processing-service/processors/script/node-module-script.processor.js +1 -1
- package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.d.ts +2 -2
- package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.js +1 -1
- package/src/services/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.d.ts +2 -2
- package/src/services/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.js +1 -1
- package/src/services/assets/browser-bundle.service.d.ts +1 -1
- package/src/services/assets/browser-bundle.service.js +2 -2
- package/src/services/html/html-rewriter-provider.service.js +4 -1
- package/src/services/html/html-transformer.service.d.ts +2 -2
- package/src/services/html/html-transformer.service.js +4 -10
- package/src/services/invalidation/development-invalidation.service.d.ts +1 -1
- package/src/services/invalidation/development-invalidation.service.js +1 -0
- package/src/services/module-loading/app-module-loader.service.d.ts +25 -0
- package/src/services/module-loading/app-module-loader.service.js +31 -0
- package/src/services/module-loading/app-server-module-transpiler.service.d.ts +9 -1
- package/src/services/module-loading/app-server-module-transpiler.service.js +77 -2
- package/src/services/module-loading/host-module-loader-registry.d.ts +4 -0
- package/src/services/module-loading/host-module-loader-registry.js +15 -0
- package/src/services/module-loading/module-loading-types.d.ts +2 -0
- package/src/{adapters/node/bootstrap-dependency-resolver.d.ts → services/module-loading/node-bootstrap-plugin.d.ts} +2 -24
- package/src/{adapters/node/bootstrap-dependency-resolver.js → services/module-loading/node-bootstrap-plugin.js} +42 -22
- package/src/services/module-loading/page-module-import.service.d.ts +4 -0
- package/src/services/module-loading/page-module-import.service.js +38 -9
- package/src/services/module-loading/server-module-transpiler.service.d.ts +3 -0
- package/src/services/module-loading/server-module-transpiler.service.js +4 -1
- package/src/services/runtime-state/dev-graph.service.d.ts +6 -6
- package/src/services/runtime-state/dev-graph.service.js +10 -10
- package/src/services/runtime-state/entrypoint-dependency-graph.service.d.ts +1 -1
- package/src/services/runtime-state/runtime-specifier-registry.service.d.ts +1 -1
- package/src/services/runtime-state/server-invalidation-state.service.d.ts +1 -1
- package/src/static-site-generator/static-site-generator.d.ts +2 -2
- package/src/static-site-generator/static-site-generator.js +1 -1
- package/src/{internal-types.d.ts → types/internal-types.d.ts} +24 -14
- package/src/{public-types.d.ts → types/public-types.d.ts} +30 -14
- package/src/types/public-types.js +0 -0
- package/src/utils/html-escaping.d.ts +7 -0
- package/src/utils/html-escaping.js +6 -0
- package/src/utils/locals-utils.d.ts +1 -1
- package/src/utils/parse-cli-args.d.ts +4 -1
- package/src/utils/parse-cli-args.js +16 -1
- package/src/utils/resolve-work-dir.js +1 -1
- package/src/watchers/project-watcher.d.ts +4 -4
- package/src/watchers/project-watcher.js +4 -10
- package/src/watchers/project-watcher.test-helpers.d.ts +2 -2
- package/src/adapters/abstract/application-adapter.ts +0 -337
- package/src/adapters/abstract/router-adapter.ts +0 -30
- package/src/adapters/abstract/server-adapter.ts +0 -79
- package/src/adapters/bun/client-bridge.ts +0 -62
- package/src/adapters/bun/create-app.ts +0 -189
- package/src/adapters/bun/hmr-manager.ts +0 -409
- package/src/adapters/bun/index.ts +0 -2
- package/src/adapters/bun/server-adapter.ts +0 -499
- package/src/adapters/bun/server-lifecycle.ts +0 -124
- package/src/adapters/index.ts +0 -6
- package/src/adapters/node/bootstrap-dependency-resolver.ts +0 -301
- package/src/adapters/node/create-app.ts +0 -179
- package/src/adapters/node/index.d.ts +0 -6
- package/src/adapters/node/index.js +0 -11
- package/src/adapters/node/index.ts +0 -16
- package/src/adapters/node/node-client-bridge.ts +0 -79
- package/src/adapters/node/node-hmr-manager.ts +0 -381
- package/src/adapters/node/runtime-adapter.d.ts +0 -46
- package/src/adapters/node/runtime-adapter.js +0 -306
- package/src/adapters/node/runtime-adapter.ts +0 -439
- package/src/adapters/node/server-adapter.ts +0 -488
- package/src/adapters/node/static-content-server.ts +0 -239
- package/src/adapters/node/write-runtime-manifest.d.ts +0 -26
- package/src/adapters/node/write-runtime-manifest.js +0 -12
- package/src/adapters/node/write-runtime-manifest.ts +0 -38
- package/src/adapters/shared/api-response.ts +0 -104
- package/src/adapters/shared/application-adapter.ts +0 -199
- package/src/adapters/shared/define-api-handler.ts +0 -66
- package/src/adapters/shared/explicit-static-route-matcher.ts +0 -140
- package/src/adapters/shared/file-route-middleware-pipeline.ts +0 -127
- package/src/adapters/shared/fs-server-response-factory.ts +0 -118
- package/src/adapters/shared/fs-server-response-matcher.ts +0 -205
- package/src/adapters/shared/hmr-entrypoint-registrar.ts +0 -149
- package/src/adapters/shared/hmr-html-response.ts +0 -52
- package/src/adapters/shared/render-context.ts +0 -120
- package/src/adapters/shared/runtime-bootstrap.ts +0 -79
- package/src/adapters/shared/server-adapter.ts +0 -489
- package/src/adapters/shared/server-route-handler.ts +0 -153
- package/src/adapters/shared/server-static-builder.ts +0 -166
- package/src/build/build-adapter.ts +0 -361
- package/src/build/build-manifest.ts +0 -54
- package/src/build/build-types.ts +0 -83
- package/src/build/dev-build-coordinator.ts +0 -221
- package/src/build/esbuild-build-adapter.ts +0 -559
- package/src/build/runtime-build-executor.ts +0 -34
- package/src/build/runtime-specifier-alias-plugin.ts +0 -58
- package/src/config/config-builder.ts +0 -706
- package/src/constants.ts +0 -54
- package/src/create-app.ts +0 -87
- package/src/dev/sc-server.ts +0 -143
- package/src/eco/component-render-context.d.ts +0 -105
- package/src/eco/component-render-context.js +0 -87
- package/src/eco/component-render-context.ts +0 -224
- package/src/eco/eco.ts +0 -242
- package/src/eco/eco.types.ts +0 -221
- package/src/eco/global-injector-map.ts +0 -112
- package/src/eco/lazy-injector-map.ts +0 -120
- package/src/eco/module-dependencies.ts +0 -75
- package/src/errors/http-error.ts +0 -72
- package/src/errors/index.ts +0 -2
- package/src/errors/locals-access-error.ts +0 -7
- package/src/global/app-logger.ts +0 -4
- package/src/hmr/client/hmr-runtime.ts +0 -152
- package/src/hmr/hmr-strategy.ts +0 -172
- package/src/hmr/hmr.postcss.test.e2e.ts +0 -41
- package/src/hmr/hmr.test.e2e.ts +0 -66
- package/src/hmr/strategies/default-hmr-strategy.ts +0 -60
- package/src/hmr/strategies/js-hmr-strategy.ts +0 -320
- package/src/index.browser.ts +0 -3
- package/src/index.ts +0 -5
- package/src/integrations/ghtml/ghtml-renderer.ts +0 -96
- package/src/integrations/ghtml/ghtml.plugin.ts +0 -32
- package/src/internal-types.ts +0 -232
- package/src/plugins/alias-resolver-plugin.ts +0 -63
- package/src/plugins/eco-component-meta-plugin.ts +0 -481
- package/src/plugins/integration-plugin.ts +0 -226
- package/src/plugins/processor.ts +0 -240
- package/src/plugins/runtime-capability.ts +0 -14
- package/src/public-types.ts +0 -1317
- package/src/route-renderer/component-graph/component-graph-executor.d.ts +0 -32
- package/src/route-renderer/component-graph/component-graph-executor.js +0 -31
- package/src/route-renderer/component-graph/component-graph-executor.ts +0 -84
- package/src/route-renderer/component-graph/component-graph.d.ts +0 -42
- package/src/route-renderer/component-graph/component-graph.js +0 -72
- package/src/route-renderer/component-graph/component-graph.ts +0 -159
- package/src/route-renderer/component-graph/component-marker.d.ts +0 -52
- package/src/route-renderer/component-graph/component-marker.js +0 -46
- package/src/route-renderer/component-graph/component-marker.ts +0 -117
- package/src/route-renderer/component-graph/component-reference.d.ts +0 -10
- package/src/route-renderer/component-graph/component-reference.js +0 -19
- package/src/route-renderer/component-graph/component-reference.ts +0 -29
- package/src/route-renderer/component-graph/marker-graph-resolver.d.ts +0 -77
- package/src/route-renderer/component-graph/marker-graph-resolver.js +0 -95
- package/src/route-renderer/component-graph/marker-graph-resolver.ts +0 -155
- package/src/route-renderer/orchestration/integration-renderer.ts +0 -790
- package/src/route-renderer/orchestration/render-execution.service.ts +0 -230
- package/src/route-renderer/orchestration/render-preparation.service.ts +0 -476
- package/src/route-renderer/page-loading/dependency-resolver.ts +0 -612
- package/src/route-renderer/page-loading/page-module-loader.ts +0 -181
- package/src/route-renderer/route-renderer.ts +0 -115
- package/src/router/client/link-intent.test.browser.ts +0 -51
- package/src/router/client/link-intent.ts +0 -92
- package/src/router/client/navigation-coordinator.ts +0 -433
- package/src/router/server/fs-router-scanner.ts +0 -219
- package/src/router/server/fs-router.ts +0 -122
- package/src/services/assets/asset-processing-service/asset-processing.service.ts +0 -401
- package/src/services/assets/asset-processing-service/asset.factory.ts +0 -105
- package/src/services/assets/asset-processing-service/assets.types.ts +0 -113
- package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.ts +0 -95
- package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.ts +0 -78
- package/src/services/assets/asset-processing-service/index.ts +0 -5
- package/src/services/assets/asset-processing-service/processor.interface.ts +0 -27
- package/src/services/assets/asset-processing-service/processor.registry.ts +0 -18
- package/src/services/assets/asset-processing-service/processors/base/base-processor.ts +0 -82
- package/src/services/assets/asset-processing-service/processors/base/base-script-processor.ts +0 -95
- package/src/services/assets/asset-processing-service/processors/index.ts +0 -5
- package/src/services/assets/asset-processing-service/processors/script/content-script.processor.ts +0 -66
- package/src/services/assets/asset-processing-service/processors/script/file-script.processor.ts +0 -88
- package/src/services/assets/asset-processing-service/processors/script/node-module-script.processor.ts +0 -85
- package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.ts +0 -27
- package/src/services/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.ts +0 -80
- package/src/services/assets/browser-bundle.service.ts +0 -53
- package/src/services/cache/cache.types.ts +0 -126
- package/src/services/cache/index.ts +0 -18
- package/src/services/cache/memory-cache-store.ts +0 -130
- package/src/services/cache/page-cache-service.ts +0 -202
- package/src/services/cache/page-request-cache-coordinator.service.ts +0 -131
- package/src/services/html/html-rewriter-provider.service.ts +0 -103
- package/src/services/html/html-transformer.service.ts +0 -279
- package/src/services/invalidation/development-invalidation.service.ts +0 -261
- package/src/services/module-loading/app-server-module-transpiler.service.ts +0 -52
- package/src/services/module-loading/page-module-import.service.ts +0 -200
- package/src/services/module-loading/server-loader.service.d.ts +0 -96
- package/src/services/module-loading/server-loader.service.js +0 -32
- package/src/services/module-loading/server-loader.service.ts +0 -130
- package/src/services/module-loading/server-module-transpiler.service.ts +0 -105
- package/src/services/runtime-manifest/node-runtime-manifest.service.d.ts +0 -35
- package/src/services/runtime-manifest/node-runtime-manifest.service.js +0 -60
- package/src/services/runtime-manifest/node-runtime-manifest.service.ts +0 -101
- package/src/services/runtime-state/dev-graph.service.ts +0 -217
- package/src/services/runtime-state/entrypoint-dependency-graph.service.ts +0 -136
- package/src/services/runtime-state/runtime-specifier-registry.service.ts +0 -96
- package/src/services/runtime-state/server-invalidation-state.service.ts +0 -68
- package/src/services/validation/schema-validation-service.ts +0 -204
- package/src/services/validation/standard-schema.types.ts +0 -68
- package/src/static-site-generator/static-site-generator.ts +0 -462
- package/src/utils/css.d.ts +0 -1
- package/src/utils/css.js +0 -7
- package/src/utils/css.ts +0 -5
- package/src/utils/deep-merge.ts +0 -47
- package/src/utils/hash.ts +0 -5
- package/src/utils/html.ts +0 -1
- package/src/utils/invariant.ts +0 -15
- package/src/utils/locals-utils.ts +0 -37
- package/src/utils/parse-cli-args.ts +0 -83
- package/src/utils/path-utils.module.ts +0 -14
- package/src/utils/resolve-work-dir.ts +0 -45
- package/src/utils/runtime.ts +0 -44
- package/src/utils/server-utils.module.ts +0 -67
- package/src/watchers/project-watcher.test-helpers.ts +0 -41
- package/src/watchers/project-watcher.ts +0 -363
- /package/src/{constants.d.ts → config/constants.d.ts} +0 -0
- /package/src/{constants.js → config/constants.js} +0 -0
- /package/src/{internal-types.js → services/module-loading/module-loading-types.js} +0 -0
- /package/src/{public-types.js → types/internal-types.js} +0 -0
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import type { EcoBuildPlugin } from '../../../build/build-types.ts';
|
|
2
|
-
|
|
3
|
-
export type AssetSource = 'content' | 'file' | 'node-module';
|
|
4
|
-
export type AssetKind = 'script' | 'stylesheet';
|
|
5
|
-
export type AssetPosition = 'head' | 'body';
|
|
6
|
-
|
|
7
|
-
export interface BaseAsset {
|
|
8
|
-
kind: AssetKind;
|
|
9
|
-
source: AssetSource;
|
|
10
|
-
attributes?: Record<string, string>;
|
|
11
|
-
position?: AssetPosition;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export interface ScriptAsset extends BaseAsset {
|
|
15
|
-
kind: 'script';
|
|
16
|
-
inline?: boolean;
|
|
17
|
-
bundle?: boolean;
|
|
18
|
-
bundleOptions?: {
|
|
19
|
-
define?: Record<string, string>;
|
|
20
|
-
minify?: boolean;
|
|
21
|
-
external?: string[];
|
|
22
|
-
naming?: string;
|
|
23
|
-
plugins?: EcoBuildPlugin[];
|
|
24
|
-
};
|
|
25
|
-
/**
|
|
26
|
-
* Whether to exclude this asset from the HTML output.
|
|
27
|
-
* @default false
|
|
28
|
-
*/
|
|
29
|
-
excludeFromHtml?: boolean;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export interface StylesheetAsset extends BaseAsset {
|
|
33
|
-
kind: 'stylesheet';
|
|
34
|
-
inline?: boolean;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export interface ContentScriptAsset extends ScriptAsset {
|
|
38
|
-
source: 'content';
|
|
39
|
-
content: string;
|
|
40
|
-
name?: string;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export interface InlineContentScriptAsset extends ContentScriptAsset {
|
|
44
|
-
inline: true;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export interface ContentStylesheetAsset extends StylesheetAsset {
|
|
48
|
-
source: 'content';
|
|
49
|
-
content: string;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export interface InlineContentStylesheetAsset extends ContentStylesheetAsset {
|
|
53
|
-
inline: true;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export interface FileScriptAsset extends ScriptAsset {
|
|
57
|
-
source: 'file';
|
|
58
|
-
filepath: string;
|
|
59
|
-
name?: string;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export interface InlineFileScriptAsset extends FileScriptAsset {
|
|
63
|
-
inline: true;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export interface FileStylesheetAsset extends StylesheetAsset {
|
|
67
|
-
source: 'file';
|
|
68
|
-
filepath: string;
|
|
69
|
-
name?: string;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export interface InlineFileStylesheetAsset extends FileStylesheetAsset {
|
|
73
|
-
inline: true;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export interface NodeModuleScriptAsset extends ScriptAsset {
|
|
77
|
-
kind: 'script';
|
|
78
|
-
source: 'node-module';
|
|
79
|
-
importPath: string;
|
|
80
|
-
name?: string;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export interface InlineNodeModuleScriptAsset extends NodeModuleScriptAsset {
|
|
84
|
-
inline: true;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export interface InlineNodeModuleScriptAsset extends NodeModuleScriptAsset {
|
|
88
|
-
inline: true;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
export interface JsonScriptAsset extends ScriptAsset {
|
|
92
|
-
source: 'content';
|
|
93
|
-
content: string;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
export type ProcessedAsset = {
|
|
97
|
-
filepath?: string;
|
|
98
|
-
srcUrl?: string;
|
|
99
|
-
content?: string;
|
|
100
|
-
kind: AssetKind;
|
|
101
|
-
position?: AssetPosition;
|
|
102
|
-
attributes?: Record<string, string>;
|
|
103
|
-
inline?: boolean;
|
|
104
|
-
excludeFromHtml?: boolean;
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
export type AssetDefinition =
|
|
108
|
-
| ContentScriptAsset
|
|
109
|
-
| FileScriptAsset
|
|
110
|
-
| NodeModuleScriptAsset
|
|
111
|
-
| JsonScriptAsset
|
|
112
|
-
| ContentStylesheetAsset
|
|
113
|
-
| FileStylesheetAsset;
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import type { EcoBuildPlugin } from '../../../build/build-types.ts';
|
|
2
|
-
import { AssetFactory } from './asset.factory.ts';
|
|
3
|
-
import type { AssetDefinition } from './assets.types.ts';
|
|
4
|
-
import {
|
|
5
|
-
createBrowserRuntimeEntryModule,
|
|
6
|
-
type BrowserRuntimeEntryModuleConfig,
|
|
7
|
-
} from './browser-runtime-entry.factory.ts';
|
|
8
|
-
|
|
9
|
-
export const BROWSER_RUNTIME_SCRIPT_ATTRIBUTES = {
|
|
10
|
-
type: 'module',
|
|
11
|
-
defer: '',
|
|
12
|
-
} as const;
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Builds the public vendor URL used for generated browser runtime assets.
|
|
16
|
-
*/
|
|
17
|
-
export function buildBrowserRuntimeAssetUrl(fileName: string): string {
|
|
18
|
-
return `/${AssetFactory.RESOLVED_ASSETS_VENDORS_DIR}/${fileName}`;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Declares a browser runtime script asset backed by one importable module.
|
|
23
|
-
*
|
|
24
|
-
* @remarks
|
|
25
|
-
* Runtime assets are emitted as excluded head scripts because integrations often
|
|
26
|
-
* need the bundler output and specifier registration without injecting the raw
|
|
27
|
-
* asset directly into HTML during dependency resolution.
|
|
28
|
-
*/
|
|
29
|
-
export function createBrowserRuntimeScriptAsset(options: {
|
|
30
|
-
importPath: string;
|
|
31
|
-
name: string;
|
|
32
|
-
fileName: string;
|
|
33
|
-
bundleOptions?: {
|
|
34
|
-
define?: Record<string, string>;
|
|
35
|
-
minify?: boolean;
|
|
36
|
-
external?: string[];
|
|
37
|
-
naming?: string;
|
|
38
|
-
plugins?: EcoBuildPlugin[];
|
|
39
|
-
};
|
|
40
|
-
attributes?: Record<string, string>;
|
|
41
|
-
}): AssetDefinition {
|
|
42
|
-
return AssetFactory.createNodeModuleScript({
|
|
43
|
-
position: 'head',
|
|
44
|
-
importPath: options.importPath,
|
|
45
|
-
name: options.name,
|
|
46
|
-
excludeFromHtml: true,
|
|
47
|
-
bundleOptions: {
|
|
48
|
-
naming: options.fileName,
|
|
49
|
-
...options.bundleOptions,
|
|
50
|
-
},
|
|
51
|
-
attributes: {
|
|
52
|
-
...BROWSER_RUNTIME_SCRIPT_ATTRIBUTES,
|
|
53
|
-
...(options.attributes ?? {}),
|
|
54
|
-
},
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Creates a browser runtime asset from a generated re-export entry module.
|
|
60
|
-
*
|
|
61
|
-
* @remarks
|
|
62
|
-
* This is the shared "module list -> generated entry file -> runtime asset"
|
|
63
|
-
* path used by integrations that need browser-side runtime bundles without
|
|
64
|
-
* owning bespoke entry-file generation logic.
|
|
65
|
-
*/
|
|
66
|
-
export function createBrowserRuntimeModuleAsset(options: {
|
|
67
|
-
modules: BrowserRuntimeEntryModuleConfig[];
|
|
68
|
-
name: string;
|
|
69
|
-
fileName: string;
|
|
70
|
-
cacheDirName?: string;
|
|
71
|
-
rootDir?: string;
|
|
72
|
-
bundleOptions?: {
|
|
73
|
-
define?: Record<string, string>;
|
|
74
|
-
minify?: boolean;
|
|
75
|
-
external?: string[];
|
|
76
|
-
naming?: string;
|
|
77
|
-
plugins?: EcoBuildPlugin[];
|
|
78
|
-
};
|
|
79
|
-
attributes?: Record<string, string>;
|
|
80
|
-
}): AssetDefinition {
|
|
81
|
-
const importPath = createBrowserRuntimeEntryModule({
|
|
82
|
-
modules: options.modules,
|
|
83
|
-
fileName: `${options.name}-entry.mjs`,
|
|
84
|
-
rootDir: options.rootDir,
|
|
85
|
-
cacheDirName: options.cacheDirName,
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
return createBrowserRuntimeScriptAsset({
|
|
89
|
-
importPath,
|
|
90
|
-
name: options.name,
|
|
91
|
-
fileName: options.fileName,
|
|
92
|
-
bundleOptions: options.bundleOptions,
|
|
93
|
-
attributes: options.attributes,
|
|
94
|
-
});
|
|
95
|
-
}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import { createRequire } from 'node:module';
|
|
4
|
-
|
|
5
|
-
export type BrowserRuntimeEntryModuleConfig = {
|
|
6
|
-
specifier: string;
|
|
7
|
-
defaultExport?: boolean;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Creates a generated ESM entry module that re-exports runtime modules through
|
|
12
|
-
* one stable file.
|
|
13
|
-
*
|
|
14
|
-
* @remarks
|
|
15
|
-
* Integrations use this helper when they need a browser runtime asset composed
|
|
16
|
-
* from multiple bare specifiers but do not want to own temporary file assembly
|
|
17
|
-
* logic themselves. The generated file lives under a cache directory inside the
|
|
18
|
-
* consuming app root so repeated runs can reuse the same location.
|
|
19
|
-
*/
|
|
20
|
-
export function createBrowserRuntimeEntryModule(options: {
|
|
21
|
-
modules: BrowserRuntimeEntryModuleConfig[];
|
|
22
|
-
fileName: string;
|
|
23
|
-
rootDir?: string;
|
|
24
|
-
cacheDirName?: string;
|
|
25
|
-
}): string {
|
|
26
|
-
const rootDir = options.rootDir ?? process.cwd();
|
|
27
|
-
const artifactsDir = path.join(
|
|
28
|
-
rootDir,
|
|
29
|
-
'node_modules',
|
|
30
|
-
'.cache',
|
|
31
|
-
options.cacheDirName ?? 'ecopages-browser-runtime',
|
|
32
|
-
);
|
|
33
|
-
fs.mkdirSync(artifactsDir, { recursive: true });
|
|
34
|
-
|
|
35
|
-
const requireFromRoot = createRequire(path.join(rootDir, 'package.json'));
|
|
36
|
-
const seenExports = new Set<string>();
|
|
37
|
-
const statements: string[] = [];
|
|
38
|
-
|
|
39
|
-
for (const module of options.modules) {
|
|
40
|
-
if (module.defaultExport) {
|
|
41
|
-
statements.push(`import __ecopages_default_export__ from '${module.specifier}';`);
|
|
42
|
-
statements.push('export default __ecopages_default_export__;');
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const exportNames = getModuleExportNames(module.specifier, requireFromRoot).filter(
|
|
46
|
-
(name) => !seenExports.has(name),
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
if (exportNames.length > 0) {
|
|
50
|
-
statements.push(`export { ${exportNames.join(', ')} } from '${module.specifier}';`);
|
|
51
|
-
for (const exportName of exportNames) {
|
|
52
|
-
seenExports.add(exportName);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const filePath = path.join(artifactsDir, options.fileName);
|
|
58
|
-
fs.writeFileSync(filePath, statements.join('\n'), 'utf-8');
|
|
59
|
-
return filePath;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Reads the named runtime exports that should be re-exported from a generated
|
|
64
|
-
* runtime entry module.
|
|
65
|
-
*
|
|
66
|
-
* @remarks
|
|
67
|
-
* Default exports are handled separately because generated runtime entry files
|
|
68
|
-
* need to emit a synthetic default binding only when the caller explicitly asks
|
|
69
|
-
* for it.
|
|
70
|
-
*/
|
|
71
|
-
function getModuleExportNames(specifier: string, requireFromRoot: ReturnType<typeof createRequire>): string[] {
|
|
72
|
-
const moduleExports = requireFromRoot(specifier);
|
|
73
|
-
|
|
74
|
-
return Object.keys(moduleExports)
|
|
75
|
-
.filter((name) => name !== '__esModule' && name !== 'default')
|
|
76
|
-
.filter((name) => /^[$A-Z_a-z][$\w]*$/.test(name))
|
|
77
|
-
.sort();
|
|
78
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { IHmrManager } from '../../../internal-types';
|
|
2
|
-
import type { AssetDefinition, ProcessedAsset } from './assets.types';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Base interface for asset processors.
|
|
6
|
-
* Processors transform asset definitions into processed assets.
|
|
7
|
-
*/
|
|
8
|
-
export interface AssetProcessor<T extends AssetDefinition = AssetDefinition> {
|
|
9
|
-
process(asset: T): Promise<ProcessedAsset>;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Interface for processors that support HMR (Hot Module Replacement).
|
|
14
|
-
* These processors can receive an HMR manager to enable hot reloading capabilities.
|
|
15
|
-
*/
|
|
16
|
-
export interface HmrAwareProcessor extends AssetProcessor {
|
|
17
|
-
setHmrManager(hmrManager: IHmrManager): void;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Type guard to check if a processor supports HMR.
|
|
22
|
-
* @param processor - The processor to check
|
|
23
|
-
* @returns True if the processor implements HmrAwareProcessor
|
|
24
|
-
*/
|
|
25
|
-
export function isHmrAware(processor: AssetProcessor): processor is HmrAwareProcessor {
|
|
26
|
-
return 'setHmrManager' in processor && typeof (processor as HmrAwareProcessor).setHmrManager === 'function';
|
|
27
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { AssetKind, AssetSource } from './assets.types';
|
|
2
|
-
import type { BaseProcessor } from './processors/base/base-processor';
|
|
3
|
-
|
|
4
|
-
export class ProcessorRegistry {
|
|
5
|
-
private processors = new Map<`${AssetKind}-${AssetSource}`, BaseProcessor<any>>();
|
|
6
|
-
|
|
7
|
-
register(kind: AssetKind, variant: AssetSource, processor: BaseProcessor<any>) {
|
|
8
|
-
this.processors.set(`${kind}-${variant}`, processor);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
getProcessor(kind: AssetKind, variant: AssetSource): BaseProcessor<any> | undefined {
|
|
12
|
-
return this.processors.get(`${kind}-${variant}`);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
getAllProcessors(): Map<`${AssetKind}-${AssetSource}`, BaseProcessor<any>> {
|
|
16
|
-
return this.processors;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
|
-
import { RESOLVED_ASSETS_DIR } from '../../../../../constants.ts';
|
|
3
|
-
import type { EcoPagesAppConfig } from '../../../../../internal-types.ts';
|
|
4
|
-
import { rapidhash } from '../../../../../utils/hash.ts';
|
|
5
|
-
import { isDevelopmentRuntime, isProductionRuntime } from '../../../../../utils/runtime.ts';
|
|
6
|
-
import type { BaseAsset, ProcessedAsset } from '../../assets.types.ts';
|
|
7
|
-
import { fileSystem } from '@ecopages/file-system';
|
|
8
|
-
|
|
9
|
-
export abstract class BaseProcessor<T extends BaseAsset> {
|
|
10
|
-
protected appConfig: EcoPagesAppConfig;
|
|
11
|
-
/**
|
|
12
|
-
* Cache for processed assets to avoid reprocessing the same asset multiple times.
|
|
13
|
-
* The cache key is a combination of the asset name and its hash.
|
|
14
|
-
* The cache value is the processed asset.
|
|
15
|
-
*/
|
|
16
|
-
protected cache: Map<string, ProcessedAsset> = new Map();
|
|
17
|
-
|
|
18
|
-
constructor({ appConfig }: { appConfig: EcoPagesAppConfig }) {
|
|
19
|
-
this.appConfig = appConfig;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
get isDevelopment(): boolean {
|
|
23
|
-
return isDevelopmentRuntime();
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
get isProduction(): boolean {
|
|
27
|
-
return isProductionRuntime();
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
abstract process(dep: T): Promise<ProcessedAsset>;
|
|
31
|
-
|
|
32
|
-
protected getAssetsDir(): string {
|
|
33
|
-
return path.join(this.appConfig.absolutePaths.distDir, RESOLVED_ASSETS_DIR);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
protected writeCacheFile(key: string, path: ProcessedAsset): void {
|
|
37
|
-
this.cache.set(key, path);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
protected getCacheFile(key: string): ProcessedAsset | undefined {
|
|
41
|
-
return this.cache.get(key);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
protected hasCacheFile(key: string): boolean {
|
|
45
|
-
return this.cache.has(key);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
protected generateHash(content: string): string {
|
|
49
|
-
return rapidhash(content).toString();
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
protected buildCacheKey(identifier: string, contentHash: string, dep: T): string {
|
|
53
|
-
const attrsHash = dep.attributes ? this.generateHash(JSON.stringify(dep.attributes)) : '';
|
|
54
|
-
const position = dep.position ?? '';
|
|
55
|
-
return `${identifier}:${contentHash}:${position}:${attrsHash}`;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
protected getOrProcess(
|
|
59
|
-
cacheKey: string,
|
|
60
|
-
processFn: () => ProcessedAsset | Promise<ProcessedAsset>,
|
|
61
|
-
): Promise<ProcessedAsset> {
|
|
62
|
-
if (this.hasCacheFile(cacheKey)) {
|
|
63
|
-
const cached = this.getCacheFile(cacheKey) as ProcessedAsset;
|
|
64
|
-
if (!cached.filepath || fileSystem.exists(cached.filepath)) {
|
|
65
|
-
return Promise.resolve(cached);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
this.cache.delete(cacheKey);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
const result = processFn();
|
|
72
|
-
if (result instanceof Promise) {
|
|
73
|
-
return result.then((asset) => {
|
|
74
|
-
this.writeCacheFile(cacheKey, asset);
|
|
75
|
-
return asset;
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
this.writeCacheFile(cacheKey, result);
|
|
80
|
-
return Promise.resolve(result);
|
|
81
|
-
}
|
|
82
|
-
}
|
package/src/services/assets/asset-processing-service/processors/base/base-script-processor.ts
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import { appLogger } from '../../../../../global/app-logger';
|
|
2
|
-
import type { EcoPagesAppConfig } from '../../../../../internal-types';
|
|
3
|
-
import { getAppBrowserBuildPlugins } from '../../../../../build/build-adapter.ts';
|
|
4
|
-
import type { EcoBuildPlugin } from '../../../../../build/build-types.ts';
|
|
5
|
-
import { fileSystem } from '@ecopages/file-system';
|
|
6
|
-
import path from 'node:path';
|
|
7
|
-
import type { ScriptAsset } from '../../assets.types';
|
|
8
|
-
import { BaseProcessor } from './base-processor';
|
|
9
|
-
import { BrowserBundleService } from '../../../browser-bundle.service.ts';
|
|
10
|
-
|
|
11
|
-
export abstract class BaseScriptProcessor<T extends ScriptAsset> extends BaseProcessor<T> {
|
|
12
|
-
private readonly browserBundleService: BrowserBundleService;
|
|
13
|
-
|
|
14
|
-
constructor({ appConfig }: { appConfig: EcoPagesAppConfig }) {
|
|
15
|
-
super({ appConfig });
|
|
16
|
-
this.browserBundleService = new BrowserBundleService(appConfig);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
protected shouldBundle(dep: T): boolean {
|
|
20
|
-
return dep.bundle !== false;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
protected getBundlerOptions(dep: T): Record<string, any> {
|
|
24
|
-
return dep.bundleOptions || {};
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
protected collectBuildPlugins(): EcoBuildPlugin[] {
|
|
28
|
-
return getAppBrowserBuildPlugins(this.appConfig);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
protected async bundleScript({
|
|
32
|
-
entrypoint,
|
|
33
|
-
outdir,
|
|
34
|
-
plugins: additionalPlugins,
|
|
35
|
-
...rest
|
|
36
|
-
}: {
|
|
37
|
-
entrypoint: string;
|
|
38
|
-
outdir: string;
|
|
39
|
-
} & ScriptAsset['bundleOptions']): Promise<string> {
|
|
40
|
-
const buildPlugins = this.collectBuildPlugins();
|
|
41
|
-
const allPlugins = additionalPlugins ? [...additionalPlugins, ...buildPlugins] : buildPlugins;
|
|
42
|
-
|
|
43
|
-
const buildResult = await this.browserBundleService.bundle({
|
|
44
|
-
profile: 'browser-script',
|
|
45
|
-
entrypoints: [entrypoint],
|
|
46
|
-
outdir,
|
|
47
|
-
root: this.appConfig.rootDir,
|
|
48
|
-
splitting: true,
|
|
49
|
-
naming: '[name]-[hash].[ext]',
|
|
50
|
-
plugins: allPlugins,
|
|
51
|
-
...rest,
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
if (!buildResult.success) {
|
|
55
|
-
for (const log of buildResult.logs) {
|
|
56
|
-
appLogger.debug(log.message, log);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const entryBaseName = path.parse(entrypoint).name;
|
|
61
|
-
const entryOutput = buildResult.outputs
|
|
62
|
-
.map((output) => output.path)
|
|
63
|
-
.find((outputPath) => path.basename(outputPath) === `${entryBaseName}.js`);
|
|
64
|
-
|
|
65
|
-
if (entryOutput) {
|
|
66
|
-
return entryOutput;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
const nonVendorOutput = buildResult.outputs
|
|
70
|
-
.map((output) => output.path)
|
|
71
|
-
.find((outputPath) => !path.basename(outputPath).startsWith('vendors'));
|
|
72
|
-
|
|
73
|
-
if (nonVendorOutput) {
|
|
74
|
-
return nonVendorOutput;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
const primaryOutput = buildResult.outputs[0]?.path;
|
|
78
|
-
if (primaryOutput) {
|
|
79
|
-
return primaryOutput;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
const namedFallbackOutput = path.join(outdir, `${entryBaseName}.js`);
|
|
83
|
-
if (fileSystem.exists(namedFallbackOutput)) {
|
|
84
|
-
return namedFallbackOutput;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
const fallbackOutput = path.join(outdir, 'entry_0.js');
|
|
88
|
-
if (fileSystem.exists(fallbackOutput)) {
|
|
89
|
-
return fallbackOutput;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
const logMessage = buildResult.logs.map((log) => log.message).join(' | ');
|
|
93
|
-
throw new Error(`No build output generated for ${entrypoint}${logMessage ? `: ${logMessage}` : ''}`);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export * from './script/content-script.processor';
|
|
2
|
-
export * from './script/file-script.processor';
|
|
3
|
-
export * from './script/node-module-script.processor';
|
|
4
|
-
export * from './stylesheet/content-stylesheet.processor';
|
|
5
|
-
export * from './stylesheet/file-stylesheet.processor';
|
package/src/services/assets/asset-processing-service/processors/script/content-script.processor.ts
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
|
-
import { fileSystem } from '@ecopages/file-system';
|
|
3
|
-
import type { ContentScriptAsset, ProcessedAsset } from '../../assets.types';
|
|
4
|
-
import { BaseScriptProcessor } from '../base/base-script-processor';
|
|
5
|
-
|
|
6
|
-
export class ContentScriptProcessor extends BaseScriptProcessor<ContentScriptAsset> {
|
|
7
|
-
async process(dep: ContentScriptAsset): Promise<ProcessedAsset> {
|
|
8
|
-
const hash = this.generateHash(dep.content);
|
|
9
|
-
const filename = dep.name ? `${dep.name}.js` : `script-${hash}.js`;
|
|
10
|
-
const shouldBundle = this.shouldBundle(dep);
|
|
11
|
-
|
|
12
|
-
const filepath = path.join(this.getAssetsDir(), 'scripts', filename);
|
|
13
|
-
|
|
14
|
-
if (!shouldBundle) {
|
|
15
|
-
if (!dep.inline) fileSystem.write(filepath, dep.content);
|
|
16
|
-
const unbundledProcessedAsset: ProcessedAsset = {
|
|
17
|
-
filepath,
|
|
18
|
-
content: dep.inline ? dep.content : undefined,
|
|
19
|
-
kind: 'script',
|
|
20
|
-
position: dep.position,
|
|
21
|
-
attributes: dep.attributes,
|
|
22
|
-
inline: dep.inline,
|
|
23
|
-
excludeFromHtml: dep.excludeFromHtml,
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
this.writeCacheFile(filename, unbundledProcessedAsset);
|
|
27
|
-
return unbundledProcessedAsset;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
if (dep.content) {
|
|
31
|
-
const tempDir = this.appConfig.absolutePaths.distDir;
|
|
32
|
-
fileSystem.ensureDir(tempDir);
|
|
33
|
-
const tempFileName = path.join(
|
|
34
|
-
tempDir,
|
|
35
|
-
`${path.parse(filename).name}.${process.pid}.${Date.now()}.${Math.random().toString(36).slice(2)}.tmp.js`,
|
|
36
|
-
);
|
|
37
|
-
fileSystem.write(tempFileName, dep.content);
|
|
38
|
-
|
|
39
|
-
const bundledFilePath = await this.bundleScript({
|
|
40
|
-
entrypoint: tempFileName,
|
|
41
|
-
outdir: this.getAssetsDir(),
|
|
42
|
-
minify: this.isProduction,
|
|
43
|
-
naming: `${path.parse(filename).name}-[hash].[ext]`,
|
|
44
|
-
...this.getBundlerOptions(dep),
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
const processedAsset: ProcessedAsset = {
|
|
48
|
-
filepath: bundledFilePath,
|
|
49
|
-
content: dep.inline ? fileSystem.readFileSync(bundledFilePath).toString() : undefined,
|
|
50
|
-
kind: 'script',
|
|
51
|
-
position: dep.position,
|
|
52
|
-
attributes: dep.attributes,
|
|
53
|
-
inline: dep.inline,
|
|
54
|
-
excludeFromHtml: dep.excludeFromHtml,
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
fileSystem.remove(tempFileName);
|
|
58
|
-
|
|
59
|
-
this.writeCacheFile(filename, processedAsset);
|
|
60
|
-
|
|
61
|
-
return processedAsset;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
throw new Error('No content found for script asset');
|
|
65
|
-
}
|
|
66
|
-
}
|
package/src/services/assets/asset-processing-service/processors/script/file-script.processor.ts
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
|
-
import { RESOLVED_ASSETS_DIR } from '../../../../../constants';
|
|
3
|
-
import { fileSystem } from '@ecopages/file-system';
|
|
4
|
-
import type { IHmrManager } from '../../../../../internal-types';
|
|
5
|
-
import type { FileScriptAsset, ProcessedAsset } from '../../assets.types';
|
|
6
|
-
import { BaseScriptProcessor } from '../base/base-script-processor';
|
|
7
|
-
|
|
8
|
-
export class FileScriptProcessor extends BaseScriptProcessor<FileScriptAsset> {
|
|
9
|
-
private hmrManager?: IHmrManager;
|
|
10
|
-
|
|
11
|
-
setHmrManager(hmrManager: IHmrManager) {
|
|
12
|
-
this.hmrManager = hmrManager;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
async process(dep: FileScriptAsset): Promise<ProcessedAsset> {
|
|
16
|
-
/**
|
|
17
|
-
* If HMR Manager is active, delegate build/watch to it.
|
|
18
|
-
*/
|
|
19
|
-
if (this.hmrManager?.isEnabled() && !dep.inline) {
|
|
20
|
-
const outputUrl = await this.hmrManager.registerScriptEntrypoint(dep.filepath);
|
|
21
|
-
return {
|
|
22
|
-
filepath: dep.filepath,
|
|
23
|
-
srcUrl: outputUrl,
|
|
24
|
-
kind: 'script',
|
|
25
|
-
position: dep.position,
|
|
26
|
-
attributes: dep.attributes,
|
|
27
|
-
inline: false,
|
|
28
|
-
excludeFromHtml: dep.excludeFromHtml,
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const content = fileSystem.readFileSync(dep.filepath);
|
|
33
|
-
const shouldBundle = this.shouldBundle(dep);
|
|
34
|
-
const configHash = this.generateHash(
|
|
35
|
-
JSON.stringify({
|
|
36
|
-
bundle: shouldBundle,
|
|
37
|
-
minify: shouldBundle && this.isProduction,
|
|
38
|
-
opts: dep.bundleOptions,
|
|
39
|
-
}),
|
|
40
|
-
);
|
|
41
|
-
const cachekey = `${this.buildCacheKey(dep.filepath, this.generateHash(content), dep)}:${configHash}`;
|
|
42
|
-
|
|
43
|
-
return this.getOrProcess(cachekey, async () => {
|
|
44
|
-
if (!shouldBundle) {
|
|
45
|
-
const outFilepath = path.relative(this.appConfig.absolutePaths.srcDir, dep.filepath);
|
|
46
|
-
let filepath: string | undefined;
|
|
47
|
-
|
|
48
|
-
if (!dep.inline) {
|
|
49
|
-
filepath = path.join(this.getAssetsDir(), outFilepath);
|
|
50
|
-
fileSystem.copyFile(dep.filepath, filepath);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return {
|
|
54
|
-
filepath,
|
|
55
|
-
content,
|
|
56
|
-
kind: 'script',
|
|
57
|
-
position: dep.position,
|
|
58
|
-
attributes: dep.attributes,
|
|
59
|
-
inline: dep.inline,
|
|
60
|
-
excludeFromHtml: dep.excludeFromHtml,
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const relativeFilepath = path.relative(this.appConfig.absolutePaths.srcDir, dep.filepath);
|
|
65
|
-
const outdirPath = path.join(this.appConfig.absolutePaths.distDir, RESOLVED_ASSETS_DIR, relativeFilepath);
|
|
66
|
-
const outdirDirname = path.dirname(outdirPath);
|
|
67
|
-
const bundlerOptions = this.getBundlerOptions(dep);
|
|
68
|
-
|
|
69
|
-
const bundledFilePath = await this.bundleScript({
|
|
70
|
-
entrypoint: dep.filepath,
|
|
71
|
-
outdir: outdirDirname,
|
|
72
|
-
minify: this.isProduction,
|
|
73
|
-
...bundlerOptions,
|
|
74
|
-
plugins: bundlerOptions.plugins,
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
return {
|
|
78
|
-
filepath: bundledFilePath,
|
|
79
|
-
content: dep.inline ? fileSystem.readFileSync(bundledFilePath).toString() : undefined,
|
|
80
|
-
kind: 'script',
|
|
81
|
-
position: dep.position,
|
|
82
|
-
attributes: dep.attributes,
|
|
83
|
-
inline: dep.inline,
|
|
84
|
-
excludeFromHtml: dep.excludeFromHtml,
|
|
85
|
-
};
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
}
|