Skip to content

Commit

Permalink
Merge branch 'main' into feat-effect
Browse files Browse the repository at this point in the history
  • Loading branch information
Alfred-Skyblue authored Oct 17, 2023
2 parents df77be4 + 0a8be45 commit a5446a3
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 101 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"@rollup/plugin-replace": "^5.0.2",
"@rollup/plugin-terser": "^0.4.3",
"@types/hash-sum": "^1.0.0",
"@types/node": "^16.18.52",
"@types/node": "^18.18.5",
"@typescript-eslint/parser": "^6.7.2",
"@vitest/coverage-istanbul": "^0.34.4",
"@vue/consolidate": "0.17.3",
Expand All @@ -84,7 +84,7 @@
"lodash": "^4.17.21",
"magic-string": "^0.30.3",
"markdown-table": "^3.0.3",
"marked": "^4.3.0",
"marked": "^9.1.1",
"minimist": "^1.2.8",
"npm-run-all": "^4.1.5",
"prettier": "^3.0.3",
Expand Down
13 changes: 10 additions & 3 deletions packages/runtime-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,13 @@ export {
defineSlots,
defineModel,
withDefaults,
useModel,
// internal
useModel
} from './apiSetupHelpers'

/**
* @internal
*/
export {
mergeDefaults,
mergeModels,
createPropsRestProxy,
Expand Down Expand Up @@ -111,7 +116,9 @@ export { useSSRContext, ssrContextKey } from './helpers/useSsrContext'

export { createRenderer, createHydrationRenderer } from './renderer'
export { queuePostFlushCb } from './scheduler'
export { warn, assertNumber } from './warning'
export { warn } from './warning'
/** @internal */
export { assertNumber } from './warning'
export {
handleError,
callWithErrorHandling,
Expand Down
6 changes: 3 additions & 3 deletions packages/vue/__tests__/e2e/markdown.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('e2e: markdown', () => {
await page().goto(baseUrl)
expect(await isVisible('#editor')).toBe(true)
expect(await value('textarea')).toBe('# hello')
expect(await html('#editor div')).toBe('<h1 id="hello">hello</h1>\n')
expect(await html('#editor div')).toBe('<h1>hello</h1>\n')

await page().type('textarea', '\n## foo\n\n- bar\n- baz')

Expand All @@ -23,8 +23,8 @@ describe('e2e: markdown', () => {

await expectByPolling(
() => html('#editor div'),
'<h1 id="hello">hello</h1>\n' +
'<h2 id="foo">foo</h2>\n' +
'<h1>hello</h1>\n' +
'<h2>foo</h2>\n' +
'<ul>\n<li>bar</li>\n<li>baz</li>\n</ul>\n'
)
}
Expand Down
44 changes: 22 additions & 22 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

76 changes: 6 additions & 70 deletions rollup.dts.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { parse } from '@babel/parser'
import { existsSync, readdirSync, readFileSync, writeFileSync } from 'fs'
import MagicString from 'magic-string'
import dts from 'rollup-plugin-dts'
import { walk } from 'estree-walker'

if (!existsSync('temp/packages')) {
console.warn(
Expand Down Expand Up @@ -41,12 +40,11 @@ export default targetPackages.map(pkg => {

/**
* Patch the dts generated by rollup-plugin-dts
* 1. remove exports marked as @internal
* 2. Convert all types to inline exports
* 1. Convert all types to inline exports
* and remove them from the big export {} declaration
* otherwise it gets weird in vitepress `defineComponent` call with
* "the inferred type cannot be named without a reference"
* 3. Append custom augmentations (jsx, macros)
* 2. Append custom augmentations (jsx, macros)
* @returns {import('rollup').Plugin}
*/
function patchTypes(pkg) {
Expand All @@ -73,64 +71,12 @@ function patchTypes(pkg) {
return
}
shouldRemoveExport.add(name)
if (!removeInternal(parentDecl || node)) {
if (isExported.has(name)) {
// @ts-ignore
s.prependLeft((parentDecl || node).start, `export `)
}
// traverse further for internal properties
if (
node.type === 'TSInterfaceDeclaration' ||
node.type === 'ClassDeclaration'
) {
node.body.body.forEach(removeInternal)
} else if (node.type === 'TSTypeAliasDeclaration') {
// @ts-ignore
walk(node.typeAnnotation, {
enter(node) {
// @ts-ignore
if (removeInternal(node)) this.skip()
}
})
}
if (isExported.has(name)) {
// @ts-ignore
s.prependLeft((parentDecl || node).start, `export `)
}
}

/**
* @param {import('@babel/types').Node} node
* @returns {boolean}
*/
function removeInternal(node) {
if (
node.leadingComments &&
node.leadingComments.some(c => {
return c.type === 'CommentBlock' && /@internal\b/.test(c.value)
})
) {
/** @type {any} */
const n = node
let id
if (n.id && n.id.type === 'Identifier') {
id = n.id.name
} else if (n.key && n.key.type === 'Identifier') {
id = n.key.name
}
if (id) {
s.overwrite(
// @ts-ignore
node.leadingComments[0].start,
node.end,
`/* removed internal: ${id} */`
)
} else {
// @ts-ignore
s.remove(node.leadingComments[0].start, node.end)
}
return true
}
return false
}

const isExported = new Set()
const shouldRemoveExport = new Set()

Expand All @@ -146,7 +92,7 @@ function patchTypes(pkg) {
}
}

// pass 1: remove internals + add exports
// pass 1: add exports
for (const node of ast.program.body) {
if (node.type === 'VariableDeclaration') {
processDeclaration(node.declarations[0], node)
Expand All @@ -167,10 +113,6 @@ function patchTypes(pkg) {
node.type === 'ClassDeclaration'
) {
processDeclaration(node)
} else if (removeInternal(node)) {
throw new Error(
`unhandled export type marked as @internal: ${node.type}`
)
}
}

Expand Down Expand Up @@ -213,12 +155,6 @@ function patchTypes(pkg) {
}
code = s.toString()

if (/@internal/.test(code)) {
throw new Error(
`unhandled @internal declarations detected in ${chunk.fileName}.`
)
}

// append pkg specific types
const additionalTypeDir = `packages/${pkg}/types`
if (existsSync(additionalTypeDir)) {
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"extends": "./tsconfig.json",
"compilerOptions": {
"declaration": true,
"emitDeclarationOnly": true
"emitDeclarationOnly": true,
"stripInternal": true
},
"exclude": [
"packages/*/__tests__",
Expand Down

0 comments on commit a5446a3

Please sign in to comment.