Skip to content

Commit

Permalink
fix(stencil): resolve validateConfig error from @stencil/[email protected]
Browse files Browse the repository at this point in the history
….0 onward
  • Loading branch information
Sharief Orie authored and DominikPieper committed May 14, 2024
1 parent 2bbadf4 commit f5b8725
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { CompilerSystem, createNodeSys } from '@stencil/core/sys/node';

import { loadCoreCompiler } from './stencil-process';

function getCompilerExecutingPath(): string {
return require.resolve('@stencil/core/compiler');
}

describe('process', () => {
describe('loadCoreCompiler', () => {
it('should return globalThis.stencil', async () => {
const sys: CompilerSystem = createNodeSys({ process });

if (sys.getCompilerExecutingPath == null) {
sys.getCompilerExecutingPath = getCompilerExecutingPath;
}

expect(globalThis.stencil).toBeUndefined();

await loadCoreCompiler(sys);

expect(globalThis.stencil).toBeTruthy();
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,15 @@ type CoreCompiler = typeof import('@stencil/core/compiler');
export const loadCoreCompiler = async (
sys: CompilerSystem
): Promise<CoreCompiler> => {
await sys.dynamicImport(sys.getCompilerExecutingPath());
const coreCompiler: CoreCompiler = await sys.dynamicImport(
sys.getCompilerExecutingPath()
);

return (globalThis as any).stencil;
if (!('stencil' in globalThis)) {
globalThis.stencil = coreCompiler;
}

return globalThis.stencil;
};

export async function createStencilProcess(config: Config): Promise<void> {
Expand Down

0 comments on commit f5b8725

Please sign in to comment.