Skip to content

Commit

Permalink
feat(Types): bundle types in the browser
Browse files Browse the repository at this point in the history
  • Loading branch information
hatemhosny committed Jan 20, 2024
1 parent 9982072 commit f9a7951
Show file tree
Hide file tree
Showing 8 changed files with 1,009 additions and 149 deletions.
346 changes: 203 additions & 143 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ const esmBuild = () =>
'languages/language-info.ts',
'export/export.ts',
'sync/sync.ts',
'types/bundle-types.ts',
'UI/open.ts',
'UI/resources.ts',
'UI/assets.ts',
Expand Down
5 changes: 5 additions & 0 deletions src/livecodes/compiler/import-map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ export const hasImports = (code: string) => getImports(code).length > 0;
export const hasExports = (code: string) =>
new RegExp(/(^export\s)|([\s|;]export\s)/).test(removeCommentsAndStrings(code));

export const hasUrlImportsOrExports = (code: string) =>
new RegExp(
/((?:import|export)\s+?(?:(?:(?:[\w*\s{},\$]*)\s+from\s+?)|))((?:"(?:\.|http|\/).*?")|(?:'(?:\.|http|\/).*?'))([\s]*?(?:;|$|))/,
).test(removeComments(code));

export const hasAwait = (code: string) =>
new RegExp(/(^await\s)|([\s|;]await\s)/).test(removeCommentsAndStrings(code));

Expand Down
2 changes: 1 addition & 1 deletion src/livecodes/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3859,7 +3859,7 @@ const basicHandlers = () => {
notifications = createNotifications();
modal = createModal();
split = createSplitPanes();
typeLoader = createTypeLoader();
typeLoader = createTypeLoader(baseUrl);

handleLogoLink();
handleResize();
Expand Down

0 comments on commit f9a7951

Please sign in to comment.