design-first / system-runtime

A JavaScript library that runs systems
https://designfirst.io/systemruntime/
Apache License 2.0
121 stars 35 forks source link

feat: ES module compatibility #72

Open ecarriou opened 2 years ago

ecarriou commented 2 years ago

What has been done

<script type="module">
  import runtime from 'https://cdn.jsdelivr.net/npm/system-runtime@6.0.0-beta.5/dist/system-runtime.js'
  const system = runtime.system('mySystem')
  // ...
</script>
  import runtime from 'system-runtime'  
  const system = runtime.system('mySystem')
  // ...
// before
$db.Person.find()

// now
$db.collections.Person.find()
Person.on('anEvent', async (val) => {
  const newValue = await import('../address.js')
  this.address(newValue.default)
})

How to test the PR

Test in HTML

<script type="module">
  import runtime from 'https://cdn.jsdelivr.net/npm/system-runtime@6.0.0-beta.5/dist/system-runtime.js'
</script>
<script type="module">
  import runtime from 'https://cdn.jsdelivr.net/npm/system-runtime@6.0.0-beta.5/dist/system-runtime.js'
  console.log(runtime.version())
</script>

Test with nodeJS

You will have something like that in your package.json:

{
  "type":"module",
  "dependencies": {
    "system-runtime": "^6.0.0-beta.5"
  }
}
import runtime from 'system-runtime'
console.log(runtime.version())

TODO