Skip to content

Instantly share code, notes, and snippets.

@ivansglazunov
Last active September 28, 2022 13:30
Show Gist options
  • Save ivansglazunov/450e028fccc4dbcb2ae0cdde37dad1d0 to your computer and use it in GitHub Desktop.
Save ivansglazunov/450e028fccc4dbcb2ae0cdde37dad1d0 to your computer and use it in GitHub Desktop.
@deep-foundation/tsx
{"package":{"name":"@deep-foundation/tsx","version":"0.0.2"},"data":[{"package":{"dependencyId":0,"containValue":"Symbol"},"id":1},{"package":{"dependencyId":0,"containValue":"Type"},"id":2},{"package":{"dependencyId":0,"containValue":"SyncTextFile"},"id":3},{"package":{"dependencyId":0,"containValue":"Handler"},"id":4},{"package":{"dependencyId":0,"containValue":"dockerSupportsJs"},"id":5},{"package":{"dependencyId":0,"containValue":"HandleUpdate"},"id":6},{"package":{"dependencyId":0,"containValue":"HandleInsert"},"id":7},{"package":{"dependencyId":0,"containValue":"Value"},"id":8},{"package":{"dependencyId":0,"containValue":"String"},"id":9},{"id":"tsxSymbol","type":1,"from":"TSX","to":"TSX","value":{"value":"📑"}},{"id":"TSX","type":2,"value":{"value":"TSX"}},{"id":"compiler","type":3,"value":{"value":"\nasync ({ deep, require, gql, data: { newLink } }) => {\n const ts = require('typescript');\n const { data: [generatedFrom] } = await deep.select({\n type_id: await deep.id('@deep-foundation/core', 'GeneratedFrom'),\n to_id: newLink.id,\n });\n const value = newLink?.value?.value;\n let compiledString = '';\n if (value) {\n const result = ts.transpileModule(value, {\n \"compilerOptions\": {\n \"allowSyntheticDefaultImports\": true,\n \"experimentalDecorators\": true,\n \"sourceMap\": true,\n \"noImplicitAny\": false,\n \"removeComments\": true,\n \"jsx\": \"react\",\n \"module\": \"commonjs\",\n \"moduleResolution\": \"node\",\n \"target\": \"es2015\",\n \"skipLibCheck\": true,\n \"resolveJsonModule\": true,\n \"esModuleInterop\": true,\n \"isolatedModules\": true\n }\n });\n compiledString = result.outputText || '';\n }\n if (!generatedFrom) {\n await deep.insert({\n type_id: await deep.id('@deep-foundation/core', 'GeneratedFrom'),\n to_id: newLink.id,\n in: { data: {\n type_id: await deep.id('@deep-foundation/core', 'Contain'),\n from_id: newLink.id,\n } },\n from: { data: {\n type_id: await deep.id('@deep-foundation/core', 'SyncTextFile'),\n string: { data: { value: compiledString } },\n in: { data: {\n type_id: await deep.id('@deep-foundation/core', 'Contain'),\n from_id: newLink.id,\n string: { data: { value: 'generated' } },\n } },\n } },\n });\n } else {\n await deep.update({\n link_id: { _eq: generatedFrom.from_id },\n }, {\n value: compiledString,\n }, { table: 'strings' });\n }\n}\n "}},{"id":"handler","type":4,"from":5,"to":"compiler"},{"id":"handleUpdate","type":6,"from":"TSX","to":"handler"},{"id":"handleInsert","type":7,"from":"TSX","to":"handler"},{"id":"tsxValue","type":8,"from":"TSX","to":9}],"errors":[],"dependencies":[{"name":"@deep-foundation/core"}]}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment