[micro-dash] No longer publishing cjs?
I noticed that v13 has only .mjs files and the bundles UMD output is gone. This is problematic because when I run with ts-node, I get:
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: ./node_modules/@s-libs/micro-dash/fesm2015/micro-dash.mjs
Does anyone know how to solve this?
Good question, and one I'm going to have to deal with at work before we can upgrade Angular 13. s-libs uses the Angular CLI for its buildchain and tooling, and it no longer produces UMD bundles.
I'm afraid I'm not very well versed with ts-node. What version of it are you at? This SO answer says version 10 would fix ... an error someone had that might be relevant?
I saw that SO post as well, but have yet to get ts-node or node-dev to actually work with mjs modules.
Have you looked at https://github.com/TypeStrong/ts-node/issues/1007? I seem to have gotten a little further with it, but it didn't solve everything for me yet. Maybe you'll have more luck?
I briefly attempted to get ts-node to accept the .mjs files in v13 of micro-dash, but no success to report yet. For now I'm sticking with v12 since v13 seems broken as far as Typescript is concerned :(
Found this https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
Looks like a good resource. Has it helped?
I've started a little hobby project, and was able to consume the .mjs files following the advice at https://github.com/TypeStrong/ts-node/issues/1007. Here's my config:
// package.json
{ "type": "module" }
// tsconfig.json
{
"compilerOptions": {
"module": "ESNext",
"target": "ES2020",
"types": ["node"],
"moduleResolution": "node",
"sourceMap": true
}
}
And some sample import syntax:
import { property } from '@s-libs/micro-dash';
import * as tf from '@tensorflow/tfjs-node';
import * as fs from 'fs';
import * as readline from 'readline';
import { INPUT_SIZE } from './build-vgg-model.js';
import { ImageInfo } from './image-info.js';
(Note that the last two imports are actually typescript files, but still have the .js suffix. Which is weird, but it's what they say to do 🤷♀️.
I run scripts with a command like:
node --loader ts-node/esm scripts/train-cropping.ts
Just cleaning up a few old, open tickets that don't have action items for me