Skip to content

Commit 9afd342

Browse files
committed
Update fetch storage to ESM
1 parent 13f20c2 commit 9afd342

File tree

3 files changed

+6
-9
lines changed

3 files changed

+6
-9
lines changed

icechunk-js/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ export default defineConfig({
132132
plugins: [wasm(), topLevelAwait()],
133133
optimizeDeps: {
134134
exclude: ['@earthmover/icechunk', '@earthmover/icechunk-wasm32-wasi'],
135+
include: ['@earthmover/icechunk > @earthmover/icechunk-wasm32-wasi'],
135136
},
136137
server: {
137138
headers: {
Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
* const repo = await Repository.open(storage)
1010
*/
1111

12-
const { Storage } = require('@earthmover/icechunk')
12+
import { Storage } from '@earthmover/icechunk'
1313

1414
/**
1515
* @param {string} baseUrl - Base URL of the icechunk repository (no trailing slash)
1616
* @returns {Storage}
1717
*/
18-
function createFetchStorage(baseUrl) {
18+
export function createFetchStorage(baseUrl) {
1919
// Normalize: strip trailing slash
2020
const base = baseUrl.replace(/\/+$/, '')
2121

@@ -57,9 +57,7 @@ function createFetchStorage(baseUrl) {
5757
},
5858

5959
listObjects: async (_err, prefix) => {
60-
// Try S3-style XML listing
61-
// Derive bucket URL and key prefix from the base URL
62-
// e.g. https://bucket.s3.region.amazonaws.com/prefix -> bucket URL + key prefix
60+
// S3-style XML listing
6361
const url = new URL(base)
6462
const keyPrefix = url.pathname.replace(/^\//, '') + '/' + prefix
6563
const listUrl = `${url.origin}/?list-type=2&prefix=${encodeURIComponent(keyPrefix)}`
@@ -126,5 +124,3 @@ function createFetchStorage(baseUrl) {
126124
},
127125
})
128126
}
129-
130-
module.exports = { createFetchStorage }

icechunk-js/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@
2626
},
2727
"./fetch-storage": {
2828
"types": "./fetch-storage.d.ts",
29-
"default": "./fetch-storage.js"
29+
"default": "./fetch-storage.mjs"
3030
}
3131
},
3232
"files": [
3333
"index.d.ts",
3434
"index.js",
3535
"browser.js",
36-
"fetch-storage.js",
36+
"fetch-storage.mjs",
3737
"fetch-storage.d.ts"
3838
],
3939
"napi": {

0 commit comments

Comments
 (0)