SublimeHyperClick icon indicating copy to clipboard operation
SublimeHyperClick copied to clipboard

"node:"-prefixed URLs are not supported

Open ArtskydJ opened this issue 3 years ago • 0 comments

Node.js allows for imports like this:

import test from 'node:test';

const { createHmac } = await import('node:crypto');

const EventEmitter = require('node:events');

const fs = require('node:fs');

For some builtin modules, it's the required syntax:

This module is only available under the node: scheme. The following will not work:

import test from 'test';

HyperClick doesn't recognize node modules starting with "node:".


I've worked around this issue using these HyperClick settings:

// ...
            "regexes": [
                "^import\\s+['\"](.+)['\"];?$",
                ".*from\\s+['\"](?:node:)?(.+)['\"];?$",
                ".*require\\(['\"`](.+?)['\"`]\\).*",
                ".*import\\((?:\\/\\*.+?\\*\\/\\s+)?['\"`](?:node:)?(.+)['\"`]\\)(?:[;\\.,])?"
            ],
// ...

However, I don't think that the regex is the correct place to parse out the "node:" prefix.

ArtskydJ avatar Jul 11 '22 20:07 ArtskydJ