bug: Error Importing 3rd party JS Lib ion-js

Đang mở
#4,085 6 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
25/100
Loại issue
Lỗi
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Đình trệ
Công nghệ
javascript, typescript
Lĩnh vực
frontend

Hướng nghiên cứu

Bắt đầu với bản tái hiện CodeSandbox được liên kết và ví dụ componentDidLoad, sau đó lần theo quyền truy cập IonTypes được báo cáo tại Blob.js:6 qua createCommonjsModule trong utils.ts. Hoàn tất khi có thể import ion-js và phân tích sample ionData trong một dự án khởi đầu Stencil mà không gặp TypeError đã được báo cáo.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Bug: Validated
Prerequisites
Stencil Version

3.0.0

Current Behavior

I am trying to ion-js in Stencil Component. I can get the same code to work in a React workspace but due to module it dosent seem to work in Stencil

componentWillLoad() {
    let ionData = `{ ccp_datatype_name:ResponsiblePerson, ccp_datatype_version:"1.0", definition:type::{ name: PriceSchema, major_version:1, minor_version:0, base:VariantBase, fields:[ { name:category, type:symbol, nullable:false, min_occurs:1, max_occurs:1 }, { name:address_identifier, type:string, nullable:false, min_occurs:1, max_occurs:1 } ] }, status:active, table_name:ccp_datatypes}`;
    let value = ion.load(ionData);
    console.log(value.fields())
  }

This same code works in run kit / React but not in stencil

require("jsbi/package.json"); // jsbi is a peer dependency. 
var ionJs = require("ion-js")
let ionData = `{ ccp_datatype_name:ResponsiblePerson, ccp_datatype_version:"1.0", definition:type::{ name: PriceSchema, major_version:1, minor_version:0, base:VariantBase, fields:[ { name:category, type:symbol, nullable:false, min_occurs:1, max_occurs:1 }, { name:address_identifier, type:string, nullable:false, min_occurs:1, max_occurs:1 } ] }, status:active, table_name:ccp_datatypes}`;


let value = ionJs.load(ionData);


console.log(value.fields());
Expected Behavior

It should be able to parse and use the lib

System Info
Brave / Mac
Steps to Reproduce

Just Put this code in any Stencil Starter Repo under ComponentDidLoad and you should see error in console.

TypeError: Cannot read properties of undefined (reading 'IonTypes')
    at Blob.js:6:36
    at createCommonjsModule (utils.ts:3:1)
    at Lob.js:58:1 undefined   
Code Reproduction URL

https://codesandbox.io/s/issue-in-stencil-and-ion-js-6uzg1w

Additional Information

No response

Ngôn ngữ chính
TypeScript
Star
13.2k
Fork
865
Merge trung bình
2 ngày 16 giờ
Pull request đã merge (30 ngày)
29

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của stenciljs/core

Tất cả issue của stenciljs/core

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.