jacobparis-insiders / sly

Monorepo for Sly CLI
https://sly-cli.fly.dev/
153 stars 11 forks source link

transformers fail to load on Windows #7

Closed ToppleTheNun closed 10 months ago

ToppleTheNun commented 10 months ago

Transformers fail to load on Windows machines. This is likely due to how ESM module import paths work on Windows: nodejs/node#31710

OS: Windows 10 Node verison: v20.3.1 Sly version: 1.4.10

terminal output

$ npx sly add @radix-ui/icons moon sun --yes
(node:42732) ExperimentalWarning: Custom ESM Loaders is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
Failed to load transformer transform-icon.ts.
TypeError: The URL must be of scheme file

sly.json

{
  "$schema": "https://sly-cli.fly.dev/registry/config.json",
  "libraries": [
    {
      "name": "@radix-ui/icons",
      "directory": "./other/svg-icons",
      "postinstall": ["npm", "run", "build:icons"],
      "transformers": ["transform-icon.ts"]
    }
  ]
}

transform-icon.ts

import { type Meta } from "@sly-cli/sly";

/**
 * @type {import('@sly-cli/sly/dist').Transformer}
 */
export default function transformIcon(input: string, meta: Meta) {
  input = prependLicenseInfo(input, meta);

  return input;
}

function prependLicenseInfo(input: string, meta: Meta): string {
  return [
    `<!-- Downloaded from ${meta.name} -->`,
    `<!-- License ${meta.license} -->`,
    `<!-- ${meta.source} -->`,
    input,
  ].join("\n");
}
mattstobbs commented 10 months ago

Has the fix for this been released to npm? I'm seeing the same error

jacobparis commented 10 months ago

Oh I forgot I don’t have publish on CI set up, I will publish the fix when my flight lands

Thanks, Jacob Paris

mattstobbs commented 8 months ago

Sorry, were you able to publish this? The latest version I can see is still 1.4.10