s-libs icon indicating copy to clipboard operation
s-libs copied to clipboard

[micro-dash] No longer publishing cjs?

Open benallfree opened this issue 4 years ago • 7 comments

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?

benallfree avatar Jan 07 '22 20:01 benallfree

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?

ersimont avatar Jan 07 '22 23:01 ersimont

I saw that SO post as well, but have yet to get ts-node or node-dev to actually work with mjs modules.

benallfree avatar Jan 08 '22 04:01 benallfree

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?

ersimont avatar Jan 10 '22 21:01 ersimont

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 :(

benallfree avatar Jan 10 '22 23:01 benallfree

Found this https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c

benallfree avatar Jan 12 '22 16:01 benallfree

Looks like a good resource. Has it helped?

ersimont avatar Jan 13 '22 14:01 ersimont

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

ersimont avatar Jan 19 '22 16:01 ersimont

Just cleaning up a few old, open tickets that don't have action items for me

ersimont avatar May 25 '24 12:05 ersimont