├── .circleci └── config.yml ├── .commitlintrc.json ├── .editorconfig ├── .eslintrc.json ├── .flowconfig ├── .github ├── CONTRIBUTING.md ├── HACKING.md └── WORKFLOW.md ├── .gitignore ├── .huskyrc.json ├── .prettierrc.json ├── .travis.yml ├── CHANGELOG.md ├── LICENSE.md ├── README.md ├── babel.config.js ├── examples ├── node_wasm │ ├── Cargo.toml │ ├── package.json │ ├── rollup.config.js │ └── src │ │ ├── index.js │ │ └── lib.rs └── stencil │ ├── .editorconfig │ ├── LICENSE │ ├── package.json │ ├── readme.md │ ├── src │ ├── components.d.ts │ ├── components │ │ └── my-component │ │ │ ├── Cargo.toml │ │ │ ├── lib.rs │ │ │ ├── my-component.css │ │ │ ├── my-component.spec.ts │ │ │ └── my-component.tsx │ ├── index.html │ └── wasm.d.ts │ ├── stencil.config.ts │ └── tsconfig.json ├── flow-typed └── rollupPluginRustDef.js ├── index.d.ts ├── jest.config.js ├── jest.setup.js ├── package-lock.json ├── package.json ├── rollup.config.js ├── script └── resolveModule.js ├── src ├── main.js ├── options.js └── util.js └── test ├── export.spec.js ├── fail.spec.js ├── fixtures ├── empty.js ├── hook_function │ ├── Cargo.toml │ ├── index.js │ └── lib.rs └── single_function │ ├── Cargo.toml │ ├── index.js │ └── lib.rs ├── import.spec.js └── util ├── index.js └── require.js /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | 3 | rustup_nightly: &rustup_nightly 4 | run: 5 | name: Install Cargo and Rust compiler 6 | command: | 7 | echo 'export PATH="$HOME/.cargo/bin:$PATH"' >> $BASH_ENV 8 | curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain 1.28.0 9 | source $BASH_ENV 10 | rustup target add wasm32-unknown-unknown 11 | 12 | smoke_tests: &smoke_tests 13 | steps: 14 | - checkout 15 | - restore_cache: 16 | key: dependency-cache-{{ checksum "package-lock.json" }} 17 | - <<: *rustup_nightly 18 | - run: 19 | name: NPM Rebuild 20 | command: npm install --quiet 21 | - run: 22 | name: Build & Bundle project 23 | command: npm run build 24 | - run: 25 | name: NPM Rebuild smoke-test 26 | command: | 27 | cd examples/${EXAMPLE_PROJECT} 28 | npm install 29 | - run: 30 | name: Run smoke tests 31 | command: | 32 | cd examples/${EXAMPLE_PROJECT} 33 | npm run build 34 | 35 | unit_tests: &unit_tests 36 | steps: 37 | - checkout 38 | - restore_cache: 39 | key: dependency-cache-{{ checksum "package-lock.json" }} 40 | - <<: *rustup_nightly 41 | - run: 42 | name: NPM Rebuild 43 | command: npm install --quiet 44 | - run: 45 | name: Run unit tests. 46 | command: npm run ci:test 47 | 48 | canary_tests: &canary_tests 49 | steps: 50 | - checkout 51 | - restore_cache: 52 | key: dependency-cache-{{ checksum "package-lock.json" }} 53 | - run: 54 | name: NPM Rebuild 55 | command: npm install --quiet 56 | - run: 57 | name: Install Rollup Canary 58 | command: npm i --no-save rollup@next --verbose 59 | - run: 60 | name: Run unit tests. 61 | command: if [[ $(compver --name rollup --gte next --lt latest) < 1 ]] ; then printf "Next is older than Latest - Skipping Canary Suite"; else npm run ci:test ; fi 62 | 63 | jobs: 64 | #region PREPARATION 65 | dependency_cache: 66 | docker: 67 | - image: circleci/node:latest 68 | steps: 69 | - checkout 70 | - restore_cache: 71 | key: dependency-cache-{{ checksum "package-lock.json" }} 72 | - run: 73 | name: Install Dependencies 74 | command: npm install --quiet 75 | - save_cache: 76 | key: dependency-cache-{{ checksum "package-lock.json" }} 77 | paths: 78 | - ./node_modules 79 | analysis: 80 | docker: 81 | - image: circleci/node:latest 82 | steps: 83 | - checkout 84 | - restore_cache: 85 | key: dependency-cache-{{ checksum "package-lock.json" }} 86 | - run: 87 | name: NPM Rebuild 88 | command: npm install --quiet 89 | - run: 90 | name: Run linting. 91 | command: npm run ci:lint 92 | - run: 93 | name: Run NSP Security Check. 94 | command: npm audit --quiet 95 | - run: 96 | name: Validate Commit Messages 97 | command: | 98 | if [[ -z $CIRCLE_TAG ]]; then 99 | npm run ci:lint:commits 100 | fi 101 | #endregion 102 | 103 | #region CROSS-BUILD 104 | node8-latest: 105 | docker: 106 | - image: circleci/node:8 107 | steps: 108 | - checkout 109 | - restore_cache: 110 | key: dependency-cache-{{ checksum "package-lock.json" }} 111 | - <<: *rustup_nightly 112 | - run: 113 | name: NPM Rebuild 114 | command: npm install --quiet 115 | - run: 116 | name: Run unit tests. 117 | command: | 118 | npm run ci:coverage 119 | - run: 120 | name: Submit coverage data to codecov. 121 | command: bash <(curl -s https://codecov.io/bash) 122 | when: on_success 123 | # node6-latest: 124 | # docker: 125 | # - image: circleci/node:6 126 | # <<: *unit_tests 127 | node10-latest: 128 | docker: 129 | - image: circleci/node:10 130 | <<: *unit_tests 131 | node8-canary: 132 | docker: 133 | - image: circleci/node:8 134 | <<: *canary_tests 135 | #endregion 136 | 137 | #region TEST BY EXAMPLES 138 | smoke-stencil: 139 | docker: 140 | - image: circleci/node:8 141 | environment: 142 | - EXAMPLE_PROJECT: stencil 143 | <<: *smoke_tests 144 | smoke-node-wasm: 145 | docker: 146 | - image: circleci/node:8 147 | environment: 148 | - EXAMPLE_PROJECT: node_wasm 149 | <<: *smoke_tests 150 | #endregion 151 | 152 | #region RELEASE VERSION 153 | draft: 154 | docker: 155 | - image: circleci/node:latest 156 | steps: 157 | - checkout 158 | - restore_cache: 159 | key: dependency-cache-{{ checksum "package-lock.json" }} 160 | - run: 161 | name: NPM Rebuild 162 | command: npm install --quiet 163 | - run: 164 | name: Validate Commit Messages 165 | command: npm run release:validate 166 | - run: 167 | name: Draft Releases to Github 168 | command: npm run ci:release 169 | publish: 170 | docker: 171 | - image: circleci/node:latest 172 | steps: 173 | - checkout 174 | - run: 175 | name: set npm TOKEN 176 | command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc 177 | - restore_cache: 178 | key: dependency-cache-{{ checksum "package-lock.json" }} 179 | - run: 180 | name: NPM Rebuild 181 | command: npm install --quiet 182 | - run: 183 | name: Publish to NPM 184 | command: npm publish --verbose 185 | #endregion 186 | 187 | workflows: 188 | version: 2 189 | build and publish on tagging: 190 | jobs: 191 | #region PREPARATION 192 | - dependency_cache: 193 | filters: 194 | tags: 195 | only: /.*/ 196 | - analysis: 197 | requires: 198 | - dependency_cache 199 | filters: 200 | tags: 201 | only: /.*/ 202 | #endregion 203 | 204 | #region CROSS-BUILD 205 | # - node6-latest: 206 | # requires: 207 | # - dependency_cache 208 | # filters: 209 | # tags: 210 | # only: /.*/ 211 | - node8-latest: 212 | requires: 213 | - analysis 214 | # - node6-latest 215 | filters: 216 | tags: 217 | only: /.*/ 218 | - node10-latest: 219 | requires: 220 | - analysis 221 | # - node6-latest 222 | filters: 223 | tags: 224 | only: /.*/ 225 | # rollup@next NOT YET PLANNED 226 | # - node8-canary: 227 | # requires: 228 | # - analysis 229 | # - node6-latest 230 | # filters: 231 | # tags: 232 | # only: /.*/ 233 | # branches: 234 | # only: 235 | # - master 236 | # - /rc.*/ 237 | #endregion 238 | 239 | #region TEST BY EXAMPLES 240 | - smoke-stencil: 241 | requires: 242 | - node8-latest 243 | filters: 244 | tags: 245 | only: /.*/ 246 | - smoke-node-wasm: 247 | requires: 248 | - node8-latest 249 | filters: 250 | tags: 251 | only: /.*/ 252 | #endregion 253 | 254 | #region RELEASE VERSION 255 | - draft: 256 | requires: 257 | # - smoke-stencil 258 | - smoke-node-wasm 259 | filters: 260 | tags: 261 | only: /^v\d+[.]\d+[.]\d+$/ 262 | branches: 263 | ignore: /.*/ 264 | - check github Releases!: 265 | type: approval 266 | requires: 267 | - draft 268 | filters: 269 | tags: 270 | only: /^v\d+[.]\d+[.]\d+$/ 271 | - publish: 272 | requires: 273 | - check github Releases! 274 | filters: 275 | tags: 276 | only: /^v\d+[.]\d+[.]\d+$/ 277 | #endregion 278 | -------------------------------------------------------------------------------- /.commitlintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": ["@commitlint/config-conventional"], 3 | 4 | "rules": { 5 | "body-leading-blank": [1, "always"], 6 | "footer-leading-blank": [1, "always"], 7 | "header-max-length": [2, "always", 72], 8 | "scope-case": [2, "always", "lower-case"], 9 | "subject-case": [ 10 | 2, 11 | "never", 12 | ["sentence-case", "start-case", "pascal-case", "upper-case"] 13 | ], 14 | "subject-empty": [2, "never"], 15 | "subject-full-stop": [2, "never", "."], 16 | "type-case": [2, "always", "lower-case"], 17 | "type-empty": [2, "never"], 18 | "type-enum": [ 19 | 2, 20 | "always", 21 | [ 22 | "build", 23 | "chore", 24 | "ci", 25 | "docs", 26 | "feat", 27 | "fix", 28 | "perf", 29 | "refactor", 30 | "revert", 31 | "style", 32 | "test" 33 | ] 34 | ] 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*.config.js] 4 | indent_style = tab 5 | indent_size = 4 6 | insert_final_newline = false 7 | 8 | [{src/**.js, test/**.js}] 9 | indent_style = space 10 | indent_size = 2 11 | insert_final_newline = true 12 | 13 | [*{rc, json, config}] 14 | indent_style = tab 15 | indent_size = 4 16 | insert_final_newline = false 17 | 18 | [*.md] 19 | indent_size = 2 -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "parser": "babel-eslint", 4 | "plugins": [ 5 | "import", 6 | "promise", 7 | "node", 8 | "prettier", 9 | "babel", 10 | "flowtype", 11 | "jest" 12 | ], 13 | "extends": [ 14 | "eslint:recommended", 15 | "plugin:prettier/recommended", 16 | "plugin:flowtype/recommended", 17 | "prettier/flowtype", 18 | "plugin:jest/recommended" 19 | ], 20 | "env": { 21 | "node": true, 22 | "es6": true, 23 | "jest/globals": true 24 | }, 25 | "rules": { 26 | "no-console": "off" 27 | }, 28 | "globals": { 29 | "WebAssembly": true 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /.flowconfig: -------------------------------------------------------------------------------- 1 | [lints] 2 | all=warn 3 | 4 | [ignore] 5 | /dist/.* 6 | /out/.* 7 | 8 | [libs] 9 | flow-typed -------------------------------------------------------------------------------- /.github/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing in rollup-plugin-rust 2 | 3 | We'd always love contributions to further improve the rollup! 4 | Here are the guidelines we'd like you to follow: 5 | 6 | - [Questions and Problems](#question) 7 | - [Issues and Bugs](#issue) 8 | - [Feature Requests](#feature) 9 | - [Pull Request Submission Guidelines](#submit-pr) 10 | - [Commit Message Conventions](#commit) 11 | 12 | ### Got a Question or Problem? 13 | 14 | Please submit support requests and questions to StackOverflow using the tag [[rollup]](http://stackoverflow.com/tags/rollup). 15 | StackOverflow is better suited for this kind of support. 16 | The issue tracker is for bug reports and feature discussions. 17 | 18 | ### Found an Issue or Bug? 19 | 20 | Before you submit an issue, please search the issue tracker, maybe an issue for your problem already exists and the discussion might inform you of workarounds readily available. 21 | 22 | We want to fix all the issues as soon as possible, but before fixing a bug we need to reproduce and confirm it. In order to reproduce bugs, we ask that you to provide a minimal reproduction scenario (github repo or failing test case). Having a live, reproducible scenario gives us a wealth of important information without going back & forth to you with additional questions like: 23 | 24 | - version of rollup used 25 | - version of the loader / plugin you are creating a bug report for 26 | - the use-case that fails 27 | 28 | A minimal reproduce scenario allows us to quickly confirm a bug (or point out config problems) as well as confirm that we are fixing the right problem. 29 | 30 | We will be insisting on a minimal reproduce scenario in order to save maintainers time and ultimately be able to fix more bugs. We understand that sometimes it might be hard to extract essentials bits of code from a larger code-base but we really need to isolate the problem before we can fix it. 31 | 32 | Unfortunately, we are not able to investigate / fix bugs without a minimal reproduction, so if we don't hear back from you we are going to close an issue that doesn't have enough info to be reproduced. 33 | 34 | ### Feature Requests? 35 | 36 | You can *request* a new feature by creating an issue on Github. 37 | 38 | If you would like to *implement* a new feature, please submit an issue with a proposal for your work `first`, to be sure that particular makes sense for the project. 39 | 40 | ### Pull Request Submission Guidelines 41 | 42 | Before you submit your Pull Request (PR) consider the following guidelines: 43 | 44 | - Search Github for an open or closed PR that relates to your submission. You don't want to duplicate effort. 45 | - Commit your changes using a descriptive commit message that follows our [commit message conventions](#commit). Adherence to these conventions is necessary because release notes are automatically generated from these messages. 46 | - Fill out our `Pull Request Template`. Your pull request will not be considered if it is ignored. 47 | - Please sign the `Contributor License Agreement (CLA)` when a pull request is opened. We cannot accept your pull request without this. Make sure you sign with the primary email address associated with your local / github account. 48 | 49 | ### rollup Contrib Commit Conventions 50 | 51 | Each commit message consists of a **header**, a **body** and a **footer**. The header has a special 52 | format that includes a **type**, a **scope** and a **subject**: 53 | 54 | ```xml 55 | (): 56 | 57 | 58 | 59 |