1amageek / pring.ts

Cloud Firestore model framework for TypeScript - Google
https://firebase.google.com/docs/firestore/
MIT License
108 stars 7 forks source link

ブラウザでも動作させるためにmodule形式をcommonjsからesモジュールに変えてほしい #28

Closed kahirokunn closed 5 years ago

kahirokunn commented 5 years ago

現在のフロントエンドだと主流のモジュールシステムはes6です。 commonjsとesmoduleの混在はできないです。 それに関するissue: https://tech-1natsu.hatenablog.com/entry/2017/10/21/142210 上のissueの内容を見ると一応超頑張ってesモジュールを全て捨ててcommonjsに寄せればいけるみたいですが、他の依存関係のあるフロントエンドのモジュールが死んでしまいます。

vue cliのtranspiledependencies機能を使ってみても以下のようなエラーが出て上手く動きませんでした。 https://cli.vuejs.org/config/#transpiledependencies

  Error: webpack-internal:///./node_modules/core-js/modules/_is-object.js:5
  module.exports = function (it) {
                 ^
  TypeError: Cannot assign to read only property 'exports' of object '#<Object>'

  - _is-object.js:5 Module.eval
    [.]/[core-js]/modules/_is-object.js:5:16

  - _is-object.js:8 eval
    [.]/[core-js]/modules/_is-object.js:8:30

  - index.html:1046 Module../node_modules/core-js/modules/_is-object.js
    /Users/k-okina/Documents/test-pring/public/index.html:1046:1

  - index.html:684 __webpack_require__
    /Users/k-okina/Documents/test-pring/public/index.html:684:30

  - index.html:61 fn
    /Users/k-okina/Documents/test-pring/public/index.html:61:20

  - _inherit-if-required.js:1 eval
    [.]/[core-js]/modules/_inherit-if-required.js:1:16

  - index.html:1011 Object../node_modules/core-js/modules/_inherit-if-required.js
    /Users/k-okina/Documents/test-pring/public/index.html:1011:1

  - index.html:684 __webpack_require__
    /Users/k-okina/Documents/test-pring/public/index.html:684:30

  - index.html:61 fn
    /Users/k-okina/Documents/test-pring/public/index.html:61:20

  - es6.regexp.constructor.js:3 eval
    [.]/[core-js]/modules/es6.regexp.constructor.js:3:25

それに関する議論もここで確認できます。 https://github.com/vuejs/vue-cli/issues/1568

普通のフロント開発でも扱えるようにes6モジュールでのexportをどうかしていただけないでしょうか?何卒よろしくおねがいします!

kahirokunn commented 5 years ago
2018-09-19 18 23 27

一応vue.jsで利用した際のエラーの詳細です。 Pring.Baseクラスは一切圧縮されていないes6公文ですが、自身で定義したclassはUserとかのような感じになっていてextendsキーワードを利用できていません。

kahirokunn commented 5 years ago

多分tsconfig.jsonのmoduleがes6になれば普通に継承できるようになる気がしています。

1amageek commented 5 years ago

tsconfigの設定を変えれば動くと思いますよ。Readmeに書いてあります。For web client

1amageek commented 5 years ago

クローズしますね!