feat(core): export version (#254)
This commit is contained in:
parent
4547d85a38
commit
fd209f5a66
@ -1,7 +1,10 @@
|
|||||||
|
const lernaJson = require('./lerna.json')
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
preset: 'ts-jest',
|
preset: 'ts-jest',
|
||||||
globals: {
|
globals: {
|
||||||
__DEV__: true,
|
__DEV__: true,
|
||||||
|
__VERSION__: lernaJson.version,
|
||||||
__BROWSER__: false,
|
__BROWSER__: false,
|
||||||
__JSDOM__: true,
|
__JSDOM__: true,
|
||||||
__RUNTIME_COMPILE__: true,
|
__RUNTIME_COMPILE__: true,
|
||||||
|
1
packages/global.d.ts
vendored
1
packages/global.d.ts
vendored
@ -4,6 +4,7 @@ declare var __JSDOM__: boolean
|
|||||||
declare var __BROWSER__: boolean
|
declare var __BROWSER__: boolean
|
||||||
declare var __RUNTIME_COMPILE__: boolean
|
declare var __RUNTIME_COMPILE__: boolean
|
||||||
declare var __COMMIT__: string
|
declare var __COMMIT__: string
|
||||||
|
declare var __VERSION__: string
|
||||||
|
|
||||||
// Feature flags
|
// Feature flags
|
||||||
declare var __FEATURE_OPTIONS__: boolean
|
declare var __FEATURE_OPTIONS__: boolean
|
||||||
|
6
packages/runtime-core/__tests__/version.spec.ts
Normal file
6
packages/runtime-core/__tests__/version.spec.ts
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
import { version } from '../src'
|
||||||
|
import lernaJson from '../../../lerna.json'
|
||||||
|
|
||||||
|
test('version', () => {
|
||||||
|
expect(version).toBe(lernaJson.version)
|
||||||
|
})
|
@ -84,3 +84,5 @@ export {
|
|||||||
DirectiveArguments
|
DirectiveArguments
|
||||||
} from './directives'
|
} from './directives'
|
||||||
export { SuspenseBoundary } from './suspense'
|
export { SuspenseBoundary } from './suspense'
|
||||||
|
|
||||||
|
export const version = __VERSION__
|
||||||
|
@ -4,6 +4,7 @@ import ts from 'rollup-plugin-typescript2'
|
|||||||
import replace from 'rollup-plugin-replace'
|
import replace from 'rollup-plugin-replace'
|
||||||
import alias from 'rollup-plugin-alias'
|
import alias from 'rollup-plugin-alias'
|
||||||
import json from 'rollup-plugin-json'
|
import json from 'rollup-plugin-json'
|
||||||
|
import lernaJson from './lerna.json'
|
||||||
|
|
||||||
if (!process.env.TARGET) {
|
if (!process.env.TARGET) {
|
||||||
throw new Error('TARGET package must be specified via --environment flag.')
|
throw new Error('TARGET package must be specified via --environment flag.')
|
||||||
@ -143,6 +144,7 @@ function createReplacePlugin(
|
|||||||
) {
|
) {
|
||||||
return replace({
|
return replace({
|
||||||
__COMMIT__: `"${process.env.COMMIT}"`,
|
__COMMIT__: `"${process.env.COMMIT}"`,
|
||||||
|
__VERSION__: `"${lernaJson.version}"`,
|
||||||
__DEV__: isBundlerESMBuild
|
__DEV__: isBundlerESMBuild
|
||||||
? // preserve to be handled by bundlers
|
? // preserve to be handled by bundlers
|
||||||
`process.env.NODE_ENV !== 'production'`
|
`process.env.NODE_ENV !== 'production'`
|
||||||
|
Loading…
Reference in New Issue
Block a user