Skip to content
This repository has been archived by the owner on May 3, 2024. It is now read-only.

Commit

Permalink
Merge branch 'main' into fix/npm-9
Browse files Browse the repository at this point in the history
  • Loading branch information
10xLaCroixDrinker authored Apr 19, 2024
2 parents 35bcb38 + f301288 commit 433b2cc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 4 additions & 3 deletions __tests__/server/utils/watchLocalModules.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
} from 'holocron/moduleRegistry';
import watchLocalModules from '../../../src/server/utils/watchLocalModules';
import { getIp } from '../../../src/server/utils/getIP';
import addBaseUrlToModuleMap from '../../../src/server/utils/addBaseUrlToModuleMap';

const ip = getIp();

Expand Down Expand Up @@ -112,7 +113,7 @@ describe('watchLocalModules', () => {
await changeListener(modulePath);
expect(loadModule).toHaveBeenCalledWith(
moduleName,
moduleMapSample.modules[moduleName],
addBaseUrlToModuleMap(moduleMapSample).modules[moduleName],
require('../../../src/server/utils/onModuleLoad').default
);
expect(getModules().get(moduleName)).toBe(updatedModule);
Expand Down Expand Up @@ -153,7 +154,7 @@ describe('watchLocalModules', () => {
await changeListener(modulePath);
expect(loadModule).toHaveBeenCalledWith(
moduleName,
moduleMapSample.modules[moduleName],
addBaseUrlToModuleMap(moduleMapSample).modules[moduleName],
require('../../../src/server/utils/onModuleLoad').default
);
expect(getModules().get(moduleName)).toBe(originalModule);
Expand Down Expand Up @@ -234,7 +235,7 @@ describe('watchLocalModules', () => {
await changeListener(modulePath);
expect(loadModule).toHaveBeenCalledWith(
moduleName,
updatedModuleMapSample.modules[moduleName],
addBaseUrlToModuleMap(updatedModuleMapSample).modules[moduleName],
require('../../../src/server/utils/onModuleLoad').default
);
expect(getModules().get(moduleName)).toBe(updatedModule);
Expand Down
4 changes: 3 additions & 1 deletion src/server/utils/watchLocalModules.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
} from 'holocron/moduleRegistry';
import { getIp } from './getIP';
import onModuleLoad from './onModuleLoad';
import addBaseUrlToModuleMap from './addBaseUrlToModuleMap';

export default function watchLocalModules() {
const staticsDirectoryPath = path.resolve(__dirname, '../../../static');
Expand All @@ -43,12 +44,13 @@ export default function watchLocalModules() {

const moduleMap = JSON.parse(fs.readFileSync(moduleMapPath, 'utf8'));

const moduleData = moduleMap.modules[moduleNameChangeDetectedIn];
const moduleData = addBaseUrlToModuleMap(moduleMap).modules[moduleNameChangeDetectedIn];
const oneAppDevCdnAddress = `http://${getIp()}:${process.env.HTTP_ONE_APP_DEV_CDN_PORT || 3001}`;

moduleData.browser.url = moduleData.browser.url.replace('[one-app-dev-cdn-url]', oneAppDevCdnAddress);
moduleData.legacyBrowser.url = moduleData.legacyBrowser.url.replace('[one-app-dev-cdn-url]', oneAppDevCdnAddress);
moduleData.node.url = moduleData.node.url.replace('[one-app-dev-cdn-url]', oneAppDevCdnAddress);
moduleData.baseUrl = moduleData.baseUrl.replace('[one-app-dev-cdn-url]', oneAppDevCdnAddress);

const module = addHigherOrderComponent(await loadModule(
moduleNameChangeDetectedIn,
Expand Down

0 comments on commit 433b2cc

Please sign in to comment.