Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support jspm.dev ports with default replacer #20

Open
wojpawlik opened this issue Dec 18, 2020 · 1 comment
Open

Support jspm.dev ports with default replacer #20

wojpawlik opened this issue Dec 18, 2020 · 1 comment

Comments

@wojpawlik
Copy link

Custom replacers look complex, I'd love to be able to just

"denoify": {
  "ports": {
    "sandwich-stream": "https://jspm.dev/npm:sandwich-stream@2.0.2"
  }
}
@garronej
Copy link
Owner

Hi @wojpawlik,

You are right, I should consider support for this. I didn't yet because I am trying to encourage the use of custom replaces that are more versatile and powerful but they are, I agree, much harder to get working as well.

However as a quick fix here is the custom replacer for sanswich-stream:

Create a file named denoify-replacer.js for example and place it in a scripts/ directory:

const {
  makeThisModuleAnExecutableReplacer,
  ParsedImportExportStatement,
} = require("denoify");

makeThisModuleAnExecutableReplacer(
  async ({ parsedImportExportStatement, version }) => {

    if (parsedImportExportStatement.parsedArgument.nodeModuleName === "sandwich-stream") {

      return ParsedImportExportStatement.stringify({
        ...parsedImportExportStatement,
        "parsedArgument": {
          "type": "URL",
          "url": `https://jspm.dev/npm:sandwich-stream@${version}`
        },
      });

    }

    return undefined;

  }
);

Then edit your package.json
image

gitbook-com bot pushed a commit that referenced this issue Oct 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants