Skip to content

Commit

Permalink
Revert "Drop node: protocol for importing Node.js modules (#720)"
Browse files Browse the repository at this point in the history
Revert c805cb3

Originally, we thought that the `node:` prefix might cause problems when bundling tus-js-client. However, it turned out that this was not the case (see linked PR), so we can now add them again.
  • Loading branch information
Acconut committed Jan 24, 2025
1 parent add4e13 commit e9f0740
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"noParameterAssign": "off",
"noDefaultExport": "error",
"useCollapsedElseIf": "error",
"useNodejsImportProtocol": "off"
"useNodejsImportProtocol": "error"
},
"suspicious": {
"noExplicitAny": "error",
Expand Down
4 changes: 2 additions & 2 deletions demos/cordova/hooks/before_prepare/copy_tus_files.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env node

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

const rootDir = path.join(__dirname, '..', '..')
const tusJsPath = path.join(rootDir, '..', '..', 'dist', 'tus.js')
Expand Down
2 changes: 1 addition & 1 deletion demos/nodejs/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createReadStream } from 'fs'
import { createReadStream } from 'node:fs'
import { Upload } from 'tus-js-client'

const path = `${import.meta.dirname}/../../README.md`
Expand Down
2 changes: 1 addition & 1 deletion lib/node/FileUrlStorage.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { readFile, writeFile } from 'fs/promises'
import { readFile, writeFile } from 'node:fs/promises'
import { lock } from 'proper-lockfile'
import type { PreviousUpload, UrlStorage } from '../options.js'

Expand Down
2 changes: 1 addition & 1 deletion lib/node/NodeFileReader.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ReadStream } from 'fs'
import { ReadStream } from 'node:fs'
import isStream from 'is-stream'

import type { FileReader, UploadInput } from '../options.js'
Expand Down
8 changes: 4 additions & 4 deletions lib/node/NodeHttpStack.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// The url.parse method is superseeded by the url.URL constructor,
// but it is still included in Node.js
import * as http from 'http'
import * as https from 'https'
import { Readable, Transform, type Writable } from 'stream'
import { parse } from 'url'
import * as http from 'node:http'
import * as https from 'node:https'
import { Readable, Transform, type Writable } from 'node:stream'
import { parse } from 'node:url'
import throttle from 'lodash.throttle'
import type { HttpProgressHandler, HttpRequest, HttpResponse, HttpStack } from '../options.js'
import type { FileSliceTypes } from './index.js'
Expand Down
6 changes: 3 additions & 3 deletions lib/node/fileSignature.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createHash } from 'crypto'
import * as fs from 'fs'
import * as path from 'path'
import { createHash } from 'node:crypto'
import * as fs from 'node:fs'
import * as path from 'node:path'
import type { UploadInput, UploadOptions } from '../options.js'

export function fingerprint(file: UploadInput, options: UploadOptions): Promise<string | null> {
Expand Down
2 changes: 1 addition & 1 deletion lib/node/sources/NodeFileSource.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type ReadStream, createReadStream, promises as fsPromises } from 'fs'
import { type ReadStream, createReadStream, promises as fsPromises } from 'node:fs'
import type { FileSource } from '../../options.js'

export async function getFileSource(stream: ReadStream): Promise<NodeFileSource> {
Expand Down
4 changes: 2 additions & 2 deletions scripts/setup-exports.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import path, { relative } from 'path'
import { mkdir, readFile, writeFile } from 'fs/promises'
import { mkdir, readFile, writeFile } from 'node:fs/promises'
import path, { relative } from 'node:path'

/**
* Each entry is a "subpackage" that users should be able to import as `tus-js-client/${entry}`.
Expand Down
12 changes: 6 additions & 6 deletions test/spec/test-node-specific.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import crypto from 'crypto'
import { once } from 'events'
import fs from 'fs'
import http from 'http'
import https from 'https'
import stream from 'stream'
import crypto from 'node:crypto'
import { once } from 'node:events'
import fs from 'node:fs'
import http from 'node:http'
import https from 'node:https'
import stream from 'node:stream'
import intoStream from 'into-stream'
import temp from 'temp'
import { Upload, canStoreURLs } from 'tus-js-client'
Expand Down

0 comments on commit e9f0740

Please sign in to comment.