Skip to content

fix: remove dynamic imports #169

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

Merged
merged 1 commit into from
Aug 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 0 additions & 35 deletions packages/ipfs-unixfs-importer/src/chunker/index.js

This file was deleted.

3 changes: 2 additions & 1 deletion packages/ipfs-unixfs-importer/src/dag-builder/file/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import * as dagPb from '@ipld/dag-pb'
import dagFlat from './flat.js'
import dagBalanced from './balanced.js'
import dagTrickle from './trickle.js'
import bufferImporterFn from './buffer-importer.js'

/**
* @typedef {import('interface-blockstore').Blockstore} Blockstore
Expand Down Expand Up @@ -41,7 +42,7 @@ async function * buildFileBatch (file, blockstore, options) {
if (typeof options.bufferImporter === 'function') {
bufferImporter = options.bufferImporter
} else {
bufferImporter = (await (import('./buffer-importer.js'))).default
bufferImporter = bufferImporterFn
}

for await (const entry of parallelBatch(bufferImporter(file, blockstore, options), options.blockWriteConcurrency)) {
Expand Down
9 changes: 6 additions & 3 deletions packages/ipfs-unixfs-importer/src/dag-builder/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import dirBuilder from './dir.js'
import fileBuilder from './file/index.js'
import errCode from 'err-code'
import rabin from '../chunker/rabin.js'
import fixedSize from '../chunker/fixed-size.js'
import validateChunks from './validate-chunks.js'

/**
* @typedef {import('../types').File} File
Expand Down Expand Up @@ -75,9 +78,9 @@ async function * dagBuilder (source, blockstore, options) {
if (typeof options.chunker === 'function') {
chunker = options.chunker
} else if (options.chunker === 'rabin') {
chunker = (await (import('../chunker/rabin.js'))).default
chunker = rabin
} else {
chunker = (await (import('../chunker/fixed-size.js'))).default
chunker = fixedSize
}

/**
Expand All @@ -88,7 +91,7 @@ async function * dagBuilder (source, blockstore, options) {
if (typeof options.chunkValidator === 'function') {
chunkValidator = options.chunkValidator
} else {
chunkValidator = (await (import('./validate-chunks.js'))).default
chunkValidator = validateChunks
}

/** @type {File} */
Expand Down
6 changes: 4 additions & 2 deletions packages/ipfs-unixfs-importer/src/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import parallelBatch from 'it-parallel-batch'
import defaultOptions from './options.js'
import dagBuilderFn from './dag-builder/index.js'
import treeBuilderFn from './tree-builder.js'

/**
* @typedef {import('interface-blockstore').Blockstore} Blockstore
Expand Down Expand Up @@ -32,15 +34,15 @@ export async function * importer (source, blockstore, options = {}) {
if (typeof options.dagBuilder === 'function') {
dagBuilder = options.dagBuilder
} else {
dagBuilder = (await (import('./dag-builder/index.js'))).default
dagBuilder = dagBuilderFn
}

let treeBuilder

if (typeof options.treeBuilder === 'function') {
treeBuilder = options.treeBuilder
} else {
treeBuilder = (await (import('./tree-builder.js'))).default
treeBuilder = treeBuilderFn
}

/** @type {AsyncIterable<ImportCandidate> | Iterable<ImportCandidate>} */
Expand Down