Skip to content

Commit 30affc8

Browse files
committed
further progress, trying to eliminate performance bottlenecks in the import discovery.
1 parent ec604f2 commit 30affc8

8 files changed

Lines changed: 822 additions & 794 deletions

File tree

src/compiler/compiler-utils.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,12 @@ import { isMathmlTag } from '../shared/mathml-tags.js';
55
import { isSvgTag } from '../shared/svg-tags.js';
66
import type { ProcessorContext } from './attribute-processor.js';
77
import { COMPONENT_POSTFIX, ERROR_MESSAGES, SOURCES, VARIABLES } from './config.js';
8+
import { findElementDefinition } from './import-discovery.js';
89

910

1011
export type Values<T> = T[keyof T];
1112

1213

13-
/** Cache over JSX component functions which are toJSX defined custom elements. */
14-
export const customElementNameMap: Map<string, Set<string>> = new Map();
15-
16-
1714
export const isComponent = (tagName: string): boolean => {
1815
return (tagName[0] && tagName[0].toLowerCase() !== tagName[0])
1916
|| tagName.includes('.')
@@ -727,10 +724,8 @@ export const isJSXCustomElementComponent = (
727724
if (tagName.endsWith(COMPONENT_POSTFIX))
728725
return true;
729726

730-
const currentFileName = getPathFilename(path);
731-
const customElementSet = customElementNameMap.get(currentFileName);
732-
733-
if (customElementSet?.has(tagName))
727+
const type = findElementDefinition(path.get('openingElement'));
728+
if (type.type === 'custom-element')
734729
return true;
735730

736731
return false;

src/compiler/config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
export type BabelPlugins = NonNullable<NonNullable<babel.TransformOptions['parserOpts']>['plugins']>;
22

33

4-
export const plugins: Set<BabelPlugins[number]> = new Set([ 'jsx', 'decorators', 'decoratorAutoAccessors' ]);
5-
export const debugMode = { value: false };
4+
export const babelPlugins: BabelPlugins = [ 'jsx', 'typescript', 'decorators', 'decoratorAutoAccessors' ];
5+
export const debugMode = { value: true };
66

77

88
export const COMPONENT_LITERAL_PREFIX = '__$';

src/compiler/create-logger.ts

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,35 @@
11
import pino, { type Logger } from 'pino';
2+
import { prettyFactory } from 'pino-pretty';
23

34

45
export const createLogger = (name: string, debug?: boolean): Logger<never, boolean> => {
6+
const prettify = prettyFactory({
7+
sync: true,
8+
colorize: true,
9+
ignore: 'pid,hostname',
10+
translateTime: 'HH:MM:ss',
11+
});
12+
const hooks: pino.LoggerOptions['hooks'] | undefined = {
13+
streamWrite: (s) => {
14+
console.log(prettify(s));
15+
16+
return '';
17+
},
18+
};
19+
520
return pino({
621
name,
7-
level: debug ? 'trace' : 'warn',
8-
...(debug && {
9-
transport: {
10-
target: 'pino-pretty',
11-
options: {
12-
colorize: true,
13-
translateTime: 'HH:MM:ss',
14-
ignore: 'pid,hostname',
15-
},
16-
},
17-
}),
22+
level: debug ? 'trace' : 'info',
23+
hooks,
24+
//...(debug && {
25+
// transport: {
26+
// target: 'pino-pretty',
27+
// options: {
28+
// colorize: true,
29+
// translateTime: 'HH:MM:ss',
30+
// ignore: 'pid,hostname',
31+
// },
32+
// },
33+
//}),
1834
});
1935
};

0 commit comments

Comments
 (0)