添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

I have initialized a project with create-react-native-library (native + js template) and have added watermelonDB as a peer dependency. Watermelon uses decorators and requires the configuration of the plugin @babel/plugin-proposal-decorators which I have added to both package.json as dev dependency and have also added the plugin in both babe.config.js . Along with this I have configured the tsconfig.json in root of the project to include experimentalDecorators as true.

While in vscode it doesn't show any issues in the editor, but when running yarn prepare or yarn it gives me the following error not sure why.

$ bob build
ℹ Building target commonjs
ℹ Cleaning up previous build at lib/commonjs
ℹ Compiling 11 files in src with babel
bob build
build files for publishing
Options:
  --help     Show help                                                 [boolean]
  --version  Show version number                                       [boolean]
SyntaxError: /Users/sarthakpranesh/Github/rn-inspection-report-lib/src/database/models/KeyValueModel.ts: Support for the experimental syntax 'decorators' isn't currently enabled (7:3):
   5 |   static table = 'key_value';
>  7 |   @field('inspection_id') inspectionId!: number | null;
     |   ^
   8 |   @text('key') key!: string;
   9 |   @field('value') value!: string;
  10 | }
Add @babel/plugin-proposal-decorators (https://github.com/babel/babel/tree/main/packages/babel-plugin-proposal-decorators) to the 'plugins' section of your Babel config to enable transformation.
If you want to leave it as-is, add @babel/plugin-syntax-decorators (https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-decorators) to the 'plugins' section to enable parsing.
    at instantiate (/Users/sarthakpranesh/Github/rn-inspection-report-lib/node_modules/@babel/parser/lib/index.js:67:32)
    at constructor (/Users/sarthakpranesh/Github/rn-inspection-report-lib/node_modules/@babel/parser/lib/index.js:364:12)
    at TypeScriptParserMixin.raise (/Users/sarthakpranesh/Github/rn-inspection-report-lib/node_modules/@babel/parser/lib/index.js:3364:19)
    at TypeScriptParserMixin.expectOnePlugin (/Users/sarthakpranesh/Github/rn-inspection-report-lib/node_modules/@babel/parser/lib/index.js:3413:18)
    at TypeScriptParserMixin.parseDecorator (/Users/sarthakpranesh/Github/rn-inspection-report-lib/node_modules/@babel/parser/lib/index.js:13096:10)
    at /Users/sarthakpranesh/Github/rn-inspection-report-lib/node_modules/@babel/parser/lib/index.js:13705:32
    at TypeScriptParserMixin.withSmartMixTopicForbiddingContext (/Users/sarthakpranesh/Github/rn-inspection-report-lib/node_modules/@babel/parser/lib/index.js:12617:14)
    at TypeScriptParserMixin.parseClassBody (/Users/sarthakpranesh/Github/rn-inspection-report-lib/node_modules/@babel/parser/lib/index.js:13694:10)
    at TypeScriptParserMixin.parseClass (/Users/sarthakpranesh/Github/rn-inspection-report-lib/node_modules/@babel/parser/lib/index.js:13669:22)
    at TypeScriptParserMixin.parseClass (/Users/sarthakpranesh/Github/rn-inspection-report-lib/node_modules/@babel/parser/lib/index.js:9840:20)
    at TypeScriptParserMixin.parseExportDefaultExpression (/Users/sarthakpranesh/Github/rn-inspection-report-lib/node_modules/@babel/parser/lib/index.js:14156:19)
    at TypeScriptParserMixin.parseExportDefaultExpression (/Users/sarthakpranesh/Github/rn-inspection-report-lib/node_modules/@babel/parser/lib/index.js:9181:18)
    at TypeScriptParserMixin.parseExport (/Users/sarthakpranesh/Github/rn-inspection-report-lib/node_modules/@babel/parser/lib/index.js:14075:25)
    at TypeScriptParserMixin.parseExport (/Users/sarthakpranesh/Github/rn-inspection-report-lib/node_modules/@babel/parser/lib/index.js:9163:20)
    at TypeScriptParserMixin.parseStatementContent (/Users/sarthakpranesh/Github/rn-inspection-report-lib/node_modules/@babel/parser/lib/index.js:13020:27)
    at TypeScriptParserMixin.parseStatementContent (/Users/sarthakpranesh/Github/rn-inspection-report-lib/node_modules/@babel/parser/lib/index.js:9222:18)
    at TypeScriptParserMixin.parseStatement (/Users/sarthakpranesh/Github/rn-inspection-report-lib/node_modules/@babel/parser/lib/index.js:12917:17)
    at TypeScriptParserMixin.parseBlockOrModuleBlockBody (/Users/sarthakpranesh/Github/rn-inspection-report-lib/node_modules/@babel/parser/lib/index.js:13497:25)
    at TypeScriptParserMixin.parseBlockBody (/Users/sarthakpranesh/Github/rn-inspection-report-lib/node_modules/@babel/parser/lib/index.js:13489:10)
    at TypeScriptParserMixin.parseProgram (/Users/sarthakpranesh/Github/rn-inspection-report-lib/node_modules/@babel/parser/lib/index.js:12832:10)
    at TypeScriptParserMixin.parseTopLevel (/Users/sarthakpranesh/Github/rn-inspection-report-lib/node_modules/@babel/parser/lib/index.js:12822:25)
    at TypeScriptParserMixin.parse (/Users/sarthakpranesh/Github/rn-inspection-report-lib/node_modules/@babel/parser/lib/index.js:14674:10)
    at TypeScriptParserMixin.parse (/Users/sarthakpranesh/Github/rn-inspection-report-lib/node_modules/@babel/parser/lib/index.js:9890:18)
    at parse (/Users/sarthakpranesh/Github/rn-inspection-report-lib/node_modules/@babel/parser/lib/index.js:14716:38)
    at parser (/Users/sarthakpranesh/Github/rn-inspection-report-lib/node_modules/@babel/core/lib/parser/index.js:41:34)
    at parser.next (<anonymous>)
    at normalizeFile (/Users/sarthakpranesh/Github/rn-inspection-report-lib/node_modules/@babel/core/lib/transformation/normalize-file.js:66:38)
    at normalizeFile.next (<anonymous>)
    at run (/Users/sarthakpranesh/Github/rn-inspection-report-lib/node_modules/@babel/core/lib/transformation/index.js:21:50)
    at run.next (<anonymous>)
    at transform (/Users/sarthakpranesh/Github/rn-inspection-report-lib/node_modules/@babel/core/lib/transform.js:22:41)
    at transform.next (<anonymous>)
    at step (/Users/sarthakpranesh/Github/rn-inspection-report-lib/node_modules/gensync/index.js:261:32)
    at /Users/sarthakpranesh/Github/rn-inspection-report-lib/node_modules/gensync/index.js:273:13
    at async.call.result.err.err (/Users/sarthakpranesh/Github/rn-inspection-report-lib/node_modules/gensync/index.js:223:11)
    at /Users/sarthakpranesh/Github/rn-inspection-report-lib/node_modules/gensync/index.js:189:28
    at /Users/sarthakpranesh/Github/rn-inspection-report-lib/node_modules/@babel/core/lib/gensync-utils/async.js:72:7
    at /Users/sarthakpranesh/Github/rn-inspection-report-lib/node_modules/gensync/index.js:113:33
    at step (/Users/sarthakpranesh/Github/rn-inspection-report-lib/node_modules/gensync/index.js:287:14)
    at /Users/sarthakpranesh/Github/rn-inspection-report-lib/node_modules/gensync/index.js:273:13
    at async.call.result.err.err (/Users/sarthakpranesh/Github/rn-inspection-report-lib/node_modules/gensync/index.js:223:11) {
  code: 'BABEL_PARSE_ERROR',
  reasonCode: 'MissingOneOfPlugins',
  loc: Position { line: 7, column: 2, index: 192 },
  pos: [Getter/Setter],
  missingPlugin: [Getter/Setter]
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

Will not be able to share source code.

You need to set configFile to true if you want to use your own babel config:

https://github.com/callstack/react-native-builder-bob#commonjs

Will not be able to share source code.

A repro should be the minimal code to reproduce an issue. No one is asking for your full source code.

You need to set configFile to true if you want to use your own babel config:

https://github.com/callstack/react-native-builder-bob#commonjs

Will not be able to share source code.

A repro should be the minimal code to reproduce an issue. No one is asking for your full source code.