-
Notifications
You must be signed in to change notification settings - Fork 392
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(cli): correct worker strategy for new bundling
- Loading branch information
1 parent
e640b72
commit 881fd5e
Showing
5 changed files
with
36 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,38 @@ | ||
import {defineConfig} from '@sanity/pkg-utils' | ||
/* eslint-disable no-sync */ | ||
import fs from 'fs' | ||
import path from 'path' | ||
import {defineConfig, PkgExports} from '@sanity/pkg-utils' | ||
import baseConfig from '../../../package.config' | ||
|
||
export default defineConfig({ | ||
...baseConfig, | ||
exports: (exports) => ({ | ||
...exports, | ||
exports: (existingExports) => ({ | ||
...existingExports, | ||
'./cli': { | ||
source: './src/cli.ts', | ||
require: './lib/cli.js', | ||
default: './lib/cli.js', | ||
}, | ||
...getWorkerExports(), | ||
}), | ||
runtime: 'node', | ||
}) | ||
|
||
function getWorkerExports(): PkgExports { | ||
const workersDir = path.join(__dirname, 'src', 'workers') | ||
const sourceFiles = fs | ||
.readdirSync(workersDir) | ||
.filter((file) => file.endsWith('.ts')) | ||
.map((file) => path.basename(file, '.ts')) | ||
|
||
const workers: PkgExports = {} | ||
for (const name of sourceFiles) { | ||
workers[`./workers/${name}`] = { | ||
source: `./src/workers/${name}.ts`, | ||
require: `./lib/workers/${name}.js`, | ||
default: `./lib/workers/${name}.js`, | ||
} | ||
} | ||
|
||
return workers | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...anity/cli/src/util/getCliConfig.worker.ts → ...s/@sanity/cli/src/workers/getCliConfig.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters