├── .editorconfig ├── .github ├── ISSUE_TEMPLATE │ └── bug-report.md └── workflows │ ├── main.yml │ ├── publish.yml │ └── publishBeta.yml ├── .gitignore ├── .npmrc ├── CONTRIBUTING.md ├── README.md ├── babel.config.js ├── doc ├── API.md ├── README-zh.md └── Usage.md ├── lib └── index.js ├── package.json ├── rollup.config.js ├── src ├── index.js ├── plugins │ ├── constants │ │ ├── globals.js │ │ └── preservedNames.js │ ├── parse-with-statement.js │ └── utils │ │ └── shouldPrependVM.js ├── renderCompiler.js ├── templateCompiler.js └── utils │ ├── merge.js │ └── string.js ├── test ├── compileRender.spec.js ├── compileTemplate.spec.js ├── options.spec.js └── utils │ └── function.js └── yarn.lock /.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | end_of_line = lf 7 | indent_size = 2 8 | indent_style = space 9 | insert_final_newline = true 10 | trim_trailing_whitespace = true 11 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug-report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: "[Bug] Please describe your issue" 5 | labels: need triage 6 | assignees: '' 7 | 8 | --- 9 | 10 | - [ ] Would you like to work on a fix? 11 | 12 | ## Current behavior 13 | Fork 14 | 15 | 1. 16 | Nuxt.js Online Example Project 17 | 18 | 19 | 2. 20 | Vue-CLI Online Example Project 21 | 22 | 23 | to re-produce your error. 24 | 25 | And Paste Link to here: Your New Re-Production project Link 26 | 27 | This will help us fix it ASAP. 28 | 29 | ``` js 30 | // or write your error code here 31 | ``` 32 | 33 | ## Expected behavior 34 | 35 | 36 | ## Extra 37 | - Usage: Vue-CLI || Nuxt.js || Webpack || ... 38 | - Node.js Version: ? 39 | - Babel Version: ? 40 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | # This is a basic workflow to help you get started with Actions 2 | 3 | name: CI 4 | 5 | # Controls when the workflow will run 6 | on: 7 | # Triggers the workflow on push or pull request events but only for the branches 8 | push: 9 | branches: 10 | - '**' 11 | pull_request: 12 | branches: [ main ] 13 | 14 | # A workflow run is made up of one or more jobs that can run sequentially or in parallel 15 | jobs: 16 | # This workflow contains a single job called "test" 17 | test: 18 | # The type of runner that the job will run on 19 | runs-on: ubuntu-latest 20 | 21 | # Steps represent a sequence of tasks that will be executed as part of the job 22 | steps: 23 | # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it 24 | - uses: actions/checkout@v2 25 | - name: Set node version to 14 26 | uses: actions/setup-node@v2 27 | with: 28 | node-version: 14 29 | cache: 'yarn' 30 | - run: yarn install 31 | - run: yarn test 32 | -------------------------------------------------------------------------------- /.github/workflows/publish.yml: -------------------------------------------------------------------------------- 1 | name: 'PublishLatestVersion' 2 | 3 | on: 4 | push: 5 | tags: 6 | - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 7 | 8 | jobs: 9 | publish: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: actions/checkout@v1 13 | - uses: actions/setup-node@v1 14 | with: 15 | node-version: 14 16 | - run: yarn install --frozen-lockfile 17 | - run: yarn test 18 | - uses: JS-DevTools/npm-publish@v1 19 | with: 20 | token: ${{ secrets.NPM_TOKEN }} 21 | -------------------------------------------------------------------------------- /.github/workflows/publishBeta.yml: -------------------------------------------------------------------------------- 1 | name: 'PublishBetaVersion' 2 | on: 3 | push: 4 | tags: 5 | - 'beta-v*' # Push events to matching beta-v*, i.e. beta-v1.0, beta-v20.15.10 6 | 7 | jobs: 8 | publish: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/checkout@v1 12 | - uses: actions/setup-node@v1 13 | with: 14 | node-version: 14 15 | - run: yarn install --frozen-lockfile 16 | - run: yarn test 17 | - uses: JS-DevTools/npm-publish@v1 18 | with: 19 | token: ${{ secrets.NPM_TOKEN }} 20 | tag: 'beta' 21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | .idea 4 | yarn-error.log 5 | .yarn 6 | -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | registry=https://registry.npmjs.org 2 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | > Feel free to ask maintainers anything by [issue](https://github.com/JuniorTour/vue-template-babel-compiler/issues/new/choose) 2 | 3 | - [Example: Fix issue #13 and Make a Pull Request](#example-fix-issue13-and-make-a-pull-request) 4 | * [1. Find or create an issue](#1-find-or-create-an-issue) 5 | * [2. Reproduce the issue](#2-reproduce-the-issue) 6 | * [3. Locate error](#3-locate-error) 7 | + [A. Chrome DevTool will start to listening](#a-chrome-devtool-will-start-to-listening) 8 | + [B. Open Chrome DevTool for Node.js form any chrome tab](#b-open-chrome-devtool-for-nodejs-form-any-chrome-tab) 9 | + [C. Use Chrome DevTool to debug this lib as usual](#c-use-chrome-devtool-to-debug-this-lib-as-usual) 10 | * [4. Find a solution](#4-find-a-solution) 11 | * [5. Fork this Repo and setup](#5-fork-this-repo-and-setup) 12 | * [6. Add test case and run `yarn test`](#6-add-test-case-and-run-yarn-test) 13 | + [Write test case is Easy!](#write-test-case-is-easy) 14 | - [A. find a `*.spec.js` file to write](#a-find-a-specjs-file-to-write) 15 | - [B. Copy the reproduce code snippet above with `jest API`](#b-copy-the-reproduce-code-snippet-above-with-jest-api) 16 | - [C. Run `yarn test`](#c-run-yarn-test) 17 | * [7. Git commit and Push](#7-git-commit-and-push) 18 | 19 | 20 | # Example: Fix [issue#13](https://github.com/JuniorTour/vue-template-babel-compiler/commit/b5e8bd13e603bfb1b9dd87f1222b831fd2a68c49) and Make a Pull Request 21 | 22 | ## 1. Find or create an issue 23 | For example, we want to fix [issue #13](https://github.com/JuniorTour/vue-template-babel-compiler/issues/13), 24 | 25 | Reporter said there will be an error: 26 | 27 | `[Vue warn]: Error in render: "ReferenceError: _defineProperty is not defined"` 28 | 29 | when write: 30 | ``` js 31 | 35 | ``` 36 | 37 | The first thing we need to do is identify and reproduce the issue. 38 | 39 | ## 2. Reproduce the issue 40 | We can setup the Example Projects to reproduce the issue: 41 | - [Example Project for Vue-CLI](https://github.com/JuniorTour/vue-template-babel-compiler-vue-cli-project) 42 | - [Example Project for nuxt.js](https://github.com/JuniorTour/vue-template-babel-compiler-nuxt-project) 43 | 44 | Follow its README to setup, usually we need: 45 | ``` shell script 46 | git clone https://github.com/JuniorTour/vue-template-babel-compiler-vue-cli-project.git 47 | 48 | cd ./vue-template-babel-compiler-vue-cli-project 49 | 50 | yarn install 51 | 52 | yarn server // or yarn dev 53 | ``` 54 | 55 | Then we can write the same code snippet in example project `.vue` files to reproduce error: 56 | ``` html 57 | 61 | 62 | 72 | ``` 73 | 74 | If we can't reproduce, talk with the reporter and maintainer in the issue page. 75 | 76 | 77 | ## 3. Locate error 78 | This lib is used in Node.js environment. 79 | 80 | So when we reproduce the error, we can use `node --inspect-brk file.js --runInBand` to debug the whole process of code execution. 81 | 82 | There are also [built-in npm script in the Example Projects](https://github.com/JuniorTour/vue-template-babel-compiler-vue-cli-project/blob/main/package.json#L9): 83 | ```shell script 84 | yarn debugDev 85 | ``` 86 | 87 | After execute `node --inspect-brk`, 88 | 89 | ### A. Chrome DevTool will start to listening 90 | ![image](https://user-images.githubusercontent.com/14243906/144751411-cc1a122c-91fe-46ad-a3f1-263d12c197d4.png) 91 | 92 | ### B. Open Chrome DevTool for Node.js form any chrome tab 93 | 94 | ![image](https://user-images.githubusercontent.com/14243906/144751826-4ed1b48d-2c92-4db3-ad64-1b65be406bc3.png) 95 | 96 | 97 | ### C. Use Chrome DevTool to debug this lib as usual 98 | ![image](https://user-images.githubusercontent.com/14243906/144751318-7f4149ba-c74a-42d1-97e2-d9b8deabfbeb.png) 99 | 100 | This npm package usually located in: 101 | `vue-template-babel-compiler-nuxt-project\node_modules\vue-template-babel-compiler\lib\index.js` 102 | 103 | > Hotkey: (ctrl || command) + P can be used to search file in DevTool: 104 | 105 | ![image](https://user-images.githubusercontent.com/14243906/144751635-ac73ff2c-2717-49ce-80f8-3606c768d2f9.png) 106 | 107 | 108 | ## 4. Find a solution 109 | After debug, I found the error above was caused by `computed property` in SFC `