-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #214 from jill64/issue-213
feat: use conditional exports instead $app.environment
- Loading branch information
Showing
11 changed files
with
71 additions
and
53 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,18 @@ | ||
import { build } from 'esbuild' | ||
import esbuild from 'esbuild' | ||
|
||
const opts = { | ||
bundle: true, | ||
minify: true, | ||
format: 'esm' | ||
} as const | ||
const build = (path: string, external?: string[]) => | ||
esbuild.build({ | ||
entryPoints: [`src/${path}.ts`], | ||
outfile: `dist/${path}.js`, | ||
bundle: true, | ||
minify: true, | ||
format: 'esm', | ||
external: ['$app/*', ...(external ?? [])] | ||
}) | ||
|
||
build({ | ||
...opts, | ||
entryPoints: ['src/index.ts'], | ||
outfile: 'dist/index.js', | ||
external: ['$app/*', 'toucan-js'] | ||
}) | ||
|
||
build({ | ||
...opts, | ||
entryPoints: ['src/client/index.ts'], | ||
outfile: 'dist/client/index.js', | ||
external: ['$app/*'] | ||
}) | ||
|
||
build({ | ||
...opts, | ||
entryPoints: ['src/server/index.ts'], | ||
outfile: 'dist/server/index.js', | ||
external: ['$app/*', 'toucan-js'] | ||
}) | ||
build('index', ['toucan-js']) | ||
build('index-dev', ['toucan-js']) | ||
build('client/index') | ||
build('client/index-dev') | ||
build('server/index', ['toucan-js']) | ||
build('server/index-dev', ['toucan-js']) |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
export { init } from './init-dev.js' |
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { HandleClientError } from '@sveltejs/kit' | ||
import { Captured } from '../common/types/Captured.js' | ||
import { init as initProd } from './init.js' | ||
import { InitOptions } from './types/InitOptions.js' | ||
|
||
export const init = ( | ||
/** | ||
* Sentry DSN | ||
* @see https://docs.sentry.io/product/sentry-basics/dsn-explainer/ | ||
*/ | ||
dsn: string, | ||
/** | ||
* Client Init Options | ||
*/ | ||
options?: InitOptions | ||
): Captured<HandleClientError> => | ||
options?.enableInDevMode | ||
? initProd(dsn, options) | ||
: (handleError = () => {}) => handleError |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export { init as clientInit } from './client/init-dev.js' | ||
export { init as serverInit } from './server/init-dev.js' |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
export { init } from './init-dev.js' |
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { init as initProd } from './init.js' | ||
import { HandleWrappers } from './types/HandleWrappers.js' | ||
import { InitOptions } from './types/InitOptions.js' | ||
import { defaultErrorHandler } from './util/defaultErrorHandler.js' | ||
import { defaultHandler } from './util/defaultHandler.js' | ||
|
||
export const init = ( | ||
/** | ||
* Sentry DSN | ||
* @see https://docs.sentry.io/product/sentry-basics/dsn-explainer/ | ||
*/ | ||
dsn: string, | ||
/** | ||
* Server Init Options | ||
*/ | ||
options?: InitOptions | ||
): HandleWrappers => | ||
options?.enableInDevMode | ||
? initProd(dsn, options) | ||
: { | ||
onHandle: (handle = defaultHandler) => handle, | ||
onError: (handleError = defaultErrorHandler) => handleError | ||
} |
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