Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bundle and Publish #98

Merged
merged 12 commits into from
Oct 27, 2021
Merged

Bundle and Publish #98

merged 12 commits into from
Oct 27, 2021

Conversation

Yuyz0112
Copy link
Contributor

In this PR, we add bundling tools to meta-ui packages(core and runtime) and publish npm packages that can be used by other projects.

Bundler

In the meantime, we use tsup as the bundler, which is designed for TS projects, and use esbuild under the hood.

We may switch to rollup or other bundlers in the future since tsup still has some issues with code splitting, but currently, it should work well enough and help us focus on the main features.

Fork @vue-reactivity/watch

@vue-reactivity/watch also uses tsup as its bundler, which creates the .mjs file as the ES module output. (We avoid this by setting the legacy flag).

But webpack4 does not like the .mjs extension which causes tools like create-react-app to fail when using meta-ui.

Even users can add some tricks to let webpack4 bundle .mjs file, the watch function still not working without throwing any error/warning.

So we fork it into our codebase to avoid these issues.

Publish

Currently, we are using lerna to publish packages. Before v1.0, all the packages can be published to the stable channel. After v1.0, we may consider using the canary release channel as well.

TODO

The editor package has not been tested and hopes we can finish it in the next PR.

 - @meta-ui/core@0.2.0
 - @meta-ui/editor@0.2.0
 - @meta-ui/runtime@0.2.0
 - @meta-ui/editor@0.2.1
 - @meta-ui/runtime@0.2.1
 - @meta-ui/core@0.2.1
 - @meta-ui/editor@0.2.2
 - @meta-ui/runtime@0.2.2
 - @meta-ui/editor@0.2.3
 - @meta-ui/runtime@0.2.3
@vue-reactivity/watch use tsup as its bundler, which create .mjs
file as the ES module output.
But webpack4 do not like .mjs extension which cause tools like
create-react-app failed when using meta-ui. Even users can add some
trick to let webpack4 bundle .mjs file, the watch function still
not working.

Refs:
1. facebook/create-react-app#10356
2. formatjs/formatjs#1395 (comment)
 - @meta-ui/editor@0.2.4
 - @meta-ui/runtime@0.2.4
@Yuyz0112 Yuyz0112 requested a review from tanbowensg October 27, 2021 06:34
@github-actions
Copy link

Code coverage

Filename Statements Branches Functions Lines
packages/core/src/version.ts 83.33% 50% 100% 83.33%
packages/core/src/application.ts 91.67% 66.67% 100% 91.67%
packages/core/src/component.ts 100% 100% 100% 100%
packages/runtime/src/utils/watchReactivity.ts 2.15% 0% 0% 2.6%
packages/runtime/src/constants.ts 100% 100% 100% 100%
packages/runtime/src/services/stateStore.ts 43.28% 42.55% 6.67% 43.94%
packages/core/src/trait.ts 100% 100% 100% 100%
packages/runtime/src/components/_internal/Text.tsx 100% 100% 100% 100%
packages/runtime/src/utils/parseTypeBox.ts 76.92% 66.67% 100% 76.92%
packages/core/src/scope.ts 100% 100% 100% 100%
packages/core/src/metadata.ts 100% 100% 100% 100%
packages/core/src/method.ts 100% 100% 100% 100%
packages/core/src/index.ts 100% 100% 100% 100%
packages/runtime/typings/src/traits/core/validation.d.ts 100% 100% 100% 100%
packages/runtime/src/components/core/Router/component.tsx 0% 0% 0% 0%
packages/runtime/src/components/chakra-ui/Form/FormControl.tsx 0% 0% 0% 0%
packages/runtime/src/components/chakra-ui/Form/Form.tsx 0% 0% 0% 0%
packages/runtime/src/components/chakra-ui/Table/Table.tsx 0% 0% 0% 0%
packages/runtime/src/components/chakra-ui/Table/Pagination.tsx 0% 100% 0% 0%
packages/runtime/src/components/chakra-ui/Table/TableTd.tsx 0% 0% 0% 0%
packages/runtime/src/components/core/Router/hooks.tsx 0% 0% 0% 0%
packages/runtime/src/components/core/Router/index.tsx 0% 100% 0% 0%
packages/runtime/src/App.tsx 0% 0% 0% 0%
packages/runtime/src/services/DebugComponents.tsx 0% 100% 0% 0%
packages/runtime/src/services/registry.tsx 0% 0% 0% 0%
packages/runtime/src/services/ImplWrapper.tsx 0% 0% 0% 0%
packages/runtime/src/services/resolveAppComponents.tsx 0% 0% 0% 0%
packages/runtime/src/traits/core/arrayState.tsx 0% 0% 0% 0%
packages/runtime/src/components/chakra-ui/NumberInput.tsx 0% 0% 0% 0%
packages/runtime/src/components/plain/Button.tsx 0% 100% 0% 0%
packages/runtime/src/components/_internal/Slot.tsx 0% 0% 0% 0%
packages/runtime/src/traits/core/validation.tsx 0% 0% 0% 0%
packages/runtime/src/traits/core/fetch.tsx 0% 0% 0% 0%
packages/runtime/src/traits/core/slot.tsx 0% 100% 0% 0%
packages/runtime/src/traits/core/hidden.tsx 0% 0% 0% 0%
packages/runtime/src/traits/core/state.tsx 0% 0% 0% 0%
packages/runtime/src/traits/core/event.tsx 0% 0% 0% 0%
packages/runtime/src/traits/core/style.tsx 0% 100% 0% 0%
packages/runtime/src/components/chakra-ui/Button.tsx 0% 100% 0% 0%
packages/runtime/src/components/chakra-ui/Radio.tsx 0% 100% 0% 0%
packages/runtime/src/components/chakra-ui/Stack.tsx 0% 100% 0% 0%
packages/runtime/src/components/chakra-ui/Tooltip.tsx 0% 0% 0% 0%
packages/runtime/src/components/chakra-ui/Tabs.tsx 0% 0% 0% 0%
packages/runtime/src/components/chakra-ui/Box.tsx 0% 100% 0% 0%
packages/runtime/src/components/chakra-ui/Dialog.tsx 0% 0% 0% 0%
packages/runtime/src/components/chakra-ui/Input.tsx 0% 0% 0% 0%
packages/runtime/src/components/chakra-ui/Kbd.tsx 0% 100% 0% 0%
packages/runtime/src/components/chakra-ui/RadioGroup.tsx 0% 0% 0% 0%
packages/runtime/src/components/chakra-ui/Root.tsx 0% 100% 0% 0%
packages/runtime/src/components/chakra-ui/VStack.tsx 0% 100% 0% 0%
packages/runtime/src/components/chakra-ui/Select.tsx 0% 100% 0% 0%
packages/runtime/src/components/chakra-ui/CheckboxGroup.tsx 0% 100% 0% 0%
packages/runtime/src/components/chakra-ui/List.tsx 0% 0% 0% 0%
packages/runtime/src/components/chakra-ui/HStack.tsx 0% 100% 0% 0%
packages/runtime/src/components/chakra-ui/Image.tsx 0% 0% 0% 0%
packages/runtime/src/components/chakra-ui/Checkbox.tsx 0% 0% 0% 0%
packages/runtime/src/components/_internal/ErrorBoundary.tsx 0% 0% 0% 0%
packages/runtime/src/components/_internal/GridLayout.tsx 0% 0% 0% 0%
packages/runtime/src/components/core/Text.tsx 0% 100% 0% 0%
packages/runtime/src/components/core/GridLayout.tsx 0% 0% 0% 0%
packages/runtime/src/components/core/Dummy.tsx 0% 100% 0% 0%
packages/runtime/typings/src/components/chakra-ui/NumberInput.d.ts 100% 100% 100% 100%
packages/runtime/typings/src/components/plain/Button.d.ts 100% 100% 100% 100%
packages/runtime/typings/src/components/_internal/GridLayout.d.ts 100% 100% 100% 100%
packages/runtime/typings/src/components/core/Dummy.d.ts 100% 100% 100% 100%
packages/runtime/src/components/chakra-ui/Types/ColorScheme.ts 0% 100% 100% 0%
packages/runtime/src/components/chakra-ui/Table/TableTypes.ts 0% 100% 100% 0%
packages/runtime/typings/src/traits/core/state.d.ts 100% 100% 100% 100%
packages/runtime/typings/src/traits/core/style.d.ts 100% 100% 100% 100%
packages/runtime/typings/src/traits/core/fetch.d.ts 100% 100% 100% 100%
packages/runtime/typings/src/traits/core/slot.d.ts 100% 100% 100% 100%
packages/runtime/typings/src/traits/core/arrayState.d.ts 100% 100% 100% 100%
packages/runtime/typings/src/traits/core/hidden.d.ts 100% 100% 100% 100%
packages/runtime/typings/src/traits/core/event.d.ts 100% 100% 100% 100%
packages/runtime/typings/src/components/chakra-ui/Dialog.d.ts 100% 100% 100% 100%
packages/runtime/typings/src/components/chakra-ui/List.d.ts 100% 100% 100% 100%
packages/runtime/typings/src/components/chakra-ui/Form/FormControl.d.ts 100% 100% 100% 100%
packages/runtime/typings/src/components/chakra-ui/Box.d.ts 100% 100% 100% 100%
packages/runtime/typings/src/components/chakra-ui/HStack.d.ts 100% 100% 100% 100%
packages/runtime/typings/src/components/chakra-ui/Types/ColorScheme.d.ts 100% 100% 100% 100%
packages/runtime/typings/src/components/chakra-ui/CheckboxGroup.d.ts 100% 100% 100% 100%
packages/runtime/typings/src/components/chakra-ui/Select.d.ts 100% 100% 100% 100%
packages/runtime/typings/src/components/chakra-ui/Checkbox.d.ts 100% 100% 100% 100%
packages/runtime/typings/src/components/chakra-ui/Stack.d.ts 100% 100% 100% 100%
packages/runtime/typings/src/components/chakra-ui/Image.d.ts 100% 100% 100% 100%
packages/runtime/typings/src/components/chakra-ui/Input.d.ts 100% 100% 100% 100%
packages/runtime/typings/src/components/chakra-ui/Tooltip.d.ts 100% 100% 100% 100%
packages/runtime/typings/src/components/chakra-ui/Button.d.ts 100% 100% 100% 100%
packages/runtime/typings/src/components/chakra-ui/RadioGroup.d.ts 100% 100% 100% 100%
packages/runtime/typings/src/components/chakra-ui/Root.d.ts 100% 100% 100% 100%
packages/runtime/typings/src/components/chakra-ui/VStack.d.ts 100% 100% 100% 100%
packages/runtime/typings/src/components/chakra-ui/Kbd.d.ts 100% 100% 100% 100%
packages/runtime/typings/src/components/chakra-ui/Radio.d.ts 100% 100% 100% 100%
packages/runtime/typings/src/components/chakra-ui/Table/index.d.ts 100% 100% 100% 100%
packages/runtime/typings/src/components/chakra-ui/Tabs.d.ts 100% 100% 100% 100%
packages/runtime/typings/src/components/_internal/Slot.d.ts 100% 100% 100% 100%
packages/runtime/typings/src/components/_internal/Text.d.ts 100% 100% 100% 100%
packages/runtime/typings/src/components/_internal/ErrorBoundary.d.ts 100% 100% 100% 100%
packages/runtime/typings/src/components/core/Router/component.d.ts 100% 100% 100% 100%
packages/runtime/typings/src/components/core/GridLayout.d.ts 100% 100% 100% 100%
packages/runtime/typings/src/components/core/Text.d.ts 100% 100% 100% 100%
packages/runtime/src/components/chakra-ui/Form/FormCSS.ts 0% 100% 100% 0%
packages/runtime/src/components/chakra-ui/Types/Toast.ts 0% 100% 100% 0%
packages/runtime/src/components/chakra-ui/Table/index.ts 0% 100% 100% 0%
packages/runtime/src/components/core/Router/matcher.ts 0% 0% 0% 0%
packages/runtime/typings/src/components/chakra-ui/Form/FormCSS.d.ts 100% 100% 100% 100%
packages/runtime/typings/src/components/chakra-ui/Form/Form.d.ts 100% 100% 100% 100%
packages/runtime/typings/src/components/chakra-ui/Types/Toast.d.ts 100% 100% 100% 100%
packages/runtime/typings/src/components/chakra-ui/Table/Pagination.d.ts 100% 100% 100% 100%
packages/runtime/typings/src/components/chakra-ui/Table/Table.d.ts 100% 100% 100% 100%
packages/runtime/typings/src/components/chakra-ui/Table/TableTypes.d.ts 100% 100% 100% 100%
packages/runtime/typings/src/components/chakra-ui/Table/TableTd.d.ts 100% 100% 100% 100%
packages/runtime/typings/src/components/core/Router/hooks.d.ts 100% 100% 100% 100%
packages/runtime/typings/src/components/core/Router/index.d.ts 100% 100% 100% 100%
packages/runtime/typings/src/components/core/Router/matcher.d.ts 100% 100% 100% 100%
packages/runtime/src/utils/encodeDragDataTransfer.ts 0% 100% 0% 0%
packages/runtime/src/index.ts 0% 100% 0% 0%
packages/runtime/src/vite-env.d.ts 100% 100% 100% 100%
packages/runtime/src/types/RuntimeSchema.ts 100% 100% 100% 100%
packages/runtime/typings/src/constants.d.ts 0% 100% 100% 0%
packages/runtime/typings/src/index.d.ts 100% 100% 100% 100%
packages/runtime/typings/src/App.d.ts 100% 100% 100% 100%
packages/runtime/typings/src/main.d.ts 100% 100% 100% 100%
packages/runtime/src/services/apiService.ts 0% 100% 0% 0%
packages/runtime/src/services/util-methods.ts 0% 0% 0% 0%
packages/runtime/src/utils/initStateAndMethod.ts 0% 0% 0% 0%
packages/runtime/src/utils/parseType.ts 0% 0% 0% 0%
packages/runtime/src/utils/pickProperty.ts 0% 100% 0% 0%
packages/runtime/src/types/ValidResultSchema.ts 0% 100% 100% 0%
packages/runtime/src/types/TraitPropertiesSchema.ts 0% 100% 100% 0%
packages/runtime/typings/src/services/apiService.d.ts 100% 100% 100% 100%
packages/runtime/src/services/handler.ts 0% 100% 0% 0%
packages/runtime/typings/src/utils/watchReactivity.d.ts 100% 100% 100% 100%
packages/runtime/typings/src/types/ValidResultSchema.d.ts 100% 100% 100% 100%
packages/runtime/typings/src/services/resolveAppComponents.d.ts 100% 100% 100% 100%
packages/runtime/typings/src/services/DebugComponents.d.ts 100% 100% 100% 100%
packages/runtime/typings/src/services/ImplWrapper.d.ts 100% 100% 100% 100%
packages/runtime/typings/src/services/stateStore.d.ts 100% 100% 100% 100%
packages/runtime/typings/src/services/registry.d.ts 100% 100% 100% 100%
packages/runtime/typings/src/services/util-methods.d.ts 100% 100% 100% 100%
packages/runtime/typings/src/services/handler.d.ts 100% 100% 100% 100%
packages/runtime/typings/src/utils/encodeDragDataTransfer.d.ts 100% 100% 100% 100%
packages/runtime/typings/src/utils/parseType.d.ts 100% 100% 100% 100%
packages/runtime/typings/src/utils/parseTypeBox.d.ts 100% 100% 100% 100%
packages/runtime/typings/src/utils/initStateAndMethod.d.ts 100% 100% 100% 100%
packages/runtime/typings/src/utils/pickProperty.d.ts 100% 100% 100% 100%
packages/runtime/typings/src/types/TraitPropertiesSchema.d.ts 100% 100% 100% 100%
packages/runtime/typings/src/types/RuntimeSchema.d.ts 100% 100% 100% 100%
packages/runtime/src/main.tsx 0% 100% 0% 0%
packages/editor/src/eventBus.ts 0% 100% 100% 0%
packages/editor/src/main.tsx 0% 100% 0% 0%
packages/editor/src/constants.ts 0% 100% 100% 0%
packages/editor/src/vite-env.d.ts 100% 100% 100% 100%
packages/editor/src/metaUI.tsx 0% 100% 100% 0%
packages/editor/src/operations/Operations.ts 0% 100% 0% 0%
packages/editor/src/operations/useAppModel.ts 0% 100% 0% 0%
packages/editor/src/components/Editor.tsx 0% 0% 0% 0%
packages/editor/src/components/KeyValueEditor.tsx 0% 0% 0% 0%
packages/editor/src/components/ComponentWrapper.tsx 0% 0% 0% 0%
packages/editor/src/components/KeyboardEventWrapper.tsx 0% 0% 0% 0%
packages/editor/src/components/CodeEditor/index.ts 100% 100% 100% 100%
packages/editor/src/components/ComponentsList/index.ts 100% 100% 100% 100%
packages/editor/src/components/EditorHeader/EditorHeader.tsx 0% 100% 0% 0%
packages/editor/src/components/PreviewModal/PreviewModal.tsx 0% 100% 0% 0%
packages/editor/src/components/StructureTree/StructureTree.tsx 0% 0% 0% 0%
packages/editor/src/components/CodeEditor/StateEditor.tsx 0% 0% 0% 0%
packages/editor/src/components/ComponentsList/ComponentList.tsx 0% 100% 0% 0%
packages/editor/src/components/EditorHeader/index.ts 100% 100% 100% 100%
packages/editor/src/components/PreviewModal/index.ts 100% 100% 100% 100%
packages/editor/src/components/StructureTree/DropComponentWrapper.tsx 0% 0% 0% 0%
packages/editor/src/components/StructureTree/index.ts 100% 100% 100% 100%
packages/editor/src/components/StructureTree/ComponentTree.tsx 0% 0% 0% 0%
packages/editor/src/components/StructureTree/ComponentItemView.tsx 0% 0% 0% 0%
packages/editor/src/components/ComponentForm/index.ts 100% 100% 100% 100%
packages/editor/src/components/ComponentForm/ComponentForm.tsx 0% 0% 0% 0%
packages/editor/src/components/ComponentForm/style.ts 0% 100% 100% 0%
packages/editor/src/components/ComponentForm/FetchTraitForm/FetchTraitForm.tsx 0% 0% 0% 0%
packages/editor/src/components/ComponentForm/EventTraitForm/EventHandlerForm.tsx 0% 0% 0% 0%
packages/editor/src/components/ComponentForm/GeneralTraitFormList/GeneralTraitForm.tsx 0% 0% 0% 0%
packages/editor/src/components/ComponentForm/FetchTraitForm/index.ts 100% 100% 100% 100%
packages/editor/src/components/ComponentForm/EventTraitForm/index.ts 100% 100% 100% 100%
packages/editor/src/components/ComponentForm/EventTraitForm/EventTraitForm.tsx 0% 0% 0% 0%
packages/editor/src/components/ComponentForm/GeneralTraitFormList/AddTraitButton.tsx 0% 100% 0% 0%
packages/editor/src/components/ComponentForm/GeneralTraitFormList/GeneralTraitFormList.tsx 0% 100% 0% 0%
packages/editor/src/components/ComponentForm/GeneralTraitFormList/index.ts 100% 100% 100% 100%

@Yuyz0112
Copy link
Contributor Author

Yuyz0112 commented Oct 27, 2021

The following code has been tested in vite and create-react-app based projects:

yarn add @meta-ui/runtime
import { initMetaUI } from "@meta-ui/runtime";

const { App: MetaApp } = initMetaUI();

const app = {
...
}

function App() {
  return (
    <MetaApp options={app} />
  );
}

export default App;

@@ -5,7 +5,7 @@ import { getSlots } from '../_internal/Slot';
import { Static, Type } from '@sinclair/typebox';
import { partial } from 'lodash';

const BaseGridLayout = React.lazy(() => import('../../components/_internal/GridLayout'));
const BaseGridLayout = React.lazy(() => import('../_internal/GridLayout'));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we lazy load GridLayout here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously, I think users who do not use GridLayout can have smaller code sizes by doing code splitting like this. But since most users will use @meta-ui/runtime as a library, ES module + tree shaking may be a better way.

In this commit, just change the relative path to a shorter one.

@tanbowensg tanbowensg merged commit 5fe5163 into main Oct 27, 2021
@tanbowensg tanbowensg deleted the runtime branch October 27, 2021 06:52
xzdry pushed a commit that referenced this pull request Nov 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants