Skip to content

puerts/puerts-commonjs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 

Repository files navigation

PuerTS CommonJS support

  • add require support for JsEnv. Just like what 1.4.0-rc.0 do.
  • 为JsEnv添加global.require,就像1.4.0-rc.0以前的版本一样。
  • this require would call PuerTS's Loader to loadJS
  • 该require会回调PuerTS的Loader进行JS加载。
  • this repo would include the old D.ts for require style development
  • 本仓库同时附带上global.require以及csharppuerts模块的d.ts

Installation | 安装方式

  1. via openupm | 通过openupm
openupm add com.tencent.puerts.commonjs
  1. via PackageMananger in Unity | 通过内置upm

add from git is not recommended because it cannot control package version. 不建议您使用add from git因为它无法进行版本控制。

  1. install manually | 手动复制安装

使用方式

  env = new JsEnv();
  Puerts.ThirdParty.CommonJS.InjectSupportForCJS(env);
  env.Eval("console.log(require('test.cjs'))");

Handle D.TS | 处理D.ts

本仓库附带了dts,但你需要在您的tsconfig.json处手动加上该d.ts所在目录的位置

  typeRoots: [
    '本仓库upm/Typing目录'
  ]

当然,你也可以将该d.ts手动拷贝到你的项目里使用。