Skip to content

Commit

Permalink
fix(sys): fix expected types for createNodeLogger and `createNodeSy…
Browse files Browse the repository at this point in the history
…s` (#5375)

* fix(sys): fix expected types for createNodeLogger and createNodeSys

* add missing function setupNodeProcess

* prettier

* PR feedback

* prettier

* Update scripts/test/validate-build.ts

Co-authored-by: Ryan Waskiewicz <[email protected]>

* deprecated createNodeLogger function with parameter

* add todo

* revert changes in validate-build.ts

* revert all changes in validate-build.ts

* Update src/sys/node/public.ts

Co-authored-by: Ryan Waskiewicz <[email protected]>

---------

Co-authored-by: Ryan Waskiewicz <[email protected]>
  • Loading branch information
christian-bromann and rwaskiewicz authored Mar 11, 2024
1 parent b36f295 commit dc1529b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
2 changes: 1 addition & 1 deletion scripts/test/validate-build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ async function validateCompiler(opts: BuildOptions): Promise<void> {
const cli = await import(cliPath);
const sysNodeApi = await import(sysNodePath);

const nodeLogger = sysNodeApi.createNodeLogger({ process });
const nodeLogger = sysNodeApi.createNodeLogger();
const nodeSys = sysNodeApi.createNodeSys({ process });

if (!nodeSys || nodeSys.name !== 'node' || nodeSys.version.length < 4) {
Expand Down
22 changes: 19 additions & 3 deletions src/sys/node/public.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,35 @@ import type { CompilerSystem, Logger } from '@stencil/core/internal';
/**
* Creates a "logger", based off of NodeJS APIs, that will be used by the compiler and dev-server.
* The NodeJS "process" object must be provided as a property in the first argument's object.
* @param c an object containing a `Process` for Stencil to use
* @returns a {@link Logger} object
*/
export declare function createNodeLogger(): Logger;

// TODO(STENCIL-1196): Remove in Stencil v5, use `createNodeLogger` without parameters instead
/**
* Creates a "logger", based off of NodeJS APIs, that will be used by the compiler and dev-server.
* The NodeJS "process" object must be provided as a property in the first argument's object.
* @param c an object containing a `Process` for Stencil to use and a logger instanced created by {@link createNodeLogger}
* @returns a {@link Logger} object
* @deprecated Use {@link createNodeLogger} without parameters instead
*/
export declare function createNodeLogger(c: { process: any }): Logger;

/**
* Creates the "system", based off of NodeJS APIs, used by the compiler. This includes any and
* all file system reads and writes using NodeJS. The compiler itself is unaware of Node's
* `fs` module. Other system APIs include any use of `crypto` to hash content. The NodeJS
* "process" object must be provided as a property in the first argument's object.
* @param c an object containing a `Process` for Stencil to use
* @param c an object containing a `Process` for Stencil to use and a logger instanced created by {@link createNodeLogger}
* @returns a {@link CompilerSystem} object
*/
export declare function createNodeSys(c: { process: any }): CompilerSystem;
export declare function createNodeSys(c: { process?: any; logger?: any }): CompilerSystem;

/**
* Sets up the NodeJS process to be used by Stencil. This includes setting up the process's
* `exit` and `uncaughtException` events to be handled by Stencil's logger.
* @param c an object containing a `Process` for Stencil to use and a logger instanced created by {@link createNodeLogger}
*/
export declare function setupNodeProcess(c: { process: any; logger: Logger }): void;

export { CompilerSystem, Logger };

0 comments on commit dc1529b

Please sign in to comment.