@module-federation/esbuild 0.0.0-next-20240523225730 → 0.0.0-next-20240524010758

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/build.cjs.js CHANGED
@@ -58,7 +58,8 @@ const DEFAULT_SKIP_LIST = [
58
58
  /\/schematics(\/|$)/,
59
59
  /^@nx\/angular/,
60
60
  (pkg)=>pkg.startsWith('@angular/') && !!pkg.match(/\/testing(\/|$)/),
61
- (pkg)=>pkg.startsWith('@types/')
61
+ (pkg)=>pkg.startsWith('@types/'),
62
+ (pkg)=>pkg.startsWith('@module-federation/')
62
63
  ];
63
64
  const PREPARED_DEFAULT_SKIP_LIST = prepareSkipList(DEFAULT_SKIP_LIST);
64
65
  function prepareSkipList(skipList) {
package/dist/build.esm.js CHANGED
@@ -29,7 +29,8 @@ const DEFAULT_SKIP_LIST = [
29
29
  /\/schematics(\/|$)/,
30
30
  /^@nx\/angular/,
31
31
  (pkg)=>pkg.startsWith('@angular/') && !!pkg.match(/\/testing(\/|$)/),
32
- (pkg)=>pkg.startsWith('@types/')
32
+ (pkg)=>pkg.startsWith('@types/'),
33
+ (pkg)=>pkg.startsWith('@module-federation/')
33
34
  ];
34
35
  const PREPARED_DEFAULT_SKIP_LIST = prepareSkipList(DEFAULT_SKIP_LIST);
35
36
  function prepareSkipList(skipList) {
@@ -743,15 +743,37 @@ const initializeHostPlugin = {
743
743
  contents: buildFederationHost(),
744
744
  resolveDir: args.pluginData.resolveDir
745
745
  }));
746
+ // Add custom loaders
747
+ const loaders = build.initialOptions.loader || {};
748
+ // Apply custom loaders
749
+ for (const [ext, loader] of Object.entries(loaders)){
750
+ build.onLoad({
751
+ filter: new RegExp(`\\${ext}$`),
752
+ namespace: 'file'
753
+ }, async (args)=>{
754
+ const contents = await fs__default["default"].promises.readFile(args.path, 'utf8');
755
+ return {
756
+ contents: buildFederationHost() + contents,
757
+ loader
758
+ };
759
+ });
760
+ }
761
+ // Fallback loader for files not matched by custom loaders
762
+ const fallbackFilter = new RegExp(Object.keys(loaders).map((ext)=>`\\${ext}$`).join('|'));
746
763
  build.onLoad({
747
764
  filter: /.*\.(ts|js|mjs)$/,
748
765
  namespace: 'file'
749
- }, async (args)=>{
750
- if (!build.initialOptions.entryPoints.some((e)=>args.path.includes(e))) return;
751
- const contents = await fs__default["default"].promises.readFile(args.path, 'utf8');
752
- return {
753
- contents: buildFederationHost() + contents
754
- };
766
+ }, //@ts-ignore
767
+ async (args)=>{
768
+ if (!fallbackFilter.test(args.path)) {
769
+ if (!build.initialOptions.entryPoints.some((e)=>args.path.includes(e))) {
770
+ return;
771
+ }
772
+ const contents = await fs__default["default"].promises.readFile(args.path, 'utf8');
773
+ return {
774
+ contents: buildFederationHost() + contents
775
+ };
776
+ }
755
777
  });
756
778
  }
757
779
  };
@@ -712,15 +712,37 @@ const initializeHostPlugin = {
712
712
  contents: buildFederationHost(),
713
713
  resolveDir: args.pluginData.resolveDir
714
714
  }));
715
+ // Add custom loaders
716
+ const loaders = build.initialOptions.loader || {};
717
+ // Apply custom loaders
718
+ for (const [ext, loader] of Object.entries(loaders)){
719
+ build.onLoad({
720
+ filter: new RegExp(`\\${ext}$`),
721
+ namespace: 'file'
722
+ }, async (args)=>{
723
+ const contents = await fs__default.promises.readFile(args.path, 'utf8');
724
+ return {
725
+ contents: buildFederationHost() + contents,
726
+ loader
727
+ };
728
+ });
729
+ }
730
+ // Fallback loader for files not matched by custom loaders
731
+ const fallbackFilter = new RegExp(Object.keys(loaders).map((ext)=>`\\${ext}$`).join('|'));
715
732
  build.onLoad({
716
733
  filter: /.*\.(ts|js|mjs)$/,
717
734
  namespace: 'file'
718
- }, async (args)=>{
719
- if (!build.initialOptions.entryPoints.some((e)=>args.path.includes(e))) return;
720
- const contents = await fs__default.promises.readFile(args.path, 'utf8');
721
- return {
722
- contents: buildFederationHost() + contents
723
- };
735
+ }, //@ts-ignore
736
+ async (args)=>{
737
+ if (!fallbackFilter.test(args.path)) {
738
+ if (!build.initialOptions.entryPoints.some((e)=>args.path.includes(e))) {
739
+ return;
740
+ }
741
+ const contents = await fs__default.promises.readFile(args.path, 'utf8');
742
+ return {
743
+ contents: buildFederationHost() + contents
744
+ };
745
+ }
724
746
  });
725
747
  }
726
748
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/esbuild",
3
- "version": "0.0.0-next-20240523225730",
3
+ "version": "0.0.0-next-20240524010758",
4
4
  "author": "Zack Jackson (@ScriptedAlchemy)",
5
5
  "main": "./dist/index.cjs.js",
6
6
  "module": "./dist/index.esm.js",
@@ -63,6 +63,6 @@
63
63
  "esbuild": "^0.18.12",
64
64
  "npmlog": "^6.0.2",
65
65
  "acorn": "^8.8.1",
66
- "@module-federation/sdk": "0.0.0-next-20240523225730"
66
+ "@module-federation/sdk": "0.0.0-next-20240524010758"
67
67
  }
68
68
  }