-
Notifications
You must be signed in to change notification settings - Fork 585
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
Babel plugin changes #4938
Merged
Merged
Babel plugin changes #4938
Changes from 62 commits
Commits
Show all changes
63 commits
Select commit
Hold shift + click to select a range
3f85e81
Data and LinkingObjects types
54d29d2
Add support for static properties
88a933a
Decorators support, needs tsc fixing
d19ae3a
Fix types for decorators
ca09443
Updated template app and added decorators
c53deb7
Add decorators to full schema test
4d71b49
Add test for type precedence
530b316
Disable test
8eed123
Add babel-plugin-decorators check
63f3678
Add checking for decorator import
c63b955
WIP on template app and rollup config
bfcc625
Add Realm.Types ctors
c407354
Add missing ref
428f06e
Handle non-TS source files with a warning
e6f564a
WIP on PR fixes
363c99e
Fix Realm.Types
e888bb2
PR changes
16fdf05
Move index.test.ts back
8e16be8
PR fixes
8f7acab
Allow override for JS template model
728e873
WIP
20fe632
Update template sync script to allow overrides, and update templates …
823cfec
Type tweak
fa339d6
Add publish workflow for babel plugin
270327a
Add README
ad1190e
Add babel-plugin deps properly
214a261
Update readme
7f8d194
Add missing primary key
b8022c8
Add types for plugin statics
fc6c1f4
Add table
2295820
WIP on README
467c1c6
Throw error if schema already defined
bb92553
WIP on moving to class-based models syntax
f4f34aa
WIP with example app etc
5c2b7e1
Add support and test for function default properties
e27517b
WIP
b2f6d59
Delete generate
7bb1e10
Add type for RequiredFields on Realm.Object
5b1c627
Add docblock and fix types
cbb07ac
Update example JS
cea7529
WIP on template app
e6b47a6
Update template RN version
7a0d6e2
Revert templates and example
360007f
Readme
0210b20
Readme update
e319fa0
Ignore generated types dir
0030310
PR tidy
0a789a8
More PR tidy
cefb8bd
Fix lint
facf2a9
Add workflow for babel plugin
e2a70a9
Readme fix
c5357d8
Update errors to use buildCodeFrameError
ae5d3c7
Revert "Fix lint"
c6627d8
Revert "Add docblock and fix types"
904b374
Revert "Add type for RequiredFields on Realm.Object"
f2b951f
Revert "Add support and test for function default properties"
bedf559
PR changes
e131633
Remove decorators from output
ec86219
Move decorators into Realm package and throw if used at runtime
358466c
Remove decorators from plugin and remove rollup in favour of tsc
77286a3
Handle decorators imported from Realm
5190b15
Changelog
036fa7b
Update pr-babel-plugin.yml
kraenhansen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
name: Testing Babel Plugin (Pull Request) | ||
|
||
env: | ||
REALM_DISABLE_ANALYTICS: 1 | ||
|
||
on: | ||
pull_request: | ||
paths: | ||
- "*" | ||
- "lib/**" | ||
- "src/**" | ||
- "types/**" | ||
- "react-native/**" | ||
- "vendor/**" | ||
# Integration tests | ||
- "integration-tests/**" | ||
- "packages/babel-plugin/**" | ||
- ".github/workflows/pr-babel-plugin.yml" | ||
# No need to run when updating documentation | ||
- "!**.md" | ||
jobs: | ||
job: | ||
name: Build & test | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
submodules: "recursive" | ||
|
||
- uses: actions/setup-node@v1 | ||
with: | ||
node-version: 16 | ||
registry-url: https://registry.npmjs.org/ | ||
|
||
- name: Install npm v7 | ||
run: npm install -g npm@8 | ||
|
||
# Caches | ||
- uses: actions/cache@v2 | ||
name: cached node_modules | ||
id: cache-node-modules | ||
with: | ||
path: node_modules | ||
key: node-modules-${{ github.job }}-${{ hashFiles('package-lock.json') }} | ||
|
||
- name: ccache | ||
uses: hendrikmuhs/ccache-action@v1 | ||
with: | ||
key: babel-plugin | ||
|
||
- name: Prepend ccache executables to the PATH | ||
run: echo PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" >> $GITHUB_ENV | ||
|
||
- name: Install realm node dependencies | ||
run: npm ci | ||
|
||
- name: Bootstrap @realm/babel-plugin | ||
run: npx lerna bootstrap --scope @realm/babel-plugin --include-dependencies | ||
env: | ||
npm_config_realm_local_prebuilds: ${{ github.workspace }}/prebuilds | ||
- name: Build realm react | ||
working-directory: packages/babel-plugin | ||
run: npm run build | ||
|
||
- name: Run tests | ||
working-directory: packages/babel-plugin | ||
run: npm run test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: Publish Babel Plugin | ||
|
||
on: | ||
push: | ||
tags: | ||
- babel-plugin-v* | ||
env: | ||
REALM_DISABLE_ANALYTICS: 1 | ||
|
||
jobs: | ||
test-build-and-publish: | ||
name: Test, build & publish | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v1 | ||
with: | ||
node-version: 16 | ||
registry-url: https://registry.npmjs.org/ | ||
- name: Install npm v7 | ||
run: npm install -g npm@8 | ||
# Install the root package (--ignore-scripts to avoid downloading or building the native module) | ||
- run: npm ci --ignore-scripts | ||
# Bootstrap lerna sub-packages | ||
- run: npx lerna bootstrap | ||
# Test the package | ||
- run: npm test | ||
working-directory: packages/babel-plugin | ||
# Publish the package | ||
- run: npm publish | ||
working-directory: packages/babel-plugin | ||
env: | ||
NODE_AUTH_TOKEN: ${{secrets.npm_token}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
//////////////////////////////////////////////////////////////////////////// | ||
// | ||
// Copyright 2022 Realm Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
//////////////////////////////////////////////////////////////////////////// | ||
|
||
import { expect } from "chai"; | ||
import Realm from "realm"; | ||
|
||
describe("Realm.Types namespace", () => { | ||
// We specify explicit types on the instance so TS will error if the type def is wrong | ||
it("Realm.Types.Decimal128 can be constructed", () => { | ||
const instance: Realm.Types.Decimal128 = new Realm.Types.Decimal128(); | ||
expect(instance).to.be.instanceOf(Realm.BSON.Decimal128); | ||
}); | ||
|
||
it("Realm.Types.ObjectId can be constructed", () => { | ||
const instance: Realm.Types.ObjectId = new Realm.Types.ObjectId(); | ||
expect(instance).to.be.instanceOf(Realm.BSON.ObjectId); | ||
}); | ||
|
||
it("Realm.Types.UUID can be constructed", () => { | ||
const instance: Realm.Types.UUID = new Realm.Types.UUID(); | ||
expect(instance).to.be.instanceOf(Realm.BSON.UUID); | ||
}); | ||
|
||
it("Realm.Types.Date can be constructed", () => { | ||
const instance: Realm.Types.Date = new Realm.Types.Date(); | ||
expect(instance).to.be.instanceOf(Date); | ||
}); | ||
|
||
it("Realm.Types.Data can be constructed", () => { | ||
const instance: Realm.Types.Data = new Realm.Types.Data(); | ||
expect(instance).to.be.instanceOf(ArrayBuffer); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
dist | ||
types/generated/ |
Empty file.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The initial announcement of the plugin can be done here. For the future I suggest that plugin's package has its own changelog.