@danielx/civet 0.3.15 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -183,3 +183,109 @@ Things Changed from ES6
183
183
  The reasoning is `x -> ...` => `x(function() ...)` in CoffeeScript and having `->` and `=>`
184
184
  behave more differently than they already do is bad. Passing an anonymous function to an
185
185
  application without parens is also convenient.
186
+
187
+ Using Civet in your Node.js Environment
188
+ ---
189
+
190
+ You have now been convinced that Civet is right for your current/next project. Here is how
191
+ to set up your environment to get productive right away and have a Good Time℠.
192
+
193
+ ### Testing
194
+
195
+ Code coverage with [c8](https://github.com/bcoe/c8) "just works" thanks to their source map
196
+ integration and Civet's source maps.
197
+
198
+ Currently Civet's ESM loader depends on [ts-node](https://www.npmjs.com/package/ts-node)
199
+
200
+ #### c8 + Mocha
201
+
202
+ `package.json`
203
+ ```json
204
+ "scripts": {
205
+ "test": "c8 mocha",
206
+ ...
207
+ },
208
+ "c8": {
209
+ "extension": [
210
+ ".civet"
211
+ ]
212
+ },
213
+ "mocha": {
214
+ "extension": [
215
+ "civet"
216
+ ],
217
+ "loader": [
218
+ "ts-node/esm",
219
+ "@danielx/civet/esm.mjs"
220
+ ],
221
+ ...
222
+ ...
223
+ ```
224
+
225
+ `ts-node` must be configured with `transpileOnly` (it can't resolve alternative extensions). Also I think `module` needs to be at least `ES2020` for the Civet ESM loader to work.
226
+
227
+ `tsconfig.json`
228
+ ```json
229
+ ...
230
+ "ts-node": {
231
+ "transpileOnly": true,
232
+ "compilerOptions": {
233
+ "module": "ES2020"
234
+ }
235
+ }
236
+ ```
237
+
238
+ If you don't care for code coverage you can skip c8 (but it is so easy why not keep it?).
239
+
240
+ You can also add `.js` and `.ts` extensions if you want to mix and match! Even `.coffee` will work if you require `coffeescript/register` or add a loader for it.
241
+
242
+ Execute the tests
243
+
244
+ ```bash
245
+ yarn test
246
+ ```
247
+
248
+ Step 4: Enjoy!
249
+
250
+ ### Developing
251
+
252
+ Use the alpha version of [Civet Language Server](https://marketplace.visualstudio.com/items?itemName=DanielX.civet)
253
+
254
+ The language server provides syntax highlighting, completions, hover documentation, symbols outline, red squigglies, and go to definition.
255
+
256
+ ---
257
+
258
+ *Q?* Why can't I just use the built-in VSCode TypeScript LSP?
259
+
260
+ *A:* VSCode's built in TypeScript LSP can't resolve non `.ts/.js`, not even with plugins. Maybe one day they'll allow for
261
+ plugins that let you adjust the resolver and insert a transpilation step but until then a separate language server is necessary.
262
+
263
+ ---
264
+
265
+ *Q?* Sometimes the file outline disappears and the red squigglies are all in the wrong place and maybe a notification pops up
266
+ about some kind of LSP error.
267
+
268
+ *A:* I'm sorry that happened to you but the Civet Language Server is still alpha and improving rapidly. Please let me know
269
+ exactly what happened and I'll try to do better next time.
270
+
271
+ It may happen when there is a syntax error in your Civet file. You can check and see if it compiles using the CLI tool in the meantime.
272
+
273
+ Please do submit bug reports / feature requests.
274
+
275
+ ### Building
276
+
277
+ I strongly recommend using [esbuild](https://esbuild.github.io/) for building / packaging your Civet project.
278
+
279
+ ```javascript
280
+ import esbuild from 'esbuild'
281
+ import civetPlugin from '@danielx/civet/esbuild-plugin'
282
+
283
+ esbuild.build({
284
+ ...,
285
+ plugins: [
286
+ civetPlugin
287
+ ]
288
+ }).catch(() => process.exit(1))
289
+ ```
290
+
291
+ It's super fast and works great!