To reproduce:
❯ volta --version
1.0.4
❯ npm --version
7.14.0
❯ npm install -g https://gist.github.com/cspotcode/c07208f11ed73dc7f81a0200e5aeb797.git
// $HOME/.npm-init.js | |
function main() { | |
// Put your customizations here | |
package.private = true; | |
} | |
// Helpers for getting access to modules that are either installed globally or available as dependencies of npm | |
function requireGlobal(name) { | |
return require(require('path').join(config.get('prefix'), 'node_modules', name)); | |
} |
#Thread-safe data structure to store prompt strings and communicate about state | |
$prompt = [Collections.Concurrent.ConcurrentDictionary[String,String]]@{} | |
$prompt.infix = '' | |
Set-PSReadlineOption -ExtraPromptLineCount 1 # For 2-line prompt | |
Register-EngineEvent -SourceIdentifier PowerShell.OnIdle -Action { | |
if($prompt.state -eq 'rerender') { | |
$prompt.isIdleRender = 'yes' | |
[Microsoft.PowerShell.PSConsoleReadLine]::InvokePrompt() | |
$prompt.isIdleRender = 'no' |
// TODO also support quoting? | |
function execTmpl(tmpl: TemplateStringsArray, ...rest: Array<string | Array<string>>) { | |
const delim = {}; | |
const acc = []; | |
for(let i = 0; i < tmpl.length; i++) { | |
if(tmpl[i].length !== 0) { | |
const bits = tmpl[i].split(/ +/); | |
for(let j = 0; j < bits.length; j++) { | |
// whitespace becomes a delim |
const target = './releases/yarn-berry.cjs'; | |
// Change URL to refer to specific commit if you want version to be locked | |
const url = 'https://github.com/yarnpkg/berry/raw/master/packages/berry-cli/bin/berry.js'; | |
const Path = require('path') | |
const fs = require('fs') | |
const targetPath = Path.join(__dirname, target) | |
if(fs.existsSync(targetPath)) { | |
require(targetPath) | |
} else { |
console.log('hello world'); |
To reproduce:
❯ volta --version
1.0.4
❯ npm --version
7.14.0
❯ npm install -g https://gist.github.com/cspotcode/c07208f11ed73dc7f81a0200e5aeb797.git
We think of .d.ts as having two styles: the ambient declare module style (Ambient) and the named "DT" style. (Named)
declare module "some string" {
tells the compiler that, from then forward, if it ever sees any import of "some string"
then it need look no further. It will not attempt to find anything on the filesystem, it will not scan through directories, none of that at all.
On the other hand, if you put export const foo...
at the beginning of a .d.ts
, then the .d.ts
itself is essentially pretending to be a .js
file (Named) and imports will pass through typescript's resolver, doing all sorts of path mapping and filesystem traversal to find the .d.ts
file.
The .d.ts
's filename only matters in the latter case, where the declaration is pretending to by a .js
file. (Named)
In the former case, (Ambient) where the .d.ts
exists to declare global types or declare module
, the .d.ts
's filename does not matter. All that matters is that the compiler has
{ | |
"name": "yaml-loader", | |
"exports": { | |
".": "./yaml-loader.mjs" | |
} | |
} |
To try this, run npm start