-
Notifications
You must be signed in to change notification settings - Fork 9
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
1 parent
b49006b
commit 45a1a87
Showing
11 changed files
with
163 additions
and
16 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
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,10 +1,14 @@ | ||
import {renderCompiler} from "./renderCompiler" | ||
import {extendTemplateCompiler} from "./templateCompiler" | ||
import parseWithStatementToVm from "./plugins/parse-with-statement"; | ||
|
||
// vue-es2015-compiler substitution: | ||
const transpile = renderCompiler | ||
|
||
// enhance vue-template-compiler with babel: | ||
extendTemplateCompiler(transpile) | ||
|
||
// babel prepend vm plugin: | ||
transpile.parseWithStatementToVmPlugin = parseWithStatementToVm | ||
|
||
module.exports = transpile |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const merge = require('deepmerge') | ||
|
||
export function mergeOptions(oldOptions, newOptions) { | ||
return merge(oldOptions, newOptions) | ||
} |
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,50 @@ | ||
import {mergeOptions} from "../src/utils/merge"; | ||
|
||
const parseWithStatementToVm = () => {} | ||
|
||
// #30 | ||
test('should merge options for babel', () => { | ||
const oldOptions = { | ||
filename: 'VueTemplateBabelCompiler', | ||
// not enable strict mode, in order to parse WithStatement | ||
sourceType: 'script', | ||
assumptions: { | ||
setComputedProperties: true, | ||
arrayLikeIsIterable: true, | ||
}, | ||
plugins: [ | ||
'@babel/plugin-transform-computed-properties', | ||
'@babel/plugin-proposal-nullish-coalescing-operator', | ||
'@babel/plugin-proposal-optional-chaining', | ||
'@babel/plugin-transform-block-scoping', | ||
'@babel/plugin-transform-destructuring', | ||
"@babel/plugin-transform-spread", | ||
["@babel/plugin-proposal-object-rest-spread", { loose: true, useBuiltIns: true }], | ||
'@babel/plugin-transform-arrow-functions', | ||
'@babel/plugin-transform-parameters', | ||
parseWithStatementToVm, | ||
], | ||
} | ||
|
||
const additionalOptions = { | ||
filename: 'newFilename', | ||
newProp: true, | ||
assumptions: { | ||
additional: 'additional' | ||
}, | ||
plugins: [ | ||
'newPlugin' | ||
] | ||
} | ||
|
||
const newOptions = mergeOptions( | ||
oldOptions, | ||
additionalOptions, | ||
) | ||
|
||
expect(newOptions.assumptions.additional).toMatch(additionalOptions.assumptions.additional) | ||
expect(newOptions.plugins.length).toEqual(oldOptions.plugins.length+1) | ||
expect(newOptions.plugins[9]).toEqual(oldOptions.plugins[9]) | ||
expect(newOptions.filename).toEqual(additionalOptions.filename) | ||
expect(newOptions.newProp).toEqual(additionalOptions.newProp) | ||
}) |
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