generated from darkobits/ts-template
-
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.
- Loading branch information
Showing
10 changed files
with
846 additions
and
348 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,5 +1,5 @@ | ||
import LogFactory from '@darkobits/log' | ||
import { createLogger } from '@darkobits/log' | ||
|
||
export { default as LogPipe } from '@darkobits/log/dist/lib/log-pipe.js' | ||
export { LogPipe } from '@darkobits/log/dist/lib/log-pipe.js' | ||
|
||
export default LogFactory({ heading: 'nr' }) | ||
export default createLogger({ heading: 'nr' }) |
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,17 +1,17 @@ | ||
const LogFactory = require('@darkobits/log') | ||
|
||
const log = LogFactory({ heading: 'smokeTest' }) | ||
|
||
// Note: This is how nr must be imported from a CJS context when it is compiled | ||
// as ESM. | ||
async function main() { | ||
const { defineConfig } = await import('../../../dist/index.js') | ||
if (typeof defineConfig !== 'function') throw new Error('Dynamic import of this package failed.') | ||
const { createLogger } = await import('@darkobits/log') | ||
const log = createLogger({ heading: 'smokeTest' }) | ||
|
||
try { | ||
const { defineConfig } = await import('../../../dist/index.js') | ||
if (typeof defineConfig !== 'function') throw new Error('Dynamic import of this package failed.') | ||
log.verbose(log.chalk.dim.cyan('cjs:dynamic-import'), log.chalk.green('success')) | ||
} catch (err) { | ||
log.error(log.chalk.dim.cyan('cjs:dynamic-import'), err) | ||
} | ||
} | ||
|
||
void main().then(() => { | ||
log.verbose(log.prefix('cjs:dynamic-import'), log.chalk.green('success')) | ||
}).catch(err => { | ||
log.error(log.prefix('cjs:dynamic-import'), err) | ||
process.exit(1) | ||
}) | ||
void main() |
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,19 +1,22 @@ | ||
const LogFactory = require('@darkobits/log') | ||
|
||
const log = LogFactory({ heading: 'smokeTest' }) | ||
|
||
// Note: We should not be able to require() this package because it is compiled | ||
// as ESM. If we get an ERR_REQUIRE_ESM, the test will still pass. Any other | ||
// error will result in a failure. | ||
try { | ||
const { defineConfig } = require('../../../dist') | ||
if (typeof defineConfig !== 'function') throw new Error('[fixtures:cjs] "require" failed.') | ||
log.verbose(log.prefix('cjs:require'), log.chalk.green('success')) | ||
} catch (err) { | ||
if (err.message.includes('require() of ES Module')) { | ||
log.verbose(log.prefix('cjs:require'), log.chalk.yellow.dim('require() of this package failed')) | ||
} else { | ||
log.error(log.prefix('cjs:require'), err) | ||
process.exit(1) | ||
async function main() { | ||
const { createLogger } = await import('@darkobits/log') | ||
const log = createLogger({ heading: 'smokeTest' }) | ||
|
||
try { | ||
const { defineConfig } = require('../../../dist') | ||
if (typeof defineConfig !== 'function') throw new Error('[fixtures:cjs] "require" failed.') | ||
log.verbose(log.chalk.dim.cyan('cjs:require'), log.chalk.green('success')) | ||
} catch (err) { | ||
if (err.message.includes('require() of ES Module')) { | ||
log.verbose(log.chalk.dim.cyan('cjs:require'), log.chalk.yellow.dim('require() of this package failed')) | ||
} else { | ||
log.error(log.chalk.dim.cyan('cjs:require'), err) | ||
process.exit(1) | ||
} | ||
} | ||
} | ||
} | ||
|
||
void main() |
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,12 +1,12 @@ | ||
import LogFactory from '@darkobits/log' | ||
import { createLogger } from '@darkobits/log' | ||
|
||
const log = LogFactory({ heading: 'smokeTest' }) | ||
const log = createLogger({ heading: 'smokeTest' }) | ||
|
||
import { defineConfig } from '../../../dist/index.js' | ||
|
||
if (typeof defineConfig !== 'function') { | ||
log.error(log.prefix('esm:import'), `Expected type of default export to be "function", got "${typeof defaultExport}".`) | ||
log.error(log.chalk.dim.cyan('esm:import'), `Expected type of default export to be "function", got "${typeof defaultExport}".`) | ||
process.exit(1) | ||
} else { | ||
log.verbose(log.prefix('esm:import'), log.chalk.green('success')) | ||
log.verbose(log.chalk.dim.cyan('esm:import'), log.chalk.green('success')) | ||
} |
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