Skip to content

Commit

Permalink
build: use rolldown + oxc
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Sep 28, 2024
1 parent 29de6f8 commit 825948e
Show file tree
Hide file tree
Showing 14 changed files with 1,285 additions and 399 deletions.
1 change: 1 addition & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ export default tseslint.config(
files: [
'eslint.config.js',
'rollup*.config.js',
'rolldown*.config.js',
'scripts/**',
'./*.{js,ts}',
'packages/*/*.js',
Expand Down
10 changes: 8 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
"scripts": {
"dev": "node scripts/dev.js",
"build": "node scripts/build.js",
"build-dts": "tsc -p tsconfig.build.json --noCheck && rollup -c rollup.dts.config.js",
"build-rollup": "node scripts/build-with-rollup.js",
"build-dts": "node scripts/build-types.js",
"build-dts-tsc": "tsc -p tsconfig.build.json --noCheck && rollup -c rollup.dts.config.js",
"clean": "rimraf --glob packages/*/dist temp .eslintcache",
"size": "run-s \"size-*\" && node scripts/usage-size.js",
"size-global": "node scripts/build.js vue runtime-dom -f global -p --size",
Expand Down Expand Up @@ -59,8 +61,8 @@
"node": ">=18.12.0"
},
"devDependencies": {
"@babel/parser": "catalog:",
"@babel/types": "catalog:",
"@rolldown/plugin-node-polyfills": "^1.0.0",
"@rollup/plugin-alias": "^5.1.1",
"@rollup/plugin-commonjs": "^26.0.3",
"@rollup/plugin-json": "^6.1.0",
Expand All @@ -81,19 +83,23 @@
"eslint-plugin-import-x": "^4.2.1",
"eslint-plugin-vitest": "^0.5.4",
"estree-walker": "catalog:",
"fast-glob": "^3.3.2",
"jsdom": "^25.0.0",
"lint-staged": "^15.2.10",
"lodash": "^4.17.21",
"magic-string": "^0.30.11",
"markdown-table": "^3.0.3",
"marked": "13.0.3",
"npm-run-all2": "^6.2.3",
"oxc-parser": "^0.30.1",
"oxc-transform": "^0.30.1",
"picocolors": "^1.1.0",
"prettier": "^3.3.3",
"pretty-bytes": "^6.1.1",
"pug": "^3.0.3",
"puppeteer": "~23.3.0",
"rimraf": "^6.0.1",
"rolldown": "nightly",
"rollup": "^4.22.4",
"rollup-plugin-dts": "^6.1.1",
"rollup-plugin-esbuild": "^6.1.1",
Expand Down
8 changes: 4 additions & 4 deletions packages/compiler-sfc/__tests__/parse.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ font-weight: bold;

const consumer = new SourceMapConsumer(script!.map!)
consumer.eachMapping(mapping => {
expect(mapping.originalLine - mapping.generatedLine).toBe(padding)
expect(mapping.originalLine! - mapping.generatedLine).toBe(padding)
})
})

Expand All @@ -100,8 +100,8 @@ font-weight: bold;

const consumer = new SourceMapConsumer(template.map!)
consumer.eachMapping(mapping => {
expect(mapping.originalLine - mapping.generatedLine).toBe(padding)
expect(mapping.originalColumn - mapping.generatedColumn).toBe(2)
expect(mapping.originalLine! - mapping.generatedLine).toBe(padding)
expect(mapping.originalColumn! - mapping.generatedColumn).toBe(2)
})
})

Expand All @@ -115,7 +115,7 @@ font-weight: bold;

const consumer = new SourceMapConsumer(custom!.map!)
consumer.eachMapping(mapping => {
expect(mapping.originalLine - mapping.generatedLine).toBe(padding)
expect(mapping.originalLine! - mapping.generatedLine).toBe(padding)
})
})
})
Expand Down
4 changes: 2 additions & 2 deletions packages/compiler-sfc/src/compileTemplate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ function mapLines(oldMap: RawSourceMap, newMap: RawSourceMap): RawSourceMap {

const origPosInOldMap = oldMapConsumer.originalPositionFor({
line: m.originalLine,
column: m.originalColumn,
column: m.originalColumn!,
})

if (origPosInOldMap.source == null) {
Expand All @@ -305,7 +305,7 @@ function mapLines(oldMap: RawSourceMap, newMap: RawSourceMap): RawSourceMap {
line: origPosInOldMap.line, // map line
// use current column, since the oldMap produced by @vue/compiler-sfc
// does not
column: m.originalColumn,
column: m.originalColumn!,
},
source: origPosInOldMap.source,
name: origPosInOldMap.name,
Expand Down
19 changes: 12 additions & 7 deletions packages/compiler-sfc/src/script/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@ export class ScriptCompileContext {
scriptAst: Program | null
scriptSetupAst: Program | null

source: string = this.descriptor.source
filename: string = this.descriptor.filename
s: MagicString = new MagicString(this.source)
startOffset: number | undefined =
this.descriptor.scriptSetup?.loc.start.offset
endOffset: number | undefined = this.descriptor.scriptSetup?.loc.end.offset
source: string
filename: string
s: MagicString
startOffset: number | undefined
endOffset: number | undefined

// import / type analysis
scope?: TypeScope
Expand Down Expand Up @@ -87,6 +86,12 @@ export class ScriptCompileContext {
const scriptLang = script && script.lang
const scriptSetupLang = scriptSetup && scriptSetup.lang

this.source = descriptor.source
this.filename = descriptor.filename
this.s = new MagicString(descriptor.source)
this.startOffset = descriptor.scriptSetup?.loc.start.offset
this.endOffset = descriptor.scriptSetup?.loc.end.offset

this.isJS =
scriptLang === 'js' ||
scriptLang === 'jsx' ||
Expand All @@ -99,7 +104,7 @@ export class ScriptCompileContext {
scriptSetupLang === 'tsx'

const customElement = options.customElement
const filename = this.descriptor.filename
const filename = descriptor.filename
if (customElement) {
this.isCE =
typeof customElement === 'boolean'
Expand Down
5 changes: 3 additions & 2 deletions packages/runtime-dom/src/apiCustomElement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ export class VueElement
/**
* @internal
*/
_nonce: string | undefined = this._def.nonce
_nonce: string | undefined

/**
* @internal
Expand Down Expand Up @@ -253,6 +253,7 @@ export class VueElement
private _createApp: CreateAppFunction<Element> = createApp,
) {
super()
this._nonce = _def.nonce
if (this.shadowRoot && _createApp !== createApp) {
this._root = this.shadowRoot
} else {
Expand Down Expand Up @@ -313,7 +314,7 @@ export class VueElement
}
}

private _setParent(parent = this._parent) {
private _setParent(parent: VueElement | undefined = this._parent): void {
if (parent) {
this._instance!.parent = parent._instance
this._instance!.provides = parent._instance!.provides
Expand Down
Loading

0 comments on commit 825948e

Please sign in to comment.