├── .editorconfig
├── .gitattributes
├── .gitignore
├── .prettierrc
├── .releaserc.json
├── LICENSE
├── README.md
├── babel.js
├── bili.config.ts
├── circle.yml
├── docs
├── README.md
├── configuration-file.md
├── index.html
├── installation.md
├── main.js
├── migration
│ └── v3-to-v4.md
├── plugins.md
└── recipes
│ ├── css.md
│ ├── env-variables.md
│ ├── javascript.md
│ ├── update-package-json.md
│ └── vue-component.md
├── jest.config.js
├── package.json
├── src
├── babel
│ └── preset.ts
├── cli.ts
├── config-loader.ts
├── index.ts
├── logger.ts
├── plugins
│ ├── babel.ts
│ ├── node-resolve.ts
│ └── progress.ts
├── polyfills.ts
├── resolve.ts
├── spinner.ts
├── types.ts
└── utils
│ ├── get-banner.ts
│ └── is-external.ts
├── test
├── __snapshots__
│ └── index.test.ts.snap
├── demo
│ └── index.js
├── fixtures
│ ├── async
│ │ └── index.js
│ ├── babel
│ │ ├── object-rest-spread
│ │ │ └── index.js
│ │ └── with-config
│ │ │ ├── .babelrc
│ │ │ └── index.js
│ ├── banner
│ │ └── default
│ │ │ ├── index.js
│ │ │ └── package.json
│ ├── buble
│ │ ├── async-dot-dot-dot.js
│ │ ├── async.js
│ │ ├── react-jsx.js
│ │ └── vue-jsx.js
│ ├── bundle-node-modules
│ │ ├── index.js
│ │ └── node_modules
│ │ │ └── pokemon.js
│ ├── custom-rollup-plugin
│ │ └── index.js
│ ├── custom-scoped-rollup-plugin
│ │ ├── index.js
│ │ └── replace
│ │ │ └── index.js
│ ├── default.js
│ ├── defaults
│ │ └── index.js
│ ├── exclude-file
│ │ ├── foo.js
│ │ └── index.js
│ ├── extend-options
│ │ ├── bar.js
│ │ └── foo.js
│ ├── format
│ │ └── index.js
│ ├── inline-certain-modules
│ │ ├── index.js
│ │ └── node_modules
│ │ │ ├── another-module
│ │ │ └── index.js
│ │ │ └── fake-module
│ │ │ └── index.js
│ ├── input
│ │ ├── empty
│ │ │ └── .gitkeep
│ │ └── index
│ │ │ └── src
│ │ │ └── index.js
│ ├── no-js-transform
│ │ └── index.js
│ ├── package.json
│ ├── prettier
│ │ ├── index.js
│ │ └── yarn.lock
│ ├── target
│ │ ├── browser
│ │ │ ├── foo-browser.js
│ │ │ ├── index.js
│ │ │ └── package.json
│ │ └── node
│ │ │ └── index.js
│ ├── typescript
│ │ └── index.ts
│ ├── uglify
│ │ └── index.js
│ ├── vue
│ │ └── component.vue
│ └── yarn.lock
└── index.test.ts
├── tsconfig.json
├── tsconfig.types.json
├── types.d.ts
└── yarn.lock
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | indent_style = space
5 | indent_size = 2
6 | end_of_line = lf
7 | charset = utf-8
8 | trim_trailing_whitespace = true
9 | insert_final_newline = true
10 |
11 | [*.md]
12 | trim_trailing_whitespace = false
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | * text=auto
2 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.log
2 | .DS_Store
3 | /node_modules
4 | /test/fixtures/node_modules
5 | .rpt2_cache
6 | /lib
7 | /dist
8 | /types
9 | /docs/api
10 | require-trace.trace
11 |
--------------------------------------------------------------------------------
/.prettierrc:
--------------------------------------------------------------------------------
1 | {
2 | "semi": false,
3 | "singleQuote": true,
4 | "bracketSpacing": true
5 | }
6 |
--------------------------------------------------------------------------------
/.releaserc.json:
--------------------------------------------------------------------------------
1 | {
2 | "branches": ["master"],
3 | "plugins": [
4 | [
5 | "@semantic-release/commit-analyzer",
6 | {
7 | "preset": "angular",
8 | "releaseRules": [
9 | { "type": "refactor", "release": "patch" },
10 | { "type": "style", "release": "patch" },
11 | { "scope": "no-release", "release": false }
12 | ]
13 | }
14 | ],
15 | "@semantic-release/release-notes-generator",
16 | "@semantic-release/npm",
17 | "@semantic-release/github"
18 | ]
19 | }
20 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) EGOIST <0x142857@gmail.com> (https://egoist.sh)
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Bili
2 |
3 |
4 |
5 | ## Features
6 |
7 | - 🚀 Fast, zero-config by default.
8 | - 📦 Using Rollup under the hood.
9 | - 🚗 Automatically transforms JS files using Buble/Babel/TypeScript.
10 | - 💅 Built-in support for `CSS` `Sass` `Stylus` `Less` `CSS modules`.
11 | - 🎶 Ridiculously easy to use Rollup plugins if you want.
12 | - 🚨 Friendly error logging experience.
13 | - 💻 Written in TypeScript, automatically generated API docs.
14 |
15 |
16 |
17 | ## Documentation
18 |
19 | https://bili.egoist.sh
20 |
21 | ## Author
22 |
23 | **bili** © EGOIST, Released under the [MIT](./LICENSE) License.
24 | Authored and maintained by EGOIST with help from contributors ([list](https://github.com/egoist/bili/contributors)).
25 |
26 | > [Website](https://egoist.sh) · GitHub [@EGOIST](https://github.com/egoist) · Twitter [@\_egoistlily](https://twitter.com/_egoistlily)
27 |
--------------------------------------------------------------------------------
/babel.js:
--------------------------------------------------------------------------------
1 | module.exports = require('./dist/babel')
2 |
--------------------------------------------------------------------------------
/bili.config.ts:
--------------------------------------------------------------------------------
1 | import { Config } from './src'
2 |
3 | const config: Config = {
4 | input: {
5 | index: 'src/index.ts',
6 | cli: 'src/cli.ts',
7 | babel: 'src/babel/preset.ts',
8 | },
9 | bundleNodeModules: true,
10 | externals: [
11 | 'spawn-sync', // from cross-spawn which is from execa which is from term-size which is from boxen
12 | ],
13 | }
14 |
15 | export default config
16 |
--------------------------------------------------------------------------------
/circle.yml:
--------------------------------------------------------------------------------
1 | version: 2
2 | jobs:
3 | build:
4 | working_directory: ~/repo
5 | docker:
6 | - image: circleci/node:10
7 | branches:
8 | ignore:
9 | - gh-pages # list of branches to ignore
10 | - /release\/.*/ # or ignore regexes
11 | steps:
12 | - checkout
13 | - restore_cache:
14 | key: dependency-cache-{{ checksum "yarn.lock" }}
15 | - run:
16 | name: install dependences
17 | command: yarn
18 | - save_cache:
19 | key: dependency-cache-{{ checksum "yarn.lock" }}
20 | paths:
21 | - ./node_modules
22 | - run:
23 | name: test
24 | command: yarn test:cov
25 | - run:
26 | name: upload coverage
27 | command: bash <(curl -s https://codecov.io/bash)
28 | - run:
29 | name: Release
30 | command: yarn semantic-release
31 |
--------------------------------------------------------------------------------
/docs/README.md:
--------------------------------------------------------------------------------
1 | # Bili
2 |
3 | Delightful library bundler.
4 |
5 | ## Features
6 |
7 | - 🚀 Fast, zero-config by default.
8 | - 📦 Using Rollup under the hood.
9 | - 🚗 Automatically transforms JS files using Buble, Babel or TypeScript.
10 | - 💅 Built-in support for CSS, Sass, Stylus, Less and CSS modules.
11 | - 🎶 Ridiculously easy to use Rollup plugins if you want.
12 | - 🚨 Friendly error logging experience.
13 | - 💻 Written in TypeScript, automatically generated API docs.
14 |
15 | ## Quick Start
16 |
17 | Bili is available on npm, [install it](./installation.md) first if you haven't.
18 |
19 | Run `bili` in your project to bundle `src/index.js` in CommonJS format:
20 |
21 | ```bash
22 | bili
23 | ```
24 |
25 | To bundle in other formats:
26 |
27 | ```bash
28 | bili --format esm
29 | # Or multiple
30 | bili --format cjs --format esm
31 | ```
32 |
33 | And you want minified bundles?
34 |
35 | ```bash
36 | bili --format esm-min --format cjs-min
37 | ```
38 |
--------------------------------------------------------------------------------
/docs/configuration-file.md:
--------------------------------------------------------------------------------
1 | # Configuration File
2 |
3 | In most cases CLI options would work just fine, however you can also use following configuration files:
4 |
5 | - `bili.config.js`
6 | - `bili.config.ts`
7 | - `.bilirc.js`
8 | - `.bilirc.ts`
9 |
10 | Check out Configuration Reference in the API documentation.
11 |
12 | ## Syntax
13 |
14 | Both `.js` and `.ts` config files are transpiled by Babel using [babel-preset-env](https://babeljs.io/docs/en/babel-preset-env) and [babel-preset-typescript](https://babeljs.io/docs/en/babel-preset-typescript), so feel free to use modern JavaScript features.
15 |
16 | ## TypeScript
17 |
18 | Bili exposes the `Config` type you can use to type-check your configuration:
19 |
20 | ```ts
21 | // bili.config.ts
22 | import { Config } from 'bili'
23 |
24 | const config: Config = {
25 | input: 'src/index.js'
26 | }
27 |
28 | export default config
29 | ```
30 |
31 | It also works in `.js` file:
32 |
33 | ```js
34 | /** @type {import('bili').Config} */
35 | module.exports = {
36 | input: 'src/index.js'
37 | }
38 | ```
39 |
--------------------------------------------------------------------------------
/docs/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Bili
8 |
9 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/docs/installation.md:
--------------------------------------------------------------------------------
1 | # Installation
2 |
3 | Bili requires [Node.js](https://nodejs.org/en/) 8 or above:
4 |
5 | ```bash
6 | # Check your Node.js version
7 | node -v
8 | ```
9 |
10 | Install Bili locally as dev dependency using npm:
11 |
12 | ```bash
13 | cd your-project
14 | npm i bili -D
15 | ```
16 |
17 | You can also install it with [Yarn](https://yarnpkg.com/) if you want:
18 |
19 | ```bash
20 | cd your-project
21 | yarn add bili --dev
22 | ```
23 |
--------------------------------------------------------------------------------
/docs/main.js:
--------------------------------------------------------------------------------
1 | var API_LINK = location.protocol + '//' + location.host + '/api/'
2 |
3 | new Docute({
4 | versions: {
5 | 'v4 (Latest)': {
6 | link: '/'
7 | },
8 | v3: {
9 | link: 'https://v3--bili.netlify.com'
10 | }
11 | },
12 | sidebar: [
13 | {
14 | title: 'Guide',
15 | links: [
16 | {
17 | title: 'Installation',
18 | link: '/installation'
19 | },
20 | {
21 | title: 'Introduction',
22 | link: '/'
23 | },
24 | {
25 | title: 'Configuration File',
26 | link: '/configuration-file'
27 | },
28 | {
29 | title: 'Plugins',
30 | link: '/plugins'
31 | },
32 | {
33 | title: 'Configuration',
34 | link: API_LINK + 'interfaces/config.html'
35 | }
36 | ]
37 | },
38 | {
39 | title: 'Recipes',
40 | links: [
41 | {
42 | title: 'JavaScript',
43 | link: '/recipes/javascript'
44 | },
45 | {
46 | title: 'CSS',
47 | link: '/recipes/css'
48 | },
49 | {
50 | title: 'Vue Component',
51 | link: '/recipes/vue-component'
52 | },
53 | {
54 | title: 'Environment Variables',
55 | link: '/recipes/env-variables'
56 | },
57 | {
58 | title: 'Update package.json',
59 | link: '/recipes/update-package-json'
60 | }
61 | ]
62 | },
63 | {
64 | title: 'Migration',
65 | links: [
66 | {
67 | title: 'v3 to v4',
68 | link: '/migration/v3-to-v4.md'
69 | }
70 | ]
71 | }
72 | ],
73 | nav: [
74 | {
75 | title: 'Home',
76 | link: '/'
77 | },
78 | {
79 | title: 'API',
80 | link: API_LINK
81 | },
82 | {
83 | title: 'GitHub',
84 | link: 'https://github.com/egoist/bili'
85 | },
86 | {
87 | title: 'Twitter',
88 | link: 'https://twitter.com/_egoistlily'
89 | }
90 | ],
91 | highlight: ['bash', 'typescript', 'json']
92 | })
93 |
--------------------------------------------------------------------------------
/docs/migration/v3-to-v4.md:
--------------------------------------------------------------------------------
1 | # Migrate from v3 to v4
2 |
3 | Please check out the Configure References for all options in v4.
4 |
5 | ## Notable Changes
6 |
7 | ### Rollup v1
8 |
9 | Rollup has been updated to v1, this is a breaking change, so check your bundled file first before publishing it.
10 |
11 | ### Input Files
12 |
13 | In v3 you can use glob patterns as input files like `bili src/*.js --format cjs` but in v4 you can __NOT__ do that, the input must be actual file path.
14 |
15 | Besides using a string or array as input files, now an object is also accepted:
16 |
17 | ```js
18 | // bili.config.js
19 | module.exports = {
20 | input: {
21 | index: 'src/index.js',
22 | cli: 'src/cli.js'
23 | }
24 | }
25 | ```
26 |
27 | ### Plugin Usage
28 |
29 | Previously you can add additional Rollup plugins by passing an array via `plugins` option, but now it should be:
30 |
31 | ```js
32 | module.exports = {
33 | plugins: {
34 | // The `rollup-plugin-` prefix is not needed in plugin name
35 | name: true | false | object
36 | }
37 | }
38 | ```
39 |
40 | The `--js` flag is removed, now you can use `plugins` option to disable built-in plugins too:
41 |
42 | ```js
43 | module.exports = {
44 | plugins: {
45 | babel: false
46 | }
47 | }
48 | ```
49 |
50 | ### Buble
51 |
52 | Buble is enabled by `--minimal` flag or babel.minimal option.
53 |
54 | ### TypeScript
55 |
56 | Nothing really changed, we automatically use `rollup-plugin-typescript2` if the input file has `.ts` extension.
57 |
58 | If you want to transpile TypeScript with Babel, here's a good news, you can just disable this plugin and let our default Babel preset handle `.ts` files using `babel-preset-typescript`.
59 |
60 | ### JSX
61 |
62 | Vue JSX support is removed, it seems to be rarely used. Let me know if you need it.
63 |
64 | ### Config Files
65 |
66 | Config files now get native TypeScript support. See more [here](../configuration-file.md).
67 |
--------------------------------------------------------------------------------
/docs/plugins.md:
--------------------------------------------------------------------------------
1 | # Plugins
2 |
3 | Bili allows you to add additional Rollup plugins like this:
4 |
5 | ```js
6 | module.exports = {
7 | plugins: {
8 | name: true | false | object
9 | }
10 | }
11 | ```
12 |
13 | If the package name starts with `rollup-plugin-`, the key should without the `rollup-plugin-` prefix. However, if the package name starts with `@rollup/`, use the full package name.
14 |
15 | The value will be used as its options, passing `true` is equivalent to an empty object, `false` is used to disable built-in plugins.
16 |
17 | To add plugin via CLI flags, you can do this:
18 |
19 | ```bash
20 | bili --plugin.foo --plugin.bar.option value
21 | ```
22 |
23 | To disable the built-in Babel plugin:
24 |
25 | ```bash
26 | bili --no-plugin.babel
27 | ```
28 |
--------------------------------------------------------------------------------
/docs/recipes/css.md:
--------------------------------------------------------------------------------
1 | # CSS
2 |
3 | `Bili` supports CSS by default with the help from [rollup-plugin-postcss](https://github.com/egoist/rollup-plugin-postcss):
4 |
5 | By default CSS files will be extracted to the same location where the JS is generated but with `.css` extension.
6 |
7 | You can inline CSS in your bundle by either using CLI option: `--no-extract-css` or config file:
8 |
9 | ```js
10 | module.exports = {
11 | output: {
12 | extractCSS: false
13 | }
14 | }
15 | ```
16 |
17 | ## PostCSS Config
18 |
19 | You can populate a `postcss.config.js` to use custom PostCSS plugins.
20 |
21 | ## CSS Preprocessors
22 |
23 | `rollup-plugin-postcss` also supports common CSS Preprocessors like Sass:
24 |
25 | ```bash
26 | yarn add node-sass --dev
27 | ```
28 |
29 | Then you can import `.scss` or `.sass` files in your code.
30 |
31 | For Stylus and Less, you also need to install `stylus` and `less` in your project.
32 |
--------------------------------------------------------------------------------
/docs/recipes/env-variables.md:
--------------------------------------------------------------------------------
1 | # Environment Variables
2 |
3 | You can replace `process.env.{VAR}` in your code with specific value. For example, we have the code as follows:
4 |
5 | ```js
6 | export const version = process.env.VERSION
7 | ```
8 |
9 | Then you can run Bili with CLI flag `--env.VERSION 0.0.0` to replace the corresponding variable to:
10 |
11 | ```js
12 | export const version = '0.0.0'
13 | ```
14 |
15 | You can also specify `env` in the Bili config file:
16 |
17 | ```js
18 | // bili.config.js
19 | module.exports = {
20 | env: {
21 | VERSION: '0.0.0'
22 | }
23 | }
24 | ```
25 |
--------------------------------------------------------------------------------
/docs/recipes/javascript.md:
--------------------------------------------------------------------------------
1 | # JavaScript
2 |
3 | ## Babel
4 |
5 | We use a sane default preset for Babel, basically it:
6 |
7 | - Uses `babel-preset-env`.
8 | - Compiles TypeScript via `babel-preset-typescript`
9 | - Compiles `object-rest-spread` to `Object.assign`.
10 | - Compiles `async/await` to Promise without regenerator using [babel-plugin-transform-async-to-promises](https://github.com/rpetrich/babel-plugin-transform-async-to-promises).
11 | - Compiles JSX.
12 | - Support [optional chaining](https://babeljs.io/docs/en/babel-plugin-proposal-optional-chaining) out of the box.
13 | - Support [nullish coalescing operator](https://babeljs.io/docs/en/babel-plugin-proposal-nullish-coalescing-operator) out of the box.
14 |
15 | You can add a `.babelrc` file in your project to use your custom config instead. If you want to disable `.babelrc` in your project, pass `--no-babelrc` flag.
16 |
17 | You can also use our default preset in your Babel config file:
18 |
19 | ```js
20 | // babel.config.js
21 | module.exports = {
22 | presets: ['bili/babel'],
23 | plugins: [
24 | // Add your babel plugins...
25 | ]
26 | }
27 | ```
28 |
29 | ### Browserslist
30 |
31 | By default Babel transpiles code to ES5, however you can use [Browserslist](https://github.com/browserslist/browserslist) to specify target environments, e.g. if you only want to support Node.js 10, you can have following config in `package.json`:
32 |
33 | ```json
34 | {
35 | "browserslist": ["node 10"]
36 | }
37 | ```
38 |
39 | ### Minimal Mode
40 |
41 | `babel-preset-env` will produce A LOT of code if you're targeting ES5, so we provide an option `babel.minimal` to replace this preset with [Buble](https://buble.surge.sh/guide/) instead. You can also use CLI flag `--minimal`.
42 |
43 | Notably:
44 |
45 | - Buble does not strictly follow spec, use it with caution.
46 | - Browserslist won't work anymore, since it's a feature in babel-preset-env. But you can configure the `buble` plugin using its [target](https://buble.surge.sh/guide/#options) option.
47 |
48 | ## TypeScript
49 |
50 | We automatically use [rollup-plugin-typescript2](https://github.com/ezolenko/rollup-plugin-typescript2) when the entry file ends with `.ts` extension, however you have to install [rollup-plugin-typescript2](https://github.com/ezolenko/rollup-plugin-typescript2) alongside `typescript` to make it work.
51 |
52 | ```bash
53 | yarn add typescript rollup-plugin-typescript2 --dev
54 | ```
55 |
56 | ## Use Babel with TypeScript
57 |
58 | By default Babel is also used for `.ts` files, it will process the file after TypeScript. It's recommended to set `compilerOptions.target` to `es2017` or above in `tsconfig.json` and let Babel transform the code to ES5 instead. If you want to disable Babel, set `plugins: { babel: false }` in your Bili config file.
59 |
--------------------------------------------------------------------------------
/docs/recipes/update-package-json.md:
--------------------------------------------------------------------------------
1 | # Update `package.json`
2 |
3 | Configure fields in `package.json` to make your package work in various environments like `npm`, `webpack`, or a CDN provider like `jsdelivr`.
4 |
5 | ## Configure the default file
6 |
7 | - `main`: the default file for every environment, it's usually pointed to your CommonJS bundle.
8 | - `module`: the default file for tools that supports ES modules. You should use Bili to generate an ESM bundle whenever possible.
9 | - `unpkg`: the default file for unpkg.com with fallback to `main` file. You should point it to the `umd` or `iife` bundle.
10 | - `jsdelivr`: like `unpkg` but for jsdelivr.com.
11 |
12 | ## Specify included files
13 |
14 | You should specify which files should be published on npm instead of publishing everything, since Bili outputs all files to `dist` directory by here, here it will look like:
15 |
16 | ```json
17 | {
18 | "files": ["dist"]
19 | }
20 | ```
21 |
--------------------------------------------------------------------------------
/docs/recipes/vue-component.md:
--------------------------------------------------------------------------------
1 | # Vue Component
2 |
3 | If one of your input files ends with `.vue`, Bili will automatically use [rollup-plugin-vue](https://rollup-plugin-vue.vuejs.org).
4 |
5 | ```bash
6 | yarn add rollup-plugin-vue vue-template-compiler vue --dev
7 |
8 | bili src/MyComponent.vue
9 | ```
10 |
11 | Otherwise you need to add `rollup-plugin-vue` manually using the CLI flag `--plugin.vue` or config file:
12 |
13 | ```js
14 | // bili.config.js
15 | module.exports = {
16 | plugins: {
17 | vue: true
18 | // or with custom options
19 | // vue: {}
20 | }
21 | }
22 | ```
23 |
24 | NOTE: due to [an issue with rollup-plugin-vue](https://github.com/vuejs/rollup-plugin-vue/issues/303), Windows users should use rollup-plugin-vue 5.1.1 or at least [5.1.5](https://github.com/vuejs/rollup-plugin-vue/issues/303#issuecomment-571249003).
25 |
--------------------------------------------------------------------------------
/jest.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | testEnvironment: 'node',
3 | transform: {
4 | '^.+\\.tsx?$': 'ts-jest'
5 | },
6 | testRegex: '(/__test__/.*|(\\.|/)(test|spec))\\.tsx?$',
7 | testPathIgnorePatterns: ['/node_modules/', '/dist/', '/types/'],
8 | moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node']
9 | }
10 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "bili",
3 | "version": "4.0.0",
4 | "description": "A zero configuration library bundler.",
5 | "main": "dist/index.js",
6 | "bin": "dist/cli.js",
7 | "types": "types/index.d.ts",
8 | "files": [
9 | "dist",
10 | "types",
11 | "babel.js"
12 | ],
13 | "scripts": {
14 | "test": "yarn test:unit",
15 | "test:cov": "yarn test:unit --coverage",
16 | "test:unit": "cd test/fixtures && yarn && cd ../../ && yarn jest",
17 | "types": "tsc --build tsconfig.types.json",
18 | "build": "rm -rf dist && node lib/cli",
19 | "prepublishOnly": "yarn types && yarn build",
20 | "docs": "typedoc --out docs/api --theme minimal --mode file",
21 | "dev:docs": "nswatch",
22 | "commit": "git-cz"
23 | },
24 | "repository": {
25 | "url": "git@github.com:egoist/bili.git",
26 | "type": "git"
27 | },
28 | "author": "egoist<0x142857@gmail.com>",
29 | "license": "MIT",
30 | "browserslist": [
31 | "node 6"
32 | ],
33 | "dependencies": {
34 | "@babel/core": "^7.10.2",
35 | "@babel/plugin-proposal-nullish-coalescing-operator": "^7.10.1",
36 | "@babel/plugin-proposal-object-rest-spread": "^7.10.1",
37 | "@babel/plugin-proposal-optional-chaining": "^7.10.1",
38 | "@babel/plugin-transform-react-jsx": "^7.10.1",
39 | "@babel/preset-env": "^7.10.2",
40 | "@babel/preset-typescript": "^7.10.1",
41 | "@rollup/plugin-babel": "^5.0.3",
42 | "@rollup/plugin-buble": "^0.21.3",
43 | "@rollup/plugin-commonjs": "^13.0.0",
44 | "@rollup/plugin-json": "^4.1.0",
45 | "@rollup/plugin-node-resolve": "^8.0.1",
46 | "@rollup/plugin-replace": "^2.3.3",
47 | "babel-plugin-transform-async-to-promises": "^0.8.15",
48 | "chalk": "^4.1.0",
49 | "ora": "^4.0.4",
50 | "rollup": "^2.16.1",
51 | "rollup-plugin-hashbang": "^2.2.2",
52 | "rollup-plugin-postcss": "^3.1.2",
53 | "rollup-plugin-terser": "^6.1.0",
54 | "v8-compile-cache": "^2.1.1",
55 | "cac": "^6.5.10",
56 | "joycon": "^2.2.5"
57 | },
58 | "devDependencies": {
59 | "@types/babel__core": "^7.1.8",
60 | "@types/babel__generator": "^7.6.1",
61 | "@types/babel__template": "^7.0.2",
62 | "@types/babel__traverse": "^7.0.12",
63 | "@types/elegant-spinner": "^2.0.1",
64 | "@types/jest": "^26.0.0",
65 | "@types/lodash": "^4.14.155",
66 | "@types/node": "^14.0.13",
67 | "@types/pify": "^3.0.2",
68 | "@types/require-from-string": "^1.2.0",
69 | "@types/resolve": "^1.17.1",
70 | "babel-plugin-alter-object-assign": "^1.0.2",
71 | "boxen": "^4.2.0",
72 | "builtin-modules": "^3.1.0",
73 | "commitizen": "^4.1.2",
74 | "cz-conventional-changelog": "^3.2.0",
75 | "gzip-size": "^5.1.1",
76 | "husky": "^4.2.5",
77 | "jest": "^26.0.1",
78 | "lint-staged": "^10.2.10",
79 | "lodash": "^4.17.15",
80 | "nswatch": "^0.2.0",
81 | "p-waterfall": "^2.1.0",
82 | "pify": "^5.0.0",
83 | "prettier": "^2.0.5",
84 | "pretty-bytes": "^5.3.0",
85 | "pretty-ms": "^7.0.0",
86 | "require-from-string": "^2.0.2",
87 | "require-so-slow": "^2.0.2",
88 | "resolve": "^1.17.0",
89 | "resolve-from": "^5.0.0",
90 | "rollup-plugin-typescript2": "^0.27.1",
91 | "semantic-release": "^17.0.8",
92 | "semver": "^7.3.2",
93 | "slash": "^3.0.0",
94 | "string-width": "^4.2.0",
95 | "stringify-author": "^0.1.3",
96 | "text-table": "^0.2.0",
97 | "tinydate": "^1.2.0",
98 | "ts-jest": "^26.1.0",
99 | "typedoc": "^0.17.7",
100 | "typescript": "^3.9.5"
101 | },
102 | "husky": {
103 | "hooks": {
104 | "pre-commit": "lint-staged"
105 | }
106 | },
107 | "lint-staged": {
108 | "*.{ts,js,json,md,vue}": [
109 | "prettier --write",
110 | "git add"
111 | ]
112 | },
113 | "engines": {
114 | "node": ">=6"
115 | },
116 | "watch": {
117 | "./src/**/*.ts": [
118 | "docs"
119 | ]
120 | },
121 | "config": {
122 | "commitizen": {
123 | "path": "cz-conventional-changelog"
124 | }
125 | }
126 | }
127 |
--------------------------------------------------------------------------------
/src/babel/preset.ts:
--------------------------------------------------------------------------------
1 | import alterObjectAssign from 'babel-plugin-alter-object-assign'
2 |
3 | const ENV = process.env.BABEL_ENV || process.env.NODE_ENV
4 |
5 | export default (
6 | context: any,
7 | {
8 | asyncToPromises = process.env.BILI_ASYNC_TO_PROMISES,
9 | jsx = process.env.BILI_JSX,
10 | objectAssign = process.env.BILI_OBJECT_ASSIGN,
11 | minimal = process.env.BILI_MINIMAL
12 | } = {}
13 | ) => {
14 | const presets = [
15 | !minimal && [
16 | require('@babel/preset-env').default,
17 | {
18 | modules: ENV === 'test' ? 'auto' : false,
19 | exclude: [
20 | 'transform-regenerator',
21 | 'transform-async-to-generator',
22 | 'proposal-object-rest-spread'
23 | ]
24 | }
25 | ],
26 | require('@babel/preset-typescript')
27 | ].filter(Boolean)
28 |
29 | const plugins = [
30 | [
31 | require('@babel/plugin-transform-react-jsx'),
32 | {
33 | pragma: jsx === 'react' ? 'React.createElement' : jsx
34 | }
35 | ],
36 | [
37 | require('@babel/plugin-proposal-object-rest-spread'),
38 | {
39 | useBuiltIns: true,
40 | loose: true
41 | }
42 | ],
43 | [require('@babel/plugin-proposal-optional-chaining')],
44 | [require('@babel/plugin-proposal-nullish-coalescing-operator')],
45 | [
46 | alterObjectAssign,
47 | {
48 | objectAssign
49 | }
50 | ],
51 | asyncToPromises && require('babel-plugin-transform-async-to-promises')
52 | ].filter(Boolean)
53 |
54 | return {
55 | presets,
56 | plugins
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/src/cli.ts:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 | import 'v8-compile-cache'
3 | import { cac } from 'cac'
4 | import { version } from '../package.json'
5 |
6 | if (process.env.BILI_LOCAL_PROFILE) {
7 | const requireSoSlow = require('require-so-slow')
8 | process.on('exit', () => {
9 | requireSoSlow.write('require-trace.trace')
10 | })
11 | }
12 |
13 | const cli = cac('bili')
14 |
15 | cli
16 | .command('[...input]', 'Bundle input files', {
17 | ignoreOptionDefaultValue: true,
18 | })
19 | .option('-w, --watch', 'Watch files')
20 | .option(
21 | '--format ',
22 | 'Output format (cjs | umd | es | iife), can be used multiple times'
23 | )
24 | .option('--input.* [file]', 'An object mapping names to entry points')
25 | .option('-d, --out-dir ', 'Output directory', { default: 'dist' })
26 | .option('--root-dir ', 'The root directory to resolve files from')
27 | .option('--file-name ', 'Set the file name for output files')
28 | .option('--module-name ', 'Set the module name for umd bundle')
29 | .option('--env.* [value]', 'Replace env variables')
30 | .option('--plugin, --plugins.* [options]', 'Use a plugin')
31 | .option(
32 | '--global.* [path]',
33 | 'id:moduleName pair for external imports in umd/iife bundles'
34 | )
35 | .option('--no-extract-css', 'Do not extract CSS files')
36 | .option('--bundle-node-modules', 'Include node modules in your bundle')
37 | .option('--minify', 'Minify output files')
38 | .option('--external ', 'Mark a module id as external', {
39 | type: [],
40 | })
41 | .option('-t, --target ', 'Output target', { default: 'node' })
42 | .option('-c, --config ', 'Use a custom config file')
43 | .option('--minimal', 'Generate minimal output whenever possible')
44 | .option('--no-babelrc', 'Disable .babelrc file')
45 | .option('--banner', 'Add banner with pkg info to the bundle')
46 | .option(
47 | '--no-map',
48 | 'Disable source maps, enabled by default for minified bundles'
49 | )
50 | .option('--map-exclude-sources', 'Exclude source code in source maps')
51 | .option('--no-async-pro, --no-async-to-promises', 'Leave async/await as is')
52 | .option('--concurrent', 'Build concurrently')
53 | .option('--verbose', 'Show verbose logs')
54 | .option('--quiet', 'Show minimal logs')
55 | .option('--stack-trace', 'Show stack trace for bundle errors')
56 | .example((bin) => ` ${bin} --format cjs --format esm`)
57 | .example((bin) => ` ${bin} src/index.js,src/cli.ts`)
58 | .example((bin) => ` ${bin} --input.index src/foo.ts`)
59 | .action(async (input, options) => {
60 | const { Bundler } = await import('./')
61 | const rootDir = options.rootDir || '.'
62 | const bundler = new Bundler(
63 | {
64 | input: options.input || (input.length === 0 ? undefined : input),
65 | output: {
66 | format: options.format,
67 | dir: options.outDir,
68 | moduleName: options.moduleName,
69 | fileName: options.fileName,
70 | minify: options.minify,
71 | extractCSS: options.extractCss,
72 | sourceMap: options.map,
73 | sourceMapExcludeSources: options.mapExcludeSources,
74 | target: options.target,
75 | },
76 | bundleNodeModules: options.bundleNodeModules,
77 | env: options.env,
78 | plugins: options.plugins,
79 | externals: options.external,
80 | globals: options.global,
81 | banner: options.banner,
82 | babel: {
83 | asyncToPromises: options.asyncToPromises,
84 | minimal: options.minimal,
85 | babelrc: options.babelrc,
86 | },
87 | },
88 | {
89 | logLevel: options.verbose
90 | ? 'verbose'
91 | : options.quiet
92 | ? 'quiet'
93 | : undefined,
94 | stackTrace: options.stackTrace,
95 | configFile: options.config,
96 | rootDir,
97 | }
98 | )
99 | await bundler
100 | .run({
101 | write: true,
102 | watch: options.watch,
103 | concurrent: options.concurrent,
104 | })
105 | .catch((err: any) => {
106 | bundler.handleError(err)
107 | process.exit(1)
108 | })
109 | })
110 |
111 | cli.version(version)
112 | cli.help()
113 |
114 | cli.parse()
115 |
116 | process.on('unhandledRejection', (err) => {
117 | console.error(err)
118 | process.exit(1)
119 | })
120 |
--------------------------------------------------------------------------------
/src/config-loader.ts:
--------------------------------------------------------------------------------
1 | import path from 'path'
2 | import fs from 'fs'
3 | import JoyCon from 'joycon'
4 | import requireFromString from 'require-from-string'
5 |
6 | const configLoader = new JoyCon({
7 | stopDir: path.dirname(process.cwd())
8 | })
9 |
10 | configLoader.addLoader({
11 | test: /\.[jt]s$/,
12 | loadSync(id) {
13 | const content = require('@babel/core').transform(
14 | fs.readFileSync(id, 'utf8'),
15 | {
16 | babelrc: false,
17 | configFile: false,
18 | filename: id,
19 | presets: [
20 | [
21 | require('@babel/preset-env'),
22 | {
23 | targets: {
24 | node: 'current'
25 | }
26 | }
27 | ],
28 | id.endsWith('.ts') && require('@babel/preset-typescript')
29 | ].filter(Boolean)
30 | }
31 | )
32 | const m = requireFromString(content && content.code ? content.code : '', id)
33 | return m.default || m
34 | }
35 | })
36 |
37 | export default configLoader
38 |
--------------------------------------------------------------------------------
/src/index.ts:
--------------------------------------------------------------------------------
1 | import './polyfills'
2 | import path from 'path'
3 | import colors from 'chalk'
4 | import prettyBytes from 'pretty-bytes'
5 | import formatTime from 'pretty-ms'
6 | import textTable from 'text-table'
7 | import resolveFrom from 'resolve-from'
8 | import boxen from 'boxen'
9 | import stringWidth from 'string-width'
10 | import {
11 | rollup,
12 | watch,
13 | Plugin as RollupPlugin,
14 | ModuleFormat as RollupFormat,
15 | } from 'rollup'
16 | import merge from 'lodash/merge'
17 | import waterfall from 'p-waterfall'
18 | import spinner from './spinner'
19 | import logger from './logger'
20 | import progressPlugin from './plugins/progress'
21 | import nodeResolvePlugin from './plugins/node-resolve'
22 | import configLoader from './config-loader'
23 | import isExternal from './utils/is-external'
24 | import getBanner from './utils/get-banner'
25 | import {
26 | Options,
27 | Config,
28 | NormalizedConfig,
29 | Format,
30 | ConfigEntryObject,
31 | Env,
32 | ConfigOutput,
33 | RunContext,
34 | RollupConfig,
35 | Task,
36 | } from './types'
37 |
38 | // Make rollup-plugin-vue use basename in component.__file instead of absolute path
39 | // TODO: PR to rollup-plugin-vue to allow this as an API option
40 | process.env.BUILD = 'production'
41 |
42 | interface RunOptions {
43 | write?: boolean
44 | watch?: boolean
45 | concurrent?: boolean
46 | }
47 |
48 | interface RollupConfigInput {
49 | source: {
50 | input: string[] | ConfigEntryObject
51 | files: string[]
52 | hasVue: boolean
53 | hasTs: boolean
54 | }
55 | title: string
56 | format: Format
57 | context: RunContext
58 | assets: Assets
59 | config: NormalizedConfig
60 | }
61 |
62 | type PluginFactory = (opts: any) => RollupPlugin
63 | type GetPlugin = (name: string) => Promise
64 |
65 | export class Bundler {
66 | rootDir: string
67 | config: NormalizedConfig
68 | configPath?: string
69 | pkg: {
70 | path?: string
71 | data?: any
72 | }
73 | bundles: Set
74 |
75 | constructor(config: Config, public options: Options = {}) {
76 | logger.setOptions({ logLevel: options.logLevel })
77 |
78 | this.rootDir = path.resolve(options.rootDir || '.')
79 |
80 | this.pkg = configLoader.loadSync({
81 | files: ['package.json'],
82 | cwd: this.rootDir,
83 | })
84 | if (!this.pkg.data) {
85 | this.pkg.data = {}
86 | }
87 |
88 | if (/\.mjs$/.test(this.pkg.data.module || this.pkg.data.main)) {
89 | logger.warn(
90 | `Bili no longer use .mjs extension for esm bundle, you should use .js instead!`
91 | )
92 | }
93 |
94 | const userConfig =
95 | options.configFile === false
96 | ? {}
97 | : configLoader.loadSync({
98 | files:
99 | typeof options.configFile === 'string'
100 | ? [options.configFile]
101 | : [
102 | 'bili.config.js',
103 | 'bili.config.ts',
104 | '.bilirc.js',
105 | '.bilirc.ts',
106 | 'package.json',
107 | ],
108 | cwd: this.rootDir,
109 | packageKey: 'bili',
110 | })
111 | if (userConfig.path) {
112 | logger.debug(`Using config file:`, userConfig.path)
113 | this.configPath = userConfig.path
114 | }
115 |
116 | this.config = this.normalizeConfig(
117 | config,
118 | userConfig.data || {}
119 | ) as NormalizedConfig
120 |
121 | this.bundles = new Set()
122 | }
123 |
124 | normalizeConfig(config: Config, userConfig: Config) {
125 | const externals = new Set([
126 | ...Object.keys(this.pkg.data.dependencies || {}),
127 | ...(Array.isArray(userConfig.externals)
128 | ? userConfig.externals
129 | : [userConfig.externals]),
130 | ...(Array.isArray(config.externals)
131 | ? config.externals
132 | : [config.externals]),
133 | ])
134 | const result = merge({}, userConfig, config, {
135 | input: config.input || userConfig.input || 'src/index.js',
136 | output: merge({}, userConfig.output, config.output),
137 | plugins: merge({}, userConfig.plugins, config.plugins),
138 | babel: merge(
139 | {
140 | asyncToPromises: true,
141 | },
142 | userConfig.babel,
143 | config.babel
144 | ),
145 | externals: [...externals].filter(Boolean),
146 | })
147 |
148 | result.output.dir = path.resolve(result.output.dir || 'dist')
149 |
150 | return result
151 | }
152 |
153 | async createRollupConfig({
154 | source,
155 | format,
156 | title,
157 | context,
158 | assets,
159 | config,
160 | }: RollupConfigInput): Promise {
161 | // Always minify if config.minify is truthy
162 | // Otherwise infer by format
163 | const minify =
164 | config.output.minify === undefined
165 | ? format.endsWith('-min')
166 | : config.output.minify
167 | let minPlaceholder = ''
168 | let rollupFormat: RollupFormat
169 | if (format.endsWith('-min')) {
170 | rollupFormat = format.replace(/-min$/, '') as RollupFormat
171 | minPlaceholder = '.min'
172 | } else {
173 | rollupFormat = format as RollupFormat
174 | }
175 |
176 | // UMD format should always bundle node_modules
177 | const bundleNodeModules =
178 | rollupFormat === 'umd' ||
179 | rollupFormat === 'iife' ||
180 | config.bundleNodeModules
181 |
182 | // rollup-plugin-typescript2 < v0.26 needs the `objectHashIgnoreUnknownHack`
183 | // option to be enabled to correctly handle async plugins, but it's no
184 | // longer needed (and causes a warning) if the user has a more recent
185 | // version installed. [1] if the plugin is installed, detect the version
186 | // and enable/disable the option accordingly.
187 | //
188 | // [1] https://github.com/egoist/bili/issues/305
189 | const getObjectHashIgnoreUnknownHack = (): boolean => {
190 | try {
191 | const { version } = this.localRequire(
192 | 'rollup-plugin-typescript2/package.json'
193 | )
194 | const semver = require('semver')
195 | return semver.lt(version, '0.26.0')
196 | } catch (e) {
197 | return true
198 | }
199 | }
200 |
201 | const pluginsOptions: { [key: string]: any } = {
202 | progress:
203 | config.plugins.progress !== false &&
204 | merge(
205 | {
206 | title,
207 | },
208 | config.plugins.progress
209 | ),
210 |
211 | json: config.plugins.json !== false && merge({}, config.plugins.json),
212 |
213 | hashbang:
214 | config.plugins.hashbang !== false && merge({}, config.plugins.hashbang),
215 |
216 | 'node-resolve':
217 | config.plugins['node-resolve'] !== false &&
218 | merge(
219 | {},
220 | {
221 | rootDir: this.rootDir,
222 | bundleNodeModules,
223 | externals: config.externals,
224 | browser: config.output.target === 'browser',
225 | },
226 | config.plugins['node-resolve']
227 | ),
228 |
229 | postcss:
230 | config.plugins.postcss !== false &&
231 | merge(
232 | {
233 | extract: config.output.extractCSS !== false,
234 | },
235 | config.plugins.postcss
236 | ),
237 |
238 | vue:
239 | (source.hasVue || config.plugins.vue) &&
240 | merge(
241 | {
242 | css: false,
243 | },
244 | config.plugins.vue
245 | ),
246 |
247 | typescript2:
248 | (source.hasTs || config.plugins.typescript2) &&
249 | merge(
250 | {
251 | objectHashIgnoreUnknownHack: getObjectHashIgnoreUnknownHack(),
252 | tsconfigOverride: {
253 | compilerOptions: {
254 | module: 'esnext',
255 | },
256 | },
257 | },
258 | config.plugins.typescript2
259 | ),
260 |
261 | babel:
262 | config.plugins.babel !== false &&
263 | merge(
264 | {
265 | exclude: 'node_modules/**',
266 | extensions: ['.js', '.jsx', '.mjs', '.ts', '.tsx', '.vue'],
267 | babelrc: config.babel.babelrc,
268 | configFile: config.babel.configFile,
269 | presetOptions: config.babel,
270 | babelHelpers: 'bundled',
271 | },
272 | config.plugins.babel
273 | ),
274 |
275 | buble:
276 | (config.plugins.buble || config.babel.minimal) &&
277 | merge(
278 | {
279 | exclude: 'node_modules/**',
280 | include: '**/*.{js,mjs,jsx,ts,tsx,vue}',
281 | transforms: {
282 | modules: false,
283 | dangerousForOf: true,
284 | dangerousTaggedTemplateString: true,
285 | },
286 | },
287 | config.plugins.buble
288 | ),
289 |
290 | commonjs:
291 | config.plugins.commonjs !== false &&
292 | merge({}, config.plugins.commonjs, {
293 | // `ignore` is required to allow dynamic require
294 | // See: https://github.com/rollup/rollup-plugin-commonjs/blob/4a22147456b1092dd565074dc33a63121675102a/src/index.js#L32
295 | ignore: (name: string) => {
296 | const { commonjs } = config.plugins
297 | if (commonjs && commonjs.ignore && commonjs.ignore(name)) {
298 | return true
299 | }
300 | return isExternal(config.externals, name)
301 | },
302 | }),
303 | }
304 |
305 | const env = Object.assign({}, config.env)
306 |
307 | // drop process.env.NODE_ENV from umd/iife
308 | if (
309 | ['umd', 'umd-min', 'iife', 'iife-min'].includes(format) &&
310 | env.NODE_ENV === undefined
311 | ) {
312 | env.NODE_ENV = minify ? 'production' : 'development'
313 | }
314 |
315 | pluginsOptions.replace = {
316 | ...Object.keys(env).reduce((res: Env, name) => {
317 | res[`process.env.${name}`] = JSON.stringify(env[name])
318 | return res
319 | }, {}),
320 | ...config.plugins.replace,
321 | }
322 |
323 | if (Object.keys(pluginsOptions.replace).length === 0) {
324 | pluginsOptions.replace = false
325 | }
326 |
327 | const banner = getBanner(config.banner, this.pkg.data)
328 |
329 | if (minify) {
330 | const terserOptions = config.plugins.terser || {}
331 | pluginsOptions.terser = {
332 | ...terserOptions,
333 | output: {
334 | comments: false,
335 | ...terserOptions.output,
336 | // Add banner (if there is)
337 | preamble: banner,
338 | },
339 | }
340 | }
341 |
342 | for (const name of Object.keys(config.plugins)) {
343 | if (pluginsOptions[name] === undefined) {
344 | Object.assign(pluginsOptions, { [name]: config.plugins[name] })
345 | }
346 | }
347 |
348 | const getPlugin: GetPlugin = async (name: string) => {
349 | if (config.resolvePlugins && config.resolvePlugins[name]) {
350 | return config.resolvePlugins[name]
351 | }
352 |
353 | const pkg = require('../package')
354 |
355 | const isCommunityBuiltin = pkg.dependencies[`rollup-plugin-${name}`]
356 |
357 | const isOfficialBuiltin = pkg.dependencies[`@rollup/plugin-${name}`]
358 |
359 | const plugin =
360 | name === 'babel'
361 | ? await import('./plugins/babel')
362 | : name === 'node-resolve'
363 | ? nodeResolvePlugin
364 | : name === 'progress'
365 | ? progressPlugin
366 | : name.startsWith('@rollup/')
367 | ? this.localRequire(name)
368 | : isCommunityBuiltin
369 | ? require(`rollup-plugin-${name}`)
370 | : isOfficialBuiltin
371 | ? require(`@rollup/plugin-${name}`)
372 | : this.localRequire(`rollup-plugin-${name}`)
373 |
374 | if (name === 'terser') {
375 | return plugin.terser
376 | }
377 |
378 | return plugin.default || plugin
379 | }
380 |
381 | const plugins = await Promise.all(
382 | Object.keys(pluginsOptions)
383 | .filter((name) => pluginsOptions[name])
384 | .map(async (name) => {
385 | const options =
386 | pluginsOptions[name] === true ? {} : pluginsOptions[name]
387 | const plugin = await getPlugin(name)
388 | if (typeof plugin !== 'function') {
389 | throw new Error(
390 | `Plugin "${name}" doesn't export a function, got ${plugin}`
391 | )
392 | }
393 | return plugin(options)
394 | })
395 | )
396 |
397 | if (logger.isDebug) {
398 | for (const name of Object.keys(pluginsOptions)) {
399 | if (pluginsOptions[name]) {
400 | logger.debug(colors.dim(format), `Using plugin: ${name}`)
401 | }
402 | }
403 | }
404 |
405 | // Add bundle to out assets Map
406 | // So that we can log the stats when all builds completed
407 | // Make sure this is the last plugin!
408 | let startTime: number
409 | let endTime: number
410 | plugins.push({
411 | name: 'record-bundle',
412 | generateBundle(outputOptions, _assets) {
413 | const EXTS = [
414 | outputOptions.entryFileNames
415 | ? path.extname(outputOptions.entryFileNames)
416 | : '.js',
417 | '.css',
418 | ]
419 | for (const fileName of Object.keys(_assets)) {
420 | if (EXTS.some((ext) => fileName.endsWith(ext))) {
421 | const file: any = _assets[fileName]
422 | const absolute =
423 | outputOptions.dir && path.resolve(outputOptions.dir, fileName)
424 | if (absolute) {
425 | const relative = path.relative(process.cwd(), absolute)
426 | assets.set(relative, {
427 | absolute,
428 | get source() {
429 | return file.type === 'asset'
430 | ? file.source.toString()
431 | : file.code
432 | },
433 | })
434 | }
435 | }
436 | }
437 | },
438 | buildStart() {
439 | startTime = Date.now()
440 | },
441 | buildEnd() {
442 | endTime = Date.now()
443 | },
444 | async writeBundle() {
445 | await printAssets(
446 | assets,
447 | `${title.replace('Bundle', 'Bundled')} ${colors.dim(
448 | `(${formatTime(endTime - startTime)})`
449 | )}`
450 | )
451 | },
452 | })
453 |
454 | const defaultFileName = getDefaultFileName(rollupFormat)
455 | const getFileName = config.output.fileName || defaultFileName
456 | const fileNameTemplate =
457 | typeof getFileName === 'function'
458 | ? getFileName({ format: rollupFormat, minify }, defaultFileName)
459 | : getFileName
460 | let fileName = fileNameTemplate
461 | .replace(/\[min\]/, minPlaceholder)
462 | // The `[ext]` placeholder no longer makes sense
463 | // Since we only output to `.js` now
464 | // Probably remove it in the future
465 | .replace(/\[ext\]/, '.js')
466 |
467 | if (rollupFormat === 'esm') {
468 | fileName = fileName.replace(/\[format\]/, 'esm')
469 | }
470 |
471 | return {
472 | inputConfig: {
473 | input: source.input,
474 | plugins,
475 | external: Object.keys(config.globals || {}).filter(
476 | (v) => !/^[\.\/]/.test(v)
477 | ),
478 | onwarn(warning) {
479 | if (typeof warning === 'string') {
480 | return logger.warn(warning)
481 | }
482 | const code = (warning.code || '').toLowerCase()
483 | if (code === 'mixed_exports' || code === 'missing_global_name') {
484 | return
485 | }
486 | let message = warning.message
487 | if (code === 'unresolved_import' && warning.source) {
488 | if (format !== 'umd' || context.unresolved.has(warning.source)) {
489 | return
490 | }
491 | context.unresolved.add(warning.source)
492 | message = `${warning.source} is treated as external dependency`
493 | }
494 | logger.warn(
495 | `${colors.yellow(`${code}`)}${colors.dim(':')} ${message}`
496 | )
497 | },
498 | },
499 | outputConfig: {
500 | globals: config.globals,
501 | format: rollupFormat,
502 | dir: path.resolve(config.output.dir || 'dist'),
503 | entryFileNames: fileName,
504 | name: config.output.moduleName,
505 | banner,
506 | sourcemap:
507 | typeof config.output.sourceMap === 'boolean'
508 | ? config.output.sourceMap
509 | : minify,
510 | sourcemapExcludeSources: config.output.sourceMapExcludeSources,
511 | },
512 | }
513 | }
514 |
515 | async run(options: RunOptions = {}) {
516 | const context: RunContext = {
517 | unresolved: new Set(),
518 | }
519 | const tasks: Task[] = []
520 |
521 | let { input } = this.config
522 | if (!Array.isArray(input)) {
523 | input = [input || 'src/index.js']
524 | }
525 | if (Array.isArray(input) && input.length === 0) {
526 | input = ['src/index.js']
527 | }
528 |
529 | const getMeta = (files: string[]) => {
530 | return {
531 | hasVue: files.some((file) => file.endsWith('.vue')),
532 | hasTs: files.some((file) => /\.tsx?$/.test(file)),
533 | }
534 | }
535 |
536 | const normalizeInputValue = (input: string[] | ConfigEntryObject) => {
537 | if (Array.isArray(input)) {
538 | return input.map(
539 | (v) => `./${path.relative(this.rootDir, this.resolveRootDir(v))}`
540 | )
541 | }
542 | return Object.keys(input).reduce(
543 | (res: ConfigEntryObject, entryName: string) => {
544 | res[entryName] = `./${path.relative(
545 | this.rootDir,
546 | this.resolveRootDir(input[entryName])
547 | )}`
548 | return res
549 | },
550 | {}
551 | )
552 | }
553 |
554 | const sources = input.map((v) => {
555 | if (typeof v === 'string') {
556 | const files = v.split(',')
557 | return {
558 | files,
559 | input: normalizeInputValue(files),
560 | ...getMeta(files),
561 | }
562 | }
563 | const files = Object.values(v)
564 | return {
565 | files,
566 | input: normalizeInputValue(v),
567 | ...getMeta(files),
568 | }
569 | })
570 |
571 | let { format, target } = this.config.output
572 | if (Array.isArray(format)) {
573 | if (format.length === 0) {
574 | format = ['cjs']
575 | }
576 | } else if (typeof format === 'string') {
577 | format = format.split(',') as Format[]
578 | } else {
579 | format = ['cjs']
580 | }
581 | const formats = format
582 |
583 | for (const source of sources) {
584 | for (const format of formats) {
585 | let title = `Bundle ${source.files.join(', ')} in ${format} format`
586 | if (target) {
587 | title += ` for target ${target}`
588 | }
589 | tasks.push({
590 | title,
591 | getConfig: async (context, task) => {
592 | const assets: Assets = new Map()
593 | this.bundles.add(assets)
594 | const config = this.config.extendConfig
595 | ? this.config.extendConfig(merge({}, this.config), {
596 | input: source.input,
597 | format,
598 | })
599 | : this.config
600 | const rollupConfig = await this.createRollupConfig({
601 | source,
602 | format,
603 | title: task.title,
604 | context,
605 | assets,
606 | config,
607 | })
608 | return this.config.extendRollupConfig
609 | ? this.config.extendRollupConfig(rollupConfig)
610 | : rollupConfig
611 | },
612 | })
613 | }
614 | }
615 |
616 | if (options.watch) {
617 | const configs = await Promise.all(
618 | tasks.map(async (task) => {
619 | const { inputConfig, outputConfig } = await task.getConfig(
620 | context,
621 | task
622 | )
623 | return {
624 | ...inputConfig,
625 | output: outputConfig,
626 | watch: {},
627 | }
628 | })
629 | )
630 | const watcher = watch(configs)
631 | watcher.on('event', (e) => {
632 | if (e.code === 'ERROR') {
633 | logger.error(e.error.message)
634 | }
635 | })
636 | } else {
637 | try {
638 | if (options.concurrent) {
639 | await Promise.all(
640 | tasks.map((task) => {
641 | return this.build(task, context, options.write)
642 | })
643 | )
644 | } else {
645 | await waterfall(
646 | tasks.map((task) => () => {
647 | return this.build(task, context, options.write)
648 | }),
649 | context
650 | )
651 | }
652 | } catch (err) {
653 | spinner.stop()
654 | throw err
655 | }
656 | }
657 |
658 | return this
659 | }
660 |
661 | async build(task: Task, context: RunContext, write?: boolean) {
662 | try {
663 | const { inputConfig, outputConfig } = await task.getConfig(context, task)
664 | const bundle = await rollup(inputConfig)
665 | if (write) {
666 | await bundle.write(outputConfig)
667 | } else {
668 | await bundle.generate(outputConfig)
669 | }
670 | } catch (err) {
671 | err.rollup = true
672 | logger.error(task.title.replace('Bundle', 'Failed to bundle'))
673 | if (err.message.includes('You must supply output.name for UMD bundles')) {
674 | err.code = 'require_module_name'
675 | err.message = `You must supply output.moduleName option or use --module-name flag for UMD bundles`
676 | }
677 | throw err
678 | }
679 | }
680 |
681 | handleError(err: any) {
682 | if (err.stack) {
683 | console.error()
684 | console.error(colors.bold(colors.red('Stack Trace:')))
685 | console.error(colors.dim(err.stack))
686 | }
687 | }
688 |
689 | resolveRootDir(...args: string[]) {
690 | return path.resolve(this.rootDir, ...args)
691 | }
692 |
693 | localRequire(
694 | name: string,
695 | { silent, cwd }: { silent?: boolean; cwd?: string } = {}
696 | ) {
697 | cwd = cwd || this.rootDir
698 | const resolved = silent
699 | ? resolveFrom.silent(cwd, name)
700 | : resolveFrom(cwd, name)
701 | return resolved && require(resolved)
702 | }
703 |
704 | getBundle(index: number) {
705 | return [...this.bundles][index]
706 | }
707 | }
708 |
709 | interface Asset {
710 | absolute: string
711 | source: string
712 | }
713 | type Assets = Map
714 |
715 | async function printAssets(assets: Assets, title: string) {
716 | const gzipSize = await import('gzip-size').then((res) => res.default)
717 | const table = await Promise.all(
718 | [...assets.keys()].map(async (relative) => {
719 | const asset = assets.get(relative) as Asset
720 | const size = asset.source.length
721 | return [
722 | colors.green(relative),
723 | prettyBytes(size),
724 | prettyBytes(await gzipSize(asset.source)),
725 | ]
726 | })
727 | )
728 | table.unshift(['File', 'Size', 'Gzipped'].map((v) => colors.dim(v)))
729 | logger.success(title)
730 | logger.log(
731 | boxen(
732 | textTable(table, {
733 | stringLength: stringWidth,
734 | })
735 | )
736 | )
737 | }
738 |
739 | function getDefaultFileName(format: RollupFormat) {
740 | return format === 'cjs' ? `[name][min][ext]` : `[name].[format][min][ext]`
741 | }
742 |
743 | export { Config, NormalizedConfig, Options, ConfigOutput }
744 |
--------------------------------------------------------------------------------
/src/logger.ts:
--------------------------------------------------------------------------------
1 | import colors from 'chalk'
2 | import spinner from './spinner'
3 |
4 | interface Options {
5 | logLevel?: 'verbose' | 'quiet'
6 | }
7 |
8 | class Logger {
9 | options: Options
10 |
11 | constructor(options?: Options) {
12 | this.options = options || {}
13 | }
14 |
15 | setOptions(options: Options) {
16 | Object.assign(this.options, options)
17 | }
18 |
19 | get isDebug() {
20 | return this.options.logLevel === 'verbose'
21 | }
22 |
23 | get isQuiet() {
24 | return this.options.logLevel === 'quiet'
25 | }
26 |
27 | warn(...args: any[]) {
28 | this.log(colors.yellow('warning'), ...args)
29 | }
30 |
31 | error(...args: any[]) {
32 | this.log(colors.red('error'), ...args)
33 | }
34 |
35 | success(...args: any[]) {
36 | this.log(colors.green('success'), ...args)
37 | }
38 |
39 | log(...args: any[]) {
40 | spinner.stop()
41 | if (this.isQuiet) return
42 | console.log(...args)
43 | }
44 |
45 | debug(...args: any[]) {
46 | if (!this.isDebug) return
47 | this.log(colors.magenta('verbose'), ...args)
48 | }
49 |
50 | progress(text: string) {
51 | if (this.isQuiet) return
52 | spinner.start(text)
53 | }
54 | }
55 |
56 | export default new Logger()
57 |
--------------------------------------------------------------------------------
/src/plugins/babel.ts:
--------------------------------------------------------------------------------
1 | import { createBabelInputPluginFactory } from '@rollup/plugin-babel'
2 | import preset from '../babel/preset'
3 | import { BabelPresetOptions } from '../types'
4 |
5 | export const a = 1
6 |
7 | export default createBabelInputPluginFactory((babelCore) => {
8 | const presetItem = babelCore.createConfigItem(preset, {
9 | type: 'preset',
10 | })
11 |
12 | return {
13 | // Passed the plugin options.
14 | options({
15 | presetOptions,
16 | ...pluginOptions
17 | }: {
18 | presetOptions: BabelPresetOptions
19 | }) {
20 | return {
21 | // Pull out any custom options that the plugin might have.
22 | customOptions: {
23 | presetOptions,
24 | },
25 |
26 | // Pass the options back with the two custom options removed.
27 | pluginOptions,
28 | }
29 | },
30 |
31 | // Passed Babel's 'PartialConfig' object.
32 | config(cfg: any, data: any) {
33 | if (cfg.hasFilesystemConfig()) {
34 | // Use the normal config
35 | return cfg.options
36 | }
37 |
38 | const presetOptions: BabelPresetOptions = data.customOptions.presetOptions
39 |
40 | // We set the options for default preset using env vars
41 | // So that you can use our default preset in your own babel.config.js
42 | // And our options will still work
43 | if (presetOptions.asyncToPromises) {
44 | process.env.BILI_ASYNC_TO_PROMISES = 'enabled'
45 | }
46 |
47 | if (presetOptions.jsx) {
48 | process.env.BILI_JSX = presetOptions.jsx
49 | }
50 |
51 | if (presetOptions.objectAssign) {
52 | process.env.BILI_OBJECT_ASSIGN = presetOptions.objectAssign
53 | }
54 |
55 | if (presetOptions.minimal) {
56 | process.env.BILI_MINIMAL = 'enabled'
57 | }
58 |
59 | return {
60 | ...cfg.options,
61 | presets: [
62 | ...(cfg.options.presets || []),
63 |
64 | // Include a custom preset in the options.
65 | presetItem,
66 | ],
67 | }
68 | },
69 | }
70 | })
71 |
--------------------------------------------------------------------------------
/src/plugins/node-resolve.ts:
--------------------------------------------------------------------------------
1 | import builtinModules from 'builtin-modules'
2 | import { NormalizedConfig } from '../index'
3 | import isExternal from '../utils/is-external'
4 | import logger from '../logger'
5 |
6 | interface Options {
7 | rootDir: string
8 | bundleNodeModules?: boolean | string[]
9 | externals: NormalizedConfig['externals']
10 | browser: boolean
11 | }
12 |
13 | export default (options: Options) => {
14 | const plugin = require('@rollup/plugin-node-resolve').default({
15 | extensions: ['.js', '.json', '.jsx', '.ts', '.tsx'],
16 | preferBuiltins: true,
17 | mainFields: [
18 | options.browser && 'browser',
19 | 'module',
20 | 'jsnext:main',
21 | 'main',
22 | ].filter(Boolean),
23 | })
24 |
25 | return {
26 | ...plugin,
27 |
28 | name: 'bili-custom-resolve',
29 |
30 | async resolveId(importee: string, importer?: string) {
31 | const resolved = await plugin.resolveId(
32 | importee,
33 | importer || `${options.rootDir}/__no_importer__.js`
34 | )
35 | const id = resolved?.id || resolved
36 |
37 | if (typeof id === 'string') {
38 | // Exclude built-in modules
39 | if (builtinModules.includes(id)) {
40 | return false
41 | }
42 | // If we don't intend to bundle node_modules
43 | // Mark it as external
44 | if (/node_modules/.test(id)) {
45 | if (!options.bundleNodeModules) {
46 | return false
47 | }
48 | if (Array.isArray(options.bundleNodeModules)) {
49 | const shouldBundle = options.bundleNodeModules.some((name) =>
50 | id.includes(`/node_modules/${name}/`)
51 | )
52 | if (!shouldBundle) {
53 | return false
54 | }
55 | }
56 | }
57 |
58 | if (isExternal(options.externals, id, importer)) {
59 | return false
60 | }
61 |
62 | if (/node_modules/.test(id) && !/^\.?\//.test(importee)) {
63 | logger.debug(`Bundled ${importee} because ${importer} imported it.`)
64 | }
65 | }
66 |
67 | return id
68 | },
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/src/plugins/progress.ts:
--------------------------------------------------------------------------------
1 | import { Plugin } from 'rollup'
2 | import logger from '../logger'
3 |
4 | export default function ({ title }: { title: string }): Plugin {
5 | return {
6 | name: 'progress',
7 | buildStart() {
8 | logger.progress(title)
9 | },
10 | transform(code: string, id: string) {
11 | if (!process.env.CI && process.stdout.isTTY) {
12 | logger.progress(`Bundling ${id.replace(process.cwd(), '.')}`)
13 | }
14 | return null
15 | },
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/polyfills.ts:
--------------------------------------------------------------------------------
1 | // Used by ./index.ts#L488 and rollup-plugin-commonjs
2 | Object.values =
3 | Object.values ||
4 | ((obj: { [k: string]: any }) => Object.keys(obj).map(i => obj[i]))
5 |
--------------------------------------------------------------------------------
/src/resolve.ts:
--------------------------------------------------------------------------------
1 | import nodeResolve from 'resolve'
2 | import pify from 'pify'
3 |
4 | interface Options {
5 | cwd: string
6 | }
7 |
8 | const resolve = pify(nodeResolve)
9 |
10 | const cache = new Map()
11 |
12 | export default async function(id: string, options: Options) {
13 | const cacheId = `${id}::${options.cwd}`
14 |
15 | if (cache.has(cacheId)) return cache.get(cacheId)
16 |
17 | const res = await resolve(id, {
18 | basedir: options.cwd,
19 | extensions: ['.js', '.json', '.jsx', '.ts', '.tsx'],
20 | packageFilter(pkg: any) {
21 | if (pkg.module) {
22 | pkg.main = pkg.module
23 | }
24 | return pkg
25 | }
26 | })
27 |
28 | cache.set(cacheId, res)
29 |
30 | return res
31 | }
32 |
--------------------------------------------------------------------------------
/src/spinner.ts:
--------------------------------------------------------------------------------
1 | import ora from 'ora'
2 |
3 | export default ora()
4 |
--------------------------------------------------------------------------------
/src/types.ts:
--------------------------------------------------------------------------------
1 | import {
2 | ModuleFormat as RollupFormat,
3 | InputOptions,
4 | OutputOptions,
5 | Plugin as RollupPlugin
6 | } from 'rollup'
7 |
8 | import { Banner } from './utils/get-banner'
9 |
10 | type Omit = Pick>
11 | type Diff = ({ [P in T]: P } &
12 | { [P in U]: never } & { [x: string]: never })[T]
13 | type Overwrite = Pick> & U
14 |
15 | export type Format =
16 | | RollupFormat
17 | | 'cjs-min'
18 | | 'es-min'
19 | | 'esm-min'
20 | | 'umd-min'
21 | | 'iife-min'
22 | | 'amd-min'
23 | | 'system-min'
24 |
25 | export type Env = {
26 | [k: string]: string | number | boolean
27 | }
28 |
29 | export type External =
30 | | string
31 | | RegExp
32 | | ((id: string, parentId?: string) => boolean)
33 |
34 | export type Externals = Array
35 |
36 | export type ConfigEntryObject = { [entryName: string]: string }
37 |
38 | export type ExtendConfig = (
39 | config: NormalizedConfig,
40 | { format, input }: { format: Format; input: string[] | ConfigEntryObject }
41 | ) => NormalizedConfig
42 |
43 | export interface RunContext {
44 | unresolved: Set
45 | }
46 |
47 | export interface Task {
48 | title: string
49 | getConfig(context: RunContext, task: Task): Promise
50 | }
51 |
52 | export interface RollupInputConfig extends InputOptions {
53 | plugins: Array
54 | }
55 |
56 | export interface RollupOutputConfig extends OutputOptions {
57 | dir: string
58 | }
59 |
60 | export interface RollupConfig {
61 | inputConfig: RollupInputConfig
62 | outputConfig: RollupOutputConfig
63 | }
64 |
65 | export type ExtendRollupConfig = (config: RollupConfig) => RollupConfig
66 |
67 | export interface FileNameContext {
68 | format: RollupFormat
69 | minify: boolean
70 | }
71 |
72 | export type GetFileName = (
73 | context: FileNameContext,
74 | defaultFileName: string
75 | ) => string
76 |
77 | export interface BabelPresetOptions {
78 | /**
79 | * Transform `async/await` to `Promise`.
80 | * @default `true`
81 | */
82 | asyncToPromises?: boolean
83 | /**
84 | * Custom JSX pragma. If you want to use Preact, set it to `h`.
85 | */
86 | jsx?: string
87 | /**
88 | * Replace `Object.assign` with your own method.
89 | * @example `myAssign`
90 | */
91 | objectAssign?: string
92 | /**
93 | * Disable .babelrc
94 | * By default Bili reads it
95 | */
96 | babelrc?: boolean
97 | /**
98 | * Disable babel.config.js
99 | */
100 | configFile?: boolean
101 | /**
102 | * Disable babel-preset-env but still use other babel plugins
103 | * In addtional we use rollup-plugin-buble after rollup-plugin-babel
104 | */
105 | minimal?: boolean
106 | }
107 |
108 | export type OutputTarget = 'node' | 'browser'
109 |
110 | export interface ConfigOutput {
111 | /**
112 | * Output format(s). You can append `min` to the format to generate minified bundle.
113 | *
114 | * @default `cjs`
115 | * @cli `--format `
116 | */
117 | format?: Format | Format[]
118 | /**
119 | * Output directory
120 | * @default `dist`
121 | * @cli `-d, --out-dir `
122 | */
123 | dir?: string
124 | /**
125 | * Output file name
126 | *
127 | * Default value:
128 | * - `[name][min][ext]` in `cjs` and `esm` format.
129 | * - `[name][min].[format].js` in other formats.
130 | *
131 | * Placeholders:
132 | * - `[name]`: The base name of input file. (without extension)
133 | * - `[format]`: The output format. (without `-min` suffix)
134 | * - `[min]`: It will replaced by `.min` when the format ends with `-min`, otherwise it's an empty string.
135 | *
136 | * The value can also be a function which returns the fileName template,
137 | * The placeholders are also available in the return value.
138 | *
139 | * @cli `--file-name `
140 | */
141 | fileName?: string | GetFileName
142 | /**
143 | * Module name for umd bundle
144 | */
145 | moduleName?: string
146 | /**
147 | * Whether to minify output files regardless of format, using this option won't add `.min` suffix to the output file name.
148 | */
149 | minify?: boolean
150 | /**
151 | * Extract CSS into a single file.
152 | * @default `true`
153 | */
154 | extractCSS?: boolean
155 | /**
156 | * Generate source maps
157 | * @default `true` for minified bundle, `false` otherwise
158 | */
159 | sourceMap?: boolean
160 | /**
161 | * Exclude source code in source maps
162 | */
163 | sourceMapExcludeSources?: boolean
164 | /**
165 | * Output target
166 | * @default `node`
167 | * @cli `--target `
168 | */
169 | target?: OutputTarget
170 | }
171 |
172 | export interface Config {
173 | /**
174 | * Input files
175 | * @default `src/index.js`
176 | * @cli `bili [...input]`
177 | */
178 | input?: string | ConfigEntryObject | Array
179 | output?: ConfigOutput
180 | /**
181 | * Define env variables that are only available in your library code. i.e. if you have some code like this in your library.
182 | *
183 | * ```js
184 | * if (process.env.NODE_ENV === 'development') {
185 | * console.log('debug')
186 | * }
187 | * ```
188 | *
189 | * And you can run following command to replace the env variable:
190 |
191 | * ```bash
192 | * bili --env.NODE_ENV production
193 | * ```
194 | *
195 | * By default we don't add any env variables.
196 | *
197 | * @cli `--env. value`
198 | */
199 | env?: Env
200 | /**
201 | * Use Rollup plugins
202 | *
203 | * ```js
204 | * // bili.config.js
205 | * module.exports = {
206 | * plugins: {
207 | * svelte: {
208 | * // Any options for rollup-plugin-svelte
209 | * }
210 | * }
211 | * }
212 | * ```
213 | *
214 | * You can also use CLI flags to add plugins, e.g.
215 | * ```bash
216 | * bili --plugin.svelte
217 | * # with option
218 | * bili --plugin.svelte.foo bar
219 | * # Same as using `svelte: { foo: 'bar' }` in config file
220 | * ```
221 | *
222 | * @cli `--plugin. [option]`
223 | */
224 | plugins?: {
225 | [name: string]: any
226 | }
227 | /**
228 | * Defines how to resolve a plugin by name
229 | * This will override the default behavior
230 | * e.g.
231 | * ```js
232 | * {
233 | * resolvePlugins: {
234 | * replace: require('./my-fork-of-rollup-plugin-replace')
235 | * }
236 | * }
237 | * ```
238 | */
239 | resolvePlugins?: {
240 | [name: string]: any
241 | }
242 | /**
243 | * Include node modules in the bundle. Note that this is always `true` for UMD bundle.
244 | * @cli `--bundle-node-modules`
245 | */
246 | bundleNodeModules?: boolean | string[]
247 | /**
248 | * When inlining node modules
249 | * You can use this option to exclude specific modules
250 | */
251 | externals?: Externals
252 | /**
253 | * Specifies `moduleId: variableName` pairs necessary for external imports in umd/iife bundles. For example, in a case like this...
254 | *
255 | * ```js
256 | * import $ from 'jquery'
257 | * ```
258 | *
259 | * ...you can map the `jquery` module ID to the global `$` variable:
260 | *
261 | * ```js
262 | * // bili.config.js
263 | * export default {
264 | * globals: {
265 | * jquery: '$'
266 | * }
267 | * }
268 | * ```
269 | *
270 | * @cli `--global.
302 | output: Overwrite
303 | env?: Env
304 | bundleNodeModules?: boolean | string[]
305 | plugins: {
306 | [name: string]: any
307 | }
308 | resolvePlugins?: {
309 | [name: string]: any
310 | }
311 | externals: Externals
312 | globals?: {
313 | [k: string]: string
314 | }
315 | banner?: Banner
316 | babel: BabelPresetOptions
317 | extendConfig?: ExtendConfig
318 | extendRollupConfig?: ExtendRollupConfig
319 | }
320 |
321 | export interface Options {
322 | /**
323 | * Log level
324 | */
325 | logLevel?: 'verbose' | 'quiet'
326 | /**
327 | * Always show stack trace
328 | */
329 | stackTrace?: boolean
330 | /**
331 | * Use a custom config file rather than auto-loading bili.config.js
332 | */
333 | configFile?: string | boolean
334 | /**
335 | * The root directory to resolve files from
336 | * Useful for mono-repo
337 | * e.g. You can install Bili in root directory and leaf packages can use their own Bili config file:
338 | * - `bili --root-dir packages/foo`
339 | * - `bili --root-dir packages/bar`
340 | */
341 | rootDir?: string
342 | }
343 |
--------------------------------------------------------------------------------
/src/utils/get-banner.ts:
--------------------------------------------------------------------------------
1 | import stringifyAuthor from 'stringify-author'
2 |
3 | interface BannerInfo {
4 | /** Author name */
5 | name?: string
6 | /** package version */
7 | version?: string
8 | /** Author name or object */
9 | author?: any
10 | /** License name, like MIT */
11 | license?: string
12 | }
13 |
14 | export type Banner = string | BannerInfo | boolean
15 |
16 | export default (banner?: Banner, pkg?: { [k: string]: any }): string => {
17 | if (!banner || typeof banner === 'string') {
18 | return banner || ''
19 | }
20 |
21 | banner = { ...pkg, ...(banner === true ? {} : banner) }
22 |
23 | const author =
24 | typeof banner.author === 'string'
25 | ? banner.author
26 | : typeof banner.author === 'object'
27 | ? stringifyAuthor(banner.author)
28 | : ''
29 |
30 | const license = banner.license || ''
31 |
32 | return (
33 | '/*!\n' +
34 | ` * ${banner.name} v${banner.version}\n` +
35 | ` * (c) ${author || ''}\n` +
36 | (license && ` * Released under the ${license} License.\n`) +
37 | ' */'
38 | )
39 | }
40 |
--------------------------------------------------------------------------------
/src/utils/is-external.ts:
--------------------------------------------------------------------------------
1 | import slash from 'slash'
2 | import { NormalizedConfig } from '../'
3 |
4 | export default function(
5 | externals: NormalizedConfig['externals'],
6 | id: string,
7 | parentId?: string
8 | ) {
9 | id = slash(id)
10 |
11 | if (!Array.isArray(externals)) {
12 | externals = [externals] as NormalizedConfig['externals']
13 | }
14 |
15 | for (const external of externals) {
16 | if (
17 | typeof external === 'string' &&
18 | (id === external || id.includes(`/node_modules/${external}/`))
19 | ) {
20 | return true
21 | }
22 | if (external instanceof RegExp) {
23 | if (external.test(id)) {
24 | return true
25 | }
26 | }
27 | if (typeof external === 'function') {
28 | if (external(id, parentId)) {
29 | return true
30 | }
31 | }
32 | }
33 |
34 | return false
35 | }
36 |
--------------------------------------------------------------------------------
/test/__snapshots__/index.test.ts.snap:
--------------------------------------------------------------------------------
1 | // Jest Snapshot v1, https://goo.gl/fbAQLP
2 |
3 | exports[`\`@rollup/plugin-replace\` can accepts custom options: \`@rollup/plugin-replace\` can accepts custom options dist/index.js 1`] = `
4 | "'use strict';
5 |
6 | {
7 | console.log('prod');
8 | }
9 |
10 | let a = 27;
11 |
12 | {
13 | a--;
14 | }
15 |
16 | console.log(a);
17 | "
18 | `;
19 |
20 | exports[`Typescript: Typescript dist/index.js 1`] = `
21 | "'use strict';
22 |
23 | Object.defineProperty(exports, '__esModule', { value: true });
24 |
25 | function greeter(person) {
26 | return 'Hello, ' + person.firstName + ' ' + person.lastName;
27 | }
28 |
29 | let user = {
30 | firstName: 'Jane',
31 | lastName: 'User'
32 | };
33 | let s = greeter(user);
34 |
35 | exports.s = s;
36 | "
37 | `;
38 |
39 | exports[`async: async dist/index.js 1`] = `
40 | "'use strict';
41 |
42 | function _async(f) {
43 | return function () {
44 | for (var args = [], i = 0; i < arguments.length; i++) {
45 | args[i] = arguments[i];
46 | }
47 |
48 | try {
49 | return Promise.resolve(f.apply(this, args));
50 | } catch (e) {
51 | return Promise.reject(e);
52 | }
53 | };
54 | }
55 |
56 | const a = {
57 | a: 1
58 | };
59 | var index = _async(function () {
60 | return Object.assign({}, a, {
61 | b
62 | });
63 | });
64 |
65 | module.exports = index;
66 | "
67 | `;
68 |
69 | exports[`babel:disable-config: babel:disable-config dist/index.js 1`] = `
70 | "'use strict';
71 |
72 | class index {}
73 |
74 | module.exports = index;
75 | "
76 | `;
77 |
78 | exports[`babel:object-rest-spread: babel:object-rest-spread dist/index.js 1`] = `
79 | "'use strict';
80 |
81 | var index = Object.assign({}, a);
82 |
83 | module.exports = index;
84 | "
85 | `;
86 |
87 | exports[`babel:with-config: babel:with-config dist/index.js 1`] = `
88 | "'use strict';
89 |
90 | class index {}
91 |
92 | module.exports = index;
93 | "
94 | `;
95 |
96 | exports[`banner:object: banner:object dist/default.js 1`] = `
97 | "/*!
98 | * name v1.2.3
99 | * (c) author
100 | * Released under the GPL License.
101 | */
102 | 'use strict';
103 |
104 | var _default = {};
105 |
106 | module.exports = _default;
107 | "
108 | `;
109 |
110 | exports[`banner:string: banner:string dist/default.js 1`] = `
111 | "woot
112 | 'use strict';
113 |
114 | var _default = {};
115 |
116 | module.exports = _default;
117 | "
118 | `;
119 |
120 | exports[`banner:true default: banner:true default dist/index.js 1`] = `
121 | "/*!
122 | * foo v0.0.0
123 | * (c) name
124 | * Released under the MIT License.
125 | */
126 | 'use strict';
127 |
128 | var index = 42;
129 |
130 | module.exports = index;
131 | "
132 | `;
133 |
134 | exports[`bundle-node-modules: bundle-node-modules dist/index.js 1`] = `
135 | "'use strict';
136 |
137 | function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
138 |
139 | var all = _interopDefault(require('some-package-that-does-not-exists'));
140 |
141 | var pokemon = ['pikachu'];
142 |
143 | var index = {
144 | all,
145 | pokemon
146 | };
147 |
148 | module.exports = index;
149 | "
150 | `;
151 |
152 | exports[`custom rollup plugin: custom rollup plugin dist/index.js 1`] = `
153 | "'use strict';
154 |
155 | Object.defineProperty(exports, '__esModule', { value: true });
156 |
157 | const tt = 'is there anything?';
158 |
159 | function afun() {
160 | return tt;
161 | }
162 |
163 | function another() {
164 | return afun();
165 | }
166 |
167 | exports.another = another;
168 | "
169 | `;
170 |
171 | exports[`custom scoped rollup plugin: custom scoped rollup plugin dist/index.js 1`] = `
172 | "'use strict';
173 |
174 | Object.defineProperty(exports, '__esModule', { value: true });
175 |
176 | const tt = 'is there anything?';
177 |
178 | function afun() {
179 | return tt;
180 | }
181 |
182 | function another() {
183 | return afun();
184 | }
185 |
186 | exports.another = another;
187 | "
188 | `;
189 |
190 | exports[`defaults: defaults dist/index.js 1`] = `
191 | "'use strict';
192 |
193 | var index = 42;
194 |
195 | module.exports = index;
196 | "
197 | `;
198 |
199 | exports[`exclude file: exclude file dist/index.js 1`] = `
200 | "'use strict';
201 |
202 | var foo = 'foo';
203 |
204 | module.exports = foo;
205 | "
206 | `;
207 |
208 | exports[`extendOptions: extendOptions dist/bar.js 1`] = `
209 | "'use strict';
210 |
211 | var bar = 'bar';
212 |
213 | module.exports = bar;
214 | "
215 | `;
216 |
217 | exports[`extendOptions: extendOptions dist/bar.umd.js 1`] = `
218 | "(function (global, factory) {
219 | typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
220 | typeof define === 'function' && define.amd ? define(factory) :
221 | (global = global || self, global.umd = factory());
222 | }(this, (function () { 'use strict';
223 |
224 | var bar = 'bar';
225 |
226 | return bar;
227 |
228 | })));
229 | "
230 | `;
231 |
232 | exports[`extendOptions: extendOptions dist/bar.umd.min.js 1`] = `
233 | "!function(e,n){\\"object\\"==typeof exports&&\\"undefined\\"!=typeof module?module.exports=n():\\"function\\"==typeof define&&define.amd?define(n):(e=e||self).min=n()}(this,(function(){\\"use strict\\";return\\"bar\\"}));
234 | "
235 | `;
236 |
237 | exports[`extendOptions: extendOptions dist/foo.js 1`] = `
238 | "'use strict';
239 |
240 | var foo = 'foo';
241 |
242 | module.exports = foo;
243 | "
244 | `;
245 |
246 | exports[`extendOptions: extendOptions dist/foo.umd.js 1`] = `
247 | "(function (global, factory) {
248 | typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
249 | typeof define === 'function' && define.amd ? define(factory) :
250 | (global = global || self, global.umd = factory());
251 | }(this, (function () { 'use strict';
252 |
253 | var foo = 'foo';
254 |
255 | return foo;
256 |
257 | })));
258 | "
259 | `;
260 |
261 | exports[`extendOptions: extendOptions dist/foo.umd.min.js 1`] = `
262 | "!function(e,n){\\"object\\"==typeof exports&&\\"undefined\\"!=typeof module?module.exports=n():\\"function\\"==typeof define&&define.amd?define(n):(e=e||self).min=n()}(this,(function(){\\"use strict\\";return\\"foo\\"}));
263 | "
264 | `;
265 |
266 | exports[`inline-certain-modules: inline-certain-modules dist/index.js 1`] = `
267 | "'use strict';
268 |
269 | require('another-module');
270 |
271 | var fakeModule = a => a;
272 |
273 | var index = fakeModule(1);
274 |
275 | module.exports = index;
276 | "
277 | `;
278 |
279 | exports[`target:browser: target:browser dist/index.js 1`] = `
280 | "'use strict';
281 |
282 | var foo = 'browser';
283 |
284 | module.exports = foo;
285 | "
286 | `;
287 |
288 | exports[`uglify: uglify dist/index.min.js 1`] = `
289 | "\\"use strict\\";Object.defineProperty(exports,\\"__esModule\\",{value:!0});exports.a=1;
290 | "
291 | `;
292 |
293 | exports[`umd and iife should drop process.env.NODE_ENV: umd and iife should drop process.env.NODE_ENV dist/index.iife.js 1`] = `
294 | "var dropNodeEnv = (function (exports) {
295 | 'use strict';
296 |
297 | exports.a = '';
298 | exports.b = '';
299 |
300 | {
301 | exports.a = 'live in dev';
302 | }
303 |
304 | {
305 | exports.b = 'live in dev';
306 | }
307 |
308 | return exports;
309 |
310 | }({}));
311 | "
312 | `;
313 |
314 | exports[`umd and iife should drop process.env.NODE_ENV: umd and iife should drop process.env.NODE_ENV dist/index.iife.min.js 1`] = `
315 | "var dropNodeEnv=function(r){\\"use strict\\";return r.a=\\"\\",r.b=\\"\\",r.a=\\"live in prod\\",r.b=\\"live in prod\\",r}({});
316 | "
317 | `;
318 |
319 | exports[`umd and iife should drop process.env.NODE_ENV: umd and iife should drop process.env.NODE_ENV dist/index.umd.js 1`] = `
320 | "(function (global, factory) {
321 | typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
322 | typeof define === 'function' && define.amd ? define(['exports'], factory) :
323 | (global = global || self, factory(global.dropNodeEnv = {}));
324 | }(this, (function (exports) { 'use strict';
325 |
326 | exports.a = '';
327 | exports.b = '';
328 |
329 | {
330 | exports.a = 'live in dev';
331 | }
332 |
333 | {
334 | exports.b = 'live in dev';
335 | }
336 |
337 | Object.defineProperty(exports, '__esModule', { value: true });
338 |
339 | })));
340 | "
341 | `;
342 |
343 | exports[`umd and iife should drop process.env.NODE_ENV: umd and iife should drop process.env.NODE_ENV dist/index.umd.min.js 1`] = `
344 | "!function(e,o){\\"object\\"==typeof exports&&\\"undefined\\"!=typeof module?o(exports):\\"function\\"==typeof define&&define.amd?define([\\"exports\\"],o):o((e=e||self).dropNodeEnv={})}(this,(function(e){\\"use strict\\";e.a=\\"\\",e.b=\\"\\",e.a=\\"live in prod\\",e.b=\\"live in prod\\",Object.defineProperty(e,\\"__esModule\\",{value:!0})}));
345 | "
346 | `;
347 |
348 | exports[`umd and iife should preserve existing env.NODE_ENV: umd and iife should preserve existing env.NODE_ENV dist/index.iife.js 1`] = `
349 | "var dropNodeEnv = (function (exports) {
350 | 'use strict';
351 |
352 | exports.a = '';
353 | exports.b = '';
354 |
355 | {
356 | exports.a = 'live in prod';
357 | }
358 |
359 | {
360 | exports.b = 'live in prod';
361 | }
362 |
363 | return exports;
364 |
365 | }({}));
366 | "
367 | `;
368 |
369 | exports[`umd and iife should preserve existing env.NODE_ENV: umd and iife should preserve existing env.NODE_ENV dist/index.iife.min.js 1`] = `
370 | "var dropNodeEnv=function(r){\\"use strict\\";return r.a=\\"\\",r.b=\\"\\",r.a=\\"live in prod\\",r.b=\\"live in prod\\",r}({});
371 | "
372 | `;
373 |
374 | exports[`umd and iife should preserve existing env.NODE_ENV: umd and iife should preserve existing env.NODE_ENV dist/index.umd.js 1`] = `
375 | "(function (global, factory) {
376 | typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
377 | typeof define === 'function' && define.amd ? define(['exports'], factory) :
378 | (global = global || self, factory(global.dropNodeEnv = {}));
379 | }(this, (function (exports) { 'use strict';
380 |
381 | exports.a = '';
382 | exports.b = '';
383 |
384 | {
385 | exports.a = 'live in prod';
386 | }
387 |
388 | {
389 | exports.b = 'live in prod';
390 | }
391 |
392 | Object.defineProperty(exports, '__esModule', { value: true });
393 |
394 | })));
395 | "
396 | `;
397 |
398 | exports[`umd and iife should preserve existing env.NODE_ENV: umd and iife should preserve existing env.NODE_ENV dist/index.umd.min.js 1`] = `
399 | "!function(e,o){\\"object\\"==typeof exports&&\\"undefined\\"!=typeof module?o(exports):\\"function\\"==typeof define&&define.amd?define([\\"exports\\"],o):o((e=e||self).dropNodeEnv={})}(this,(function(e){\\"use strict\\";e.a=\\"\\",e.b=\\"\\",e.a=\\"live in prod\\",e.b=\\"live in prod\\",Object.defineProperty(e,\\"__esModule\\",{value:!0})}));
400 | "
401 | `;
402 |
403 | exports[`vue plugin: vue plugin dist/component.css 1`] = `
404 | "
405 | .main-content[data-v-5fccef39]{margin:0 auto;font-family:sans-serif;background-color:#ccf7e2;padding:10px;border-radius:5px;max-width:500px
406 | }"
407 | `;
408 |
409 | exports[`vue plugin: vue plugin dist/component.js 1`] = `
410 | "'use strict';
411 |
412 | function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
413 |
414 | var __vue_normalize__ = _interopDefault(require('vue-runtime-helpers/dist/normalize-component.js'));
415 |
416 | //
417 | //
418 | //
419 | //
420 | //
421 | //
422 | //
423 | var script = {
424 | name: 'main-content',
425 | data: () => ({
426 | name: 'Bili !'
427 | })
428 | };
429 |
430 | /* script */
431 | const __vue_script__ = script; // For security concerns, we use only base name in production mode. See https://github.com/vuejs/rollup-plugin-vue/issues/258
432 |
433 | script.__file = \\"component.vue\\";
434 | /* template */
435 |
436 | var __vue_render__ = function () {
437 | var _vm = this;
438 |
439 | var _h = _vm.$createElement;
440 |
441 | var _c = _vm._self._c || _h;
442 |
443 | return _c('div', {
444 | staticClass: \\"main-content\\"
445 | }, [_c('h1', [_vm._v(\\"This is your first component in Vue\\")]), _vm._v(\\" \\"), _c('h3', [_vm._v(_vm._s(_vm.name))])]);
446 | };
447 |
448 | var __vue_staticRenderFns__ = [];
449 | /* style */
450 |
451 | const __vue_inject_styles__ = undefined;
452 | /* scoped */
453 |
454 | const __vue_scope_id__ = \\"data-v-5fccef39\\";
455 | /* module identifier */
456 |
457 | const __vue_module_identifier__ = undefined;
458 | /* functional template */
459 |
460 | const __vue_is_functional_template__ = false;
461 | /* style inject */
462 |
463 | /* style inject SSR */
464 |
465 | var component = __vue_normalize__({
466 | render: __vue_render__,
467 | staticRenderFns: __vue_staticRenderFns__
468 | }, __vue_inject_styles__, __vue_script__, __vue_scope_id__, __vue_is_functional_template__, __vue_module_identifier__, undefined, undefined);
469 |
470 | module.exports = component;
471 | "
472 | `;
473 |
--------------------------------------------------------------------------------
/test/demo/index.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 | import cac from 'cac'
3 |
4 | class Foo {
5 | async foo() {}
6 | }
7 |
8 | console.log(cac())
9 |
--------------------------------------------------------------------------------
/test/fixtures/async/index.js:
--------------------------------------------------------------------------------
1 | const a = { a: 1 }
2 |
3 | export default async () => {
4 | return { ...a, b }
5 | }
6 |
--------------------------------------------------------------------------------
/test/fixtures/babel/object-rest-spread/index.js:
--------------------------------------------------------------------------------
1 | export default {
2 | ...a
3 | }
4 |
--------------------------------------------------------------------------------
/test/fixtures/babel/with-config/.babelrc:
--------------------------------------------------------------------------------
1 | {}
2 |
--------------------------------------------------------------------------------
/test/fixtures/babel/with-config/index.js:
--------------------------------------------------------------------------------
1 | export default class {}
2 |
--------------------------------------------------------------------------------
/test/fixtures/banner/default/index.js:
--------------------------------------------------------------------------------
1 | export default 42
2 |
--------------------------------------------------------------------------------
/test/fixtures/banner/default/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "foo",
3 | "version": "0.0.0",
4 | "license": "MIT",
5 | "author": {
6 | "name": "name",
7 | "email": "email@email.com"
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/test/fixtures/buble/async-dot-dot-dot.js:
--------------------------------------------------------------------------------
1 | export default async function() {
2 | return {
3 | ...(await this.bar())
4 | }
5 | }
6 |
--------------------------------------------------------------------------------
/test/fixtures/buble/async.js:
--------------------------------------------------------------------------------
1 | const a = async () => ({ a: 'a' })
2 |
3 | export default a().then(res => ({ ...res }))
4 |
--------------------------------------------------------------------------------
/test/fixtures/buble/react-jsx.js:
--------------------------------------------------------------------------------
1 | export default hi
2 |
--------------------------------------------------------------------------------
/test/fixtures/buble/vue-jsx.js:
--------------------------------------------------------------------------------
1 | export default {
2 | render() {
3 | return hi
4 | }
5 | }
6 |
--------------------------------------------------------------------------------
/test/fixtures/bundle-node-modules/index.js:
--------------------------------------------------------------------------------
1 | import all from 'some-package-that-does-not-exists'
2 | import pokemon from 'pokemon'
3 |
4 | export default { all, pokemon }
5 |
--------------------------------------------------------------------------------
/test/fixtures/bundle-node-modules/node_modules/pokemon.js:
--------------------------------------------------------------------------------
1 | module.exports = ['pikachu']
2 |
--------------------------------------------------------------------------------
/test/fixtures/custom-rollup-plugin/index.js:
--------------------------------------------------------------------------------
1 | const data = { foo: 'bar' }
2 |
3 | const tt = 'is there anything?'
4 |
5 | function afun() {
6 | console.log('test')
7 | return tt
8 | }
9 |
10 | export function another() {
11 | console.log('two')
12 | return afun()
13 | }
14 |
--------------------------------------------------------------------------------
/test/fixtures/custom-scoped-rollup-plugin/index.js:
--------------------------------------------------------------------------------
1 | const data = { foo: 'bar' }
2 |
3 | const tt = 'is there anything?'
4 |
5 | function afun() {
6 | console.log('test')
7 | return tt
8 | }
9 |
10 | export function another() {
11 | console.log('two')
12 | return afun()
13 | }
14 |
--------------------------------------------------------------------------------
/test/fixtures/custom-scoped-rollup-plugin/replace/index.js:
--------------------------------------------------------------------------------
1 | const data = { foo: 'bar' }
2 |
3 | if (process.env.NODE_ENV === 'production') {
4 | console.log('prod')
5 | } else {
6 | console.log('dev')
7 | }
8 |
9 | let a = 27
10 |
11 | if (process.env.NODE_ENV === 'development') {
12 | a++
13 | } else {
14 | a--
15 | }
16 |
17 | console.log(a)
18 |
--------------------------------------------------------------------------------
/test/fixtures/default.js:
--------------------------------------------------------------------------------
1 | export default {}
2 |
--------------------------------------------------------------------------------
/test/fixtures/defaults/index.js:
--------------------------------------------------------------------------------
1 | export default 42
2 |
--------------------------------------------------------------------------------
/test/fixtures/exclude-file/foo.js:
--------------------------------------------------------------------------------
1 | export default 'foo'
2 |
--------------------------------------------------------------------------------
/test/fixtures/exclude-file/index.js:
--------------------------------------------------------------------------------
1 | import foo from './foo'
2 |
3 | export default foo
4 |
--------------------------------------------------------------------------------
/test/fixtures/extend-options/bar.js:
--------------------------------------------------------------------------------
1 | export default 'bar'
2 |
--------------------------------------------------------------------------------
/test/fixtures/extend-options/foo.js:
--------------------------------------------------------------------------------
1 | export default 'foo'
2 |
--------------------------------------------------------------------------------
/test/fixtures/format/index.js:
--------------------------------------------------------------------------------
1 | let a = ''
2 | let b = ''
3 |
4 | if (process.env.NODE_ENV === 'development') {
5 | a = 'live in dev'
6 | } else {
7 | a = 'live in prod'
8 | }
9 |
10 | if (process.env.NODE_ENV === 'production') {
11 | b = 'live in prod'
12 | } else {
13 | b = 'live in dev'
14 | }
15 |
16 | export { a, b }
17 |
--------------------------------------------------------------------------------
/test/fixtures/inline-certain-modules/index.js:
--------------------------------------------------------------------------------
1 | import foo from 'fake-module'
2 | import another from 'another-module'
3 |
4 | export default foo(1, another)
5 |
--------------------------------------------------------------------------------
/test/fixtures/inline-certain-modules/node_modules/another-module/index.js:
--------------------------------------------------------------------------------
1 | module.exports = 42
2 |
--------------------------------------------------------------------------------
/test/fixtures/inline-certain-modules/node_modules/fake-module/index.js:
--------------------------------------------------------------------------------
1 | module.exports = a => a
--------------------------------------------------------------------------------
/test/fixtures/input/empty/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/egoist/bili/843a77ba327238cefe120d5a2f695b554c83a761/test/fixtures/input/empty/.gitkeep
--------------------------------------------------------------------------------
/test/fixtures/input/index/src/index.js:
--------------------------------------------------------------------------------
1 | export default 42
2 |
--------------------------------------------------------------------------------
/test/fixtures/no-js-transform/index.js:
--------------------------------------------------------------------------------
1 | export default () => {}
2 |
--------------------------------------------------------------------------------
/test/fixtures/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "private": true,
3 | "dependencies": {
4 | "@rollup/plugin-strip": "^1.3.2",
5 | "rollup-plugin-prettier": "^0.5.0",
6 | "rollup-plugin-strip": "^1.2.0",
7 | "rollup-plugin-typescript2": "^0.18.0",
8 | "rollup-plugin-vue": "^4.6.2",
9 | "typescript": "^3.1.6",
10 | "vue-template-compiler": "^2.5.17"
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/test/fixtures/prettier/index.js:
--------------------------------------------------------------------------------
1 | export const a = 1
2 | export let d = 'double stringh'
3 | export function done() {
4 | const t = {
5 | prop: 343,
6 | another: 782
7 | }
8 | return t
9 | }
10 |
--------------------------------------------------------------------------------
/test/fixtures/prettier/yarn.lock:
--------------------------------------------------------------------------------
1 | # THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2 | # yarn lockfile v1
3 |
4 |
5 | diff@3.5.0:
6 | version "3.5.0"
7 | resolved "https://registry.yarnpkg.com/diff/-/diff-3.5.0.tgz#800c0dd1e0a8bfbc95835c202ad220fe317e5a12"
8 | integrity sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==
9 |
10 | lodash.isempty@4.4.0:
11 | version "4.4.0"
12 | resolved "https://registry.yarnpkg.com/lodash.isempty/-/lodash.isempty-4.4.0.tgz#6f86cbedd8be4ec987be9aaf33c9684db1b31e7e"
13 | integrity sha1-b4bL7di+TsmHvpqvM8loTbGzHn4=
14 |
15 | lodash.omitby@4.6.0:
16 | version "4.6.0"
17 | resolved "https://registry.yarnpkg.com/lodash.omitby/-/lodash.omitby-4.6.0.tgz#5c15ff4754ad555016b53c041311e8f079204791"
18 | integrity sha1-XBX/R1StVVAWtTwEExHo8HkgR5E=
19 |
20 | magic-string@0.25.1:
21 | version "0.25.1"
22 | resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.25.1.tgz#b1c248b399cd7485da0fe7385c2fc7011843266e"
23 | integrity sha512-sCuTz6pYom8Rlt4ISPFn6wuFodbKMIHUMv4Qko9P17dpxb7s52KJTmRuZZqHdGmLCK9AOcDare039nRIcfdkEg==
24 | dependencies:
25 | sourcemap-codec "^1.4.1"
26 |
27 | prettier@^1.0.0:
28 | version "1.15.2"
29 | resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.15.2.tgz#d31abe22afa4351efa14c7f8b94b58bb7452205e"
30 | integrity sha512-YgPLFFA0CdKL4Eg2IHtUSjzj/BWgszDHiNQAe0VAIBse34148whfdzLagRL+QiKS+YfK5ftB6X4v/MBw8yCoug==
31 |
32 | rollup-plugin-prettier@^0.5.0:
33 | version "0.5.0"
34 | resolved "https://registry.yarnpkg.com/rollup-plugin-prettier/-/rollup-plugin-prettier-0.5.0.tgz#25950b990a8f521206d44ee911486229b91a86bf"
35 | integrity sha512-F00UUEShD6J9s96yLPSajLyAI0IRjysbsHUpw4laJMisvdLb7llsLdm88gPKAZSykqgU97GF0S6btSflSruuyg==
36 | dependencies:
37 | diff "3.5.0"
38 | lodash.isempty "4.4.0"
39 | lodash.omitby "4.6.0"
40 | magic-string "0.25.1"
41 | prettier "^1.0.0"
42 |
43 | sourcemap-codec@^1.4.1:
44 | version "1.4.3"
45 | resolved "https://registry.yarnpkg.com/sourcemap-codec/-/sourcemap-codec-1.4.3.tgz#0ba615b73ec35112f63c2f2d9e7c3f87282b0e33"
46 | integrity sha512-vFrY/x/NdsD7Yc8mpTJXuao9S8lq08Z/kOITHz6b7YbfI9xL8Spe5EvSQUHOI7SbpY8bRPr0U3kKSsPuqEGSfA==
47 |
--------------------------------------------------------------------------------
/test/fixtures/target/browser/foo-browser.js:
--------------------------------------------------------------------------------
1 | export default 'browser'
2 |
--------------------------------------------------------------------------------
/test/fixtures/target/browser/index.js:
--------------------------------------------------------------------------------
1 | import foo from './foo'
2 |
3 | export default foo
4 |
--------------------------------------------------------------------------------
/test/fixtures/target/browser/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "browser": {
3 | "./foo.js": "./foo-browser.js"
4 | }
5 | }
6 |
--------------------------------------------------------------------------------
/test/fixtures/target/node/index.js:
--------------------------------------------------------------------------------
1 | export default class Foo {}
2 |
--------------------------------------------------------------------------------
/test/fixtures/typescript/index.ts:
--------------------------------------------------------------------------------
1 | interface Person {
2 | firstName: string
3 | lastName: string
4 | }
5 |
6 | function greeter(person: Person) {
7 | return 'Hello, ' + person.firstName + ' ' + person.lastName
8 | }
9 |
10 | let user = { firstName: 'Jane', lastName: 'User' }
11 |
12 | export let s = greeter(user)
13 |
--------------------------------------------------------------------------------
/test/fixtures/uglify/index.js:
--------------------------------------------------------------------------------
1 | export const a = 1
2 |
--------------------------------------------------------------------------------
/test/fixtures/vue/component.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
This is your first component in Vue
4 | {{ name }}
5 |
6 |
7 |
8 |
16 |
17 |
27 |
--------------------------------------------------------------------------------
/test/fixtures/yarn.lock:
--------------------------------------------------------------------------------
1 | # THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2 | # yarn lockfile v1
3 |
4 |
5 | "@rollup/plugin-strip@^1.3.2":
6 | version "1.3.2"
7 | resolved "https://registry.npmjs.org/@rollup/plugin-strip/-/plugin-strip-1.3.2.tgz#9f52e99add99b835a4a3c14e02385f3726514923"
8 | integrity sha512-dByULCvYdklJRJ50XqmA/ntyvVuVnnxOrgZ6cIIMBLLzQrsm9Ui15VD+6I8a11w8Ob9R7ySwYjFck9YCMzseKA==
9 | dependencies:
10 | "@rollup/pluginutils" "^3.0.4"
11 | estree-walker "^1.0.1"
12 | magic-string "^0.25.5"
13 |
14 | "@rollup/pluginutils@^3.0.4":
15 | version "3.0.8"
16 | resolved "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-3.0.8.tgz#4e94d128d94b90699e517ef045422960d18c8fde"
17 | integrity sha512-rYGeAc4sxcZ+kPG/Tw4/fwJODC3IXHYDH4qusdN/b6aLw5LPUbzpecYbEJh4sVQGPFJxd2dBU4kc1H3oy9/bnw==
18 | dependencies:
19 | estree-walker "^1.0.1"
20 |
21 | "@vue/component-compiler-utils@^2.1.0":
22 | version "2.3.0"
23 | resolved "https://registry.yarnpkg.com/@vue/component-compiler-utils/-/component-compiler-utils-2.3.0.tgz#4f580f1b28fc7685859d87ea0e92a1c0271c93da"
24 | integrity sha512-4RB1mow8IO2X0/86plKhflMJYSiSn3sWHiqVob8s/LCADFMHSaFRTQp5GdqvjvlGmwjhdn2dzDQik+RLjTx/5g==
25 | dependencies:
26 | consolidate "^0.15.1"
27 | hash-sum "^1.0.2"
28 | lru-cache "^4.1.2"
29 | merge-source-map "^1.1.0"
30 | postcss "^6.0.20"
31 | postcss-selector-parser "^3.1.1"
32 | prettier "1.13.7"
33 | source-map "^0.5.6"
34 | vue-template-es2015-compiler "^1.6.0"
35 |
36 | "@vue/component-compiler@^3.6":
37 | version "3.6.0"
38 | resolved "https://registry.npmjs.org/@vue/component-compiler/-/component-compiler-3.6.0.tgz#8db313e50eaa2903cef5aac68c37a09364dba79d"
39 | integrity sha512-NIA0vmOI4zbtJAn69iZls8IJ8VxmguswAuiUdu8TcR+YYTYzntfw290HUCSFjzAdRg+FUWZv8r+wc3TzJ/IjwA==
40 | dependencies:
41 | "@vue/component-compiler-utils" "^2.1.0"
42 | clean-css "^4.1.11"
43 | hash-sum "^1.0.2"
44 | postcss-modules-sync "^1.0.0"
45 | source-map "0.6.*"
46 |
47 | ansi-regex@^2.0.0:
48 | version "2.1.1"
49 | resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-2.1.1.tgz#c3b33ab5ee360d86e0e628f0468ae7ef27d654df"
50 | integrity sha1-w7M6te42DYbg5ijwRorn7yfWVN8=
51 |
52 | ansi-styles@^2.2.1:
53 | version "2.2.1"
54 | resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-2.2.1.tgz#b432dd3358b634cf75e1e4664368240533c1ddbe"
55 | integrity sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=
56 |
57 | ansi-styles@^3.2.1:
58 | version "3.2.1"
59 | resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d"
60 | integrity sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==
61 | dependencies:
62 | color-convert "^1.9.0"
63 |
64 | arr-diff@^2.0.0:
65 | version "2.0.0"
66 | resolved "https://registry.yarnpkg.com/arr-diff/-/arr-diff-2.0.0.tgz#8f3b827f955a8bd669697e4a4256ac3ceae356cf"
67 | integrity sha1-jzuCf5Vai9ZpaX5KQlasPOrjVs8=
68 | dependencies:
69 | arr-flatten "^1.0.1"
70 |
71 | arr-flatten@^1.0.1:
72 | version "1.1.0"
73 | resolved "https://registry.yarnpkg.com/arr-flatten/-/arr-flatten-1.1.0.tgz#36048bbff4e7b47e136644316c99669ea5ae91f1"
74 | integrity sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==
75 |
76 | array-unique@^0.2.1:
77 | version "0.2.1"
78 | resolved "https://registry.yarnpkg.com/array-unique/-/array-unique-0.2.1.tgz#a1d97ccafcbc2625cc70fadceb36a50c58b01a53"
79 | integrity sha1-odl8yvy8JiXMcPrc6zalDFiwGlM=
80 |
81 | big.js@^3.1.3:
82 | version "3.2.0"
83 | resolved "https://registry.yarnpkg.com/big.js/-/big.js-3.2.0.tgz#a5fc298b81b9e0dca2e458824784b65c52ba588e"
84 | integrity sha512-+hN/Zh2D08Mx65pZ/4g5bsmNiZUuChDiQfTUQ7qJr4/kuopCr88xZsAXv6mBoZEsUI4OuGHlX59qE94K2mMW8Q==
85 |
86 | bluebird@^3.1.1:
87 | version "3.5.3"
88 | resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.5.3.tgz#7d01c6f9616c9a51ab0f8c549a79dfe6ec33efa7"
89 | integrity sha512-/qKPUQlaW1OyR51WeCPBvRnAlnZFUJkCSG5HzGnuIqhgyJtF+T94lFnn33eiazjRm2LAHVy2guNnaq48X9SJuw==
90 |
91 | braces@^1.8.2:
92 | version "1.8.5"
93 | resolved "https://registry.yarnpkg.com/braces/-/braces-1.8.5.tgz#ba77962e12dff969d6b76711e914b737857bf6a7"
94 | integrity sha1-uneWLhLf+WnWt2cR6RS3N4V79qc=
95 | dependencies:
96 | expand-range "^1.8.1"
97 | preserve "^0.2.0"
98 | repeat-element "^1.1.2"
99 |
100 | chalk@^1.1.3:
101 | version "1.1.3"
102 | resolved "https://registry.yarnpkg.com/chalk/-/chalk-1.1.3.tgz#a8115c55e4a702fe4d150abd3872822a7e09fc98"
103 | integrity sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=
104 | dependencies:
105 | ansi-styles "^2.2.1"
106 | escape-string-regexp "^1.0.2"
107 | has-ansi "^2.0.0"
108 | strip-ansi "^3.0.0"
109 | supports-color "^2.0.0"
110 |
111 | chalk@^2.4.1:
112 | version "2.4.1"
113 | resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.1.tgz#18c49ab16a037b6eb0152cc83e3471338215b66e"
114 | integrity sha512-ObN6h1v2fTJSmUXoS3nMQ92LbDK9be4TV+6G+omQlGJFdcUX5heKi1LZ1YnRMIgwTLEj3E24bT6tYni50rlCfQ==
115 | dependencies:
116 | ansi-styles "^3.2.1"
117 | escape-string-regexp "^1.0.5"
118 | supports-color "^5.3.0"
119 |
120 | clean-css@^4.1.11:
121 | version "4.2.1"
122 | resolved "https://registry.yarnpkg.com/clean-css/-/clean-css-4.2.1.tgz#2d411ef76b8569b6d0c84068dabe85b0aa5e5c17"
123 | integrity sha512-4ZxI6dy4lrY6FHzfiy1aEOXgu4LIsW2MhwG0VBKdcoGoH/XLFgaHSdLTGr4O8Be6A8r3MOphEiI8Gc1n0ecf3g==
124 | dependencies:
125 | source-map "~0.6.0"
126 |
127 | color-convert@^1.9.0:
128 | version "1.9.3"
129 | resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8"
130 | integrity sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==
131 | dependencies:
132 | color-name "1.1.3"
133 |
134 | color-name@1.1.3:
135 | version "1.1.3"
136 | resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25"
137 | integrity sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=
138 |
139 | consolidate@^0.15.1:
140 | version "0.15.1"
141 | resolved "https://registry.yarnpkg.com/consolidate/-/consolidate-0.15.1.tgz#21ab043235c71a07d45d9aad98593b0dba56bab7"
142 | integrity sha512-DW46nrsMJgy9kqAbPt5rKaCr7uFtpo4mSUvLHIUbJEjm0vo+aY5QLwBUq3FK4tRnJr/X0Psc0C4jf/h+HtXSMw==
143 | dependencies:
144 | bluebird "^3.1.1"
145 |
146 | css-selector-tokenizer@^0.7.0:
147 | version "0.7.1"
148 | resolved "https://registry.yarnpkg.com/css-selector-tokenizer/-/css-selector-tokenizer-0.7.1.tgz#a177271a8bca5019172f4f891fc6eed9cbf68d5d"
149 | integrity sha512-xYL0AMZJ4gFzJQsHUKa5jiWWi2vH77WVNg7JYRyewwj6oPh4yb/y6Y9ZCw9dsj/9UauMhtuxR+ogQd//EdEVNA==
150 | dependencies:
151 | cssesc "^0.1.0"
152 | fastparse "^1.1.1"
153 | regexpu-core "^1.0.0"
154 |
155 | cssesc@^0.1.0:
156 | version "0.1.0"
157 | resolved "https://registry.yarnpkg.com/cssesc/-/cssesc-0.1.0.tgz#c814903e45623371a0477b40109aaafbeeaddbb4"
158 | integrity sha1-yBSQPkViM3GgR3tAEJqq++6t27Q=
159 |
160 | de-indent@^1.0.2:
161 | version "1.0.2"
162 | resolved "https://registry.yarnpkg.com/de-indent/-/de-indent-1.0.2.tgz#b2038e846dc33baa5796128d0804b455b8c1e21d"
163 | integrity sha1-sgOOhG3DO6pXlhKNCAS0VbjB4h0=
164 |
165 | debug@^4.1.1:
166 | version "4.1.1"
167 | resolved "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz#3b72260255109c6b589cee050f1d516139664791"
168 | integrity sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==
169 | dependencies:
170 | ms "^2.1.1"
171 |
172 | diff@3.5.0:
173 | version "3.5.0"
174 | resolved "https://registry.yarnpkg.com/diff/-/diff-3.5.0.tgz#800c0dd1e0a8bfbc95835c202ad220fe317e5a12"
175 | integrity sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==
176 |
177 | dot-prop@^4.1.1:
178 | version "4.2.0"
179 | resolved "https://registry.yarnpkg.com/dot-prop/-/dot-prop-4.2.0.tgz#1f19e0c2e1aa0e32797c49799f2837ac6af69c57"
180 | integrity sha512-tUMXrxlExSW6U2EXiiKGSBVdYgtV8qlHL+C10TsW4PURY/ic+eaysnSkwB4kA/mBlCyy/IKDJ+Lc3wbWeaXtuQ==
181 | dependencies:
182 | is-obj "^1.0.0"
183 |
184 | emojis-list@^2.0.0:
185 | version "2.1.0"
186 | resolved "https://registry.yarnpkg.com/emojis-list/-/emojis-list-2.1.0.tgz#4daa4d9db00f9819880c79fa457ae5b09a1fd389"
187 | integrity sha1-TapNnbAPmBmIDHn6RXrlsJof04k=
188 |
189 | escape-string-regexp@^1.0.2, escape-string-regexp@^1.0.5:
190 | version "1.0.5"
191 | resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4"
192 | integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=
193 |
194 | estree-walker@^0.5.2:
195 | version "0.5.2"
196 | resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-0.5.2.tgz#d3850be7529c9580d815600b53126515e146dd39"
197 | integrity sha512-XpCnW/AE10ws/kDAs37cngSkvgIR8aN3G0MS85m7dUpuK2EREo9VJ00uvw6Dg/hXEpfsE1I1TvJOJr+Z+TL+ig==
198 |
199 | estree-walker@^1.0.1:
200 | version "1.0.1"
201 | resolved "https://registry.npmjs.org/estree-walker/-/estree-walker-1.0.1.tgz#31bc5d612c96b704106b477e6dd5d8aa138cb700"
202 | integrity sha512-1fMXF3YP4pZZVozF8j/ZLfvnR8NSIljt56UhbZ5PeeDmmGHpgpdwQt7ITlGvYaQukCvuBRMLEiKiYC+oeIg4cg==
203 |
204 | expand-brackets@^0.1.4:
205 | version "0.1.5"
206 | resolved "https://registry.yarnpkg.com/expand-brackets/-/expand-brackets-0.1.5.tgz#df07284e342a807cd733ac5af72411e581d1177b"
207 | integrity sha1-3wcoTjQqgHzXM6xa9yQR5YHRF3s=
208 | dependencies:
209 | is-posix-bracket "^0.1.0"
210 |
211 | expand-range@^1.8.1:
212 | version "1.8.2"
213 | resolved "https://registry.yarnpkg.com/expand-range/-/expand-range-1.8.2.tgz#a299effd335fe2721ebae8e257ec79644fc85337"
214 | integrity sha1-opnv/TNf4nIeuujiV+x5ZE/IUzc=
215 | dependencies:
216 | fill-range "^2.1.0"
217 |
218 | extglob@^0.3.1:
219 | version "0.3.2"
220 | resolved "https://registry.yarnpkg.com/extglob/-/extglob-0.3.2.tgz#2e18ff3d2f49ab2765cec9023f011daa8d8349a1"
221 | integrity sha1-Lhj/PS9JqydlzskCPwEdqo2DSaE=
222 | dependencies:
223 | is-extglob "^1.0.0"
224 |
225 | fastparse@^1.1.1:
226 | version "1.1.2"
227 | resolved "https://registry.yarnpkg.com/fastparse/-/fastparse-1.1.2.tgz#91728c5a5942eced8531283c79441ee4122c35a9"
228 | integrity sha512-483XLLxTVIwWK3QTrMGRqUfUpoOs/0hbQrl2oz4J0pAcm3A3bu84wxTFqGqkJzewCLdME38xJLJAxBABfQT8sQ==
229 |
230 | filename-regex@^2.0.0:
231 | version "2.0.1"
232 | resolved "https://registry.yarnpkg.com/filename-regex/-/filename-regex-2.0.1.tgz#c1c4b9bee3e09725ddb106b75c1e301fe2f18b26"
233 | integrity sha1-wcS5vuPglyXdsQa3XB4wH+LxiyY=
234 |
235 | fill-range@^2.1.0:
236 | version "2.2.4"
237 | resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-2.2.4.tgz#eb1e773abb056dcd8df2bfdf6af59b8b3a936565"
238 | integrity sha512-cnrcCbj01+j2gTG921VZPnHbjmdAf8oQV/iGeV2kZxGSyfYjjTyY79ErsK1WJWMpw6DaApEX72binqJE+/d+5Q==
239 | dependencies:
240 | is-number "^2.1.0"
241 | isobject "^2.0.0"
242 | randomatic "^3.0.0"
243 | repeat-element "^1.1.2"
244 | repeat-string "^1.5.2"
245 |
246 | for-in@^1.0.1:
247 | version "1.0.2"
248 | resolved "https://registry.yarnpkg.com/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80"
249 | integrity sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=
250 |
251 | for-own@^0.1.4:
252 | version "0.1.5"
253 | resolved "https://registry.yarnpkg.com/for-own/-/for-own-0.1.5.tgz#5265c681a4f294dabbf17c9509b6763aa84510ce"
254 | integrity sha1-UmXGgaTylNq78XyVCbZ2OqhFEM4=
255 | dependencies:
256 | for-in "^1.0.1"
257 |
258 | fs-extra@7.0.0:
259 | version "7.0.0"
260 | resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-7.0.0.tgz#8cc3f47ce07ef7b3593a11b9fb245f7e34c041d6"
261 | integrity sha512-EglNDLRpmaTWiD/qraZn6HREAEAHJcJOmxNEYwq6xeMKnVMAy3GUcFB+wXt2C6k4CNvB/mP1y/U3dzvKKj5OtQ==
262 | dependencies:
263 | graceful-fs "^4.1.2"
264 | jsonfile "^4.0.0"
265 | universalify "^0.1.0"
266 |
267 | generic-names@^1.0.2:
268 | version "1.0.3"
269 | resolved "https://registry.yarnpkg.com/generic-names/-/generic-names-1.0.3.tgz#2d786a121aee508876796939e8e3bff836c20917"
270 | integrity sha1-LXhqEhruUIh2eWk56OO/+DbCCRc=
271 | dependencies:
272 | loader-utils "^0.2.16"
273 |
274 | glob-base@^0.3.0:
275 | version "0.3.0"
276 | resolved "https://registry.yarnpkg.com/glob-base/-/glob-base-0.3.0.tgz#dbb164f6221b1c0b1ccf82aea328b497df0ea3c4"
277 | integrity sha1-27Fk9iIbHAscz4Kuoyi0l98Oo8Q=
278 | dependencies:
279 | glob-parent "^2.0.0"
280 | is-glob "^2.0.0"
281 |
282 | glob-parent@^2.0.0:
283 | version "2.0.0"
284 | resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-2.0.0.tgz#81383d72db054fcccf5336daa902f182f6edbb28"
285 | integrity sha1-gTg9ctsFT8zPUzbaqQLxgvbtuyg=
286 | dependencies:
287 | is-glob "^2.0.0"
288 |
289 | graceful-fs@^4.1.2, graceful-fs@^4.1.6:
290 | version "4.1.15"
291 | resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.15.tgz#ffb703e1066e8a0eeaa4c8b80ba9253eeefbfb00"
292 | integrity sha512-6uHUhOPEBgQ24HM+r6b/QwWfZq+yiFcipKFrOFiBEnWdy5sdzYoi+pJeQaPI5qOLRFqWmAXUPQNsielzdLoecA==
293 |
294 | has-ansi@^2.0.0:
295 | version "2.0.0"
296 | resolved "https://registry.yarnpkg.com/has-ansi/-/has-ansi-2.0.0.tgz#34f5049ce1ecdf2b0649af3ef24e45ed35416d91"
297 | integrity sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=
298 | dependencies:
299 | ansi-regex "^2.0.0"
300 |
301 | has-flag@^1.0.0:
302 | version "1.0.0"
303 | resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-1.0.0.tgz#9d9e793165ce017a00f00418c43f942a7b1d11fa"
304 | integrity sha1-nZ55MWXOAXoA8AQYxD+UKnsdEfo=
305 |
306 | has-flag@^3.0.0:
307 | version "3.0.0"
308 | resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd"
309 | integrity sha1-tdRU3CGZriJWmfNGfloH87lVuv0=
310 |
311 | hash-sum@^1.0.2:
312 | version "1.0.2"
313 | resolved "https://registry.yarnpkg.com/hash-sum/-/hash-sum-1.0.2.tgz#33b40777754c6432573c120cc3808bbd10d47f04"
314 | integrity sha1-M7QHd3VMZDJXPBIMw4CLvRDUfwQ=
315 |
316 | he@^1.1.0:
317 | version "1.2.0"
318 | resolved "https://registry.yarnpkg.com/he/-/he-1.2.0.tgz#84ae65fa7eafb165fddb61566ae14baf05664f0f"
319 | integrity sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==
320 |
321 | icss-replace-symbols@^1.0.2:
322 | version "1.1.0"
323 | resolved "https://registry.yarnpkg.com/icss-replace-symbols/-/icss-replace-symbols-1.1.0.tgz#06ea6f83679a7749e386cfe1fe812ae5db223ded"
324 | integrity sha1-Bupvg2ead0njhs/h/oEq5dsiPe0=
325 |
326 | indexes-of@^1.0.1:
327 | version "1.0.1"
328 | resolved "https://registry.yarnpkg.com/indexes-of/-/indexes-of-1.0.1.tgz#f30f716c8e2bd346c7b67d3df3915566a7c05607"
329 | integrity sha1-8w9xbI4r00bHtn0985FVZqfAVgc=
330 |
331 | is-buffer@^1.1.5:
332 | version "1.1.6"
333 | resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.6.tgz#efaa2ea9daa0d7ab2ea13a97b2b8ad51fefbe8be"
334 | integrity sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==
335 |
336 | is-dotfile@^1.0.0:
337 | version "1.0.3"
338 | resolved "https://registry.yarnpkg.com/is-dotfile/-/is-dotfile-1.0.3.tgz#a6a2f32ffd2dfb04f5ca25ecd0f6b83cf798a1e1"
339 | integrity sha1-pqLzL/0t+wT1yiXs0Pa4PPeYoeE=
340 |
341 | is-equal-shallow@^0.1.3:
342 | version "0.1.3"
343 | resolved "https://registry.yarnpkg.com/is-equal-shallow/-/is-equal-shallow-0.1.3.tgz#2238098fc221de0bcfa5d9eac4c45d638aa1c534"
344 | integrity sha1-IjgJj8Ih3gvPpdnqxMRdY4qhxTQ=
345 | dependencies:
346 | is-primitive "^2.0.0"
347 |
348 | is-extendable@^0.1.1:
349 | version "0.1.1"
350 | resolved "https://registry.yarnpkg.com/is-extendable/-/is-extendable-0.1.1.tgz#62b110e289a471418e3ec36a617d472e301dfc89"
351 | integrity sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik=
352 |
353 | is-extglob@^1.0.0:
354 | version "1.0.0"
355 | resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-1.0.0.tgz#ac468177c4943405a092fc8f29760c6ffc6206c0"
356 | integrity sha1-rEaBd8SUNAWgkvyPKXYMb/xiBsA=
357 |
358 | is-glob@^2.0.0, is-glob@^2.0.1:
359 | version "2.0.1"
360 | resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-2.0.1.tgz#d096f926a3ded5600f3fdfd91198cb0888c2d863"
361 | integrity sha1-0Jb5JqPe1WAPP9/ZEZjLCIjC2GM=
362 | dependencies:
363 | is-extglob "^1.0.0"
364 |
365 | is-number@^2.1.0:
366 | version "2.1.0"
367 | resolved "https://registry.yarnpkg.com/is-number/-/is-number-2.1.0.tgz#01fcbbb393463a548f2f466cce16dece49db908f"
368 | integrity sha1-Afy7s5NGOlSPL0ZszhbezknbkI8=
369 | dependencies:
370 | kind-of "^3.0.2"
371 |
372 | is-number@^4.0.0:
373 | version "4.0.0"
374 | resolved "https://registry.yarnpkg.com/is-number/-/is-number-4.0.0.tgz#0026e37f5454d73e356dfe6564699867c6a7f0ff"
375 | integrity sha512-rSklcAIlf1OmFdyAqbnWTLVelsQ58uvZ66S/ZyawjWqIviTWCjg2PzVGw8WUA+nNuPTqb4wgA+NszrJ+08LlgQ==
376 |
377 | is-obj@^1.0.0:
378 | version "1.0.1"
379 | resolved "https://registry.yarnpkg.com/is-obj/-/is-obj-1.0.1.tgz#3e4729ac1f5fde025cd7d83a896dab9f4f67db0f"
380 | integrity sha1-PkcprB9f3gJc19g6iW2rn09n2w8=
381 |
382 | is-posix-bracket@^0.1.0:
383 | version "0.1.1"
384 | resolved "https://registry.yarnpkg.com/is-posix-bracket/-/is-posix-bracket-0.1.1.tgz#3334dc79774368e92f016e6fbc0a88f5cd6e6bc4"
385 | integrity sha1-MzTceXdDaOkvAW5vvAqI9c1ua8Q=
386 |
387 | is-primitive@^2.0.0:
388 | version "2.0.0"
389 | resolved "https://registry.yarnpkg.com/is-primitive/-/is-primitive-2.0.0.tgz#207bab91638499c07b2adf240a41a87210034575"
390 | integrity sha1-IHurkWOEmcB7Kt8kCkGochADRXU=
391 |
392 | isarray@1.0.0:
393 | version "1.0.0"
394 | resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11"
395 | integrity sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=
396 |
397 | isobject@^2.0.0:
398 | version "2.1.0"
399 | resolved "https://registry.yarnpkg.com/isobject/-/isobject-2.1.0.tgz#f065561096a3f1da2ef46272f815c840d87e0c89"
400 | integrity sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk=
401 | dependencies:
402 | isarray "1.0.0"
403 |
404 | js-base64@^2.1.9:
405 | version "2.4.9"
406 | resolved "https://registry.yarnpkg.com/js-base64/-/js-base64-2.4.9.tgz#748911fb04f48a60c4771b375cac45a80df11c03"
407 | integrity sha512-xcinL3AuDJk7VSzsHgb9DvvIXayBbadtMZ4HFPx8rUszbW1MuNMlwYVC4zzCZ6e1sqZpnNS5ZFYOhXqA39T7LQ==
408 |
409 | jsesc@~0.5.0:
410 | version "0.5.0"
411 | resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-0.5.0.tgz#e7dee66e35d6fc16f710fe91d5cf69f70f08911d"
412 | integrity sha1-597mbjXW/Bb3EP6R1c9p9w8IkR0=
413 |
414 | json5@^0.5.0:
415 | version "0.5.1"
416 | resolved "https://registry.yarnpkg.com/json5/-/json5-0.5.1.tgz#1eade7acc012034ad84e2396767ead9fa5495821"
417 | integrity sha1-Hq3nrMASA0rYTiOWdn6tn6VJWCE=
418 |
419 | jsonfile@^4.0.0:
420 | version "4.0.0"
421 | resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-4.0.0.tgz#8771aae0799b64076b76640fca058f9c10e33ecb"
422 | integrity sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=
423 | optionalDependencies:
424 | graceful-fs "^4.1.6"
425 |
426 | kind-of@^3.0.2:
427 | version "3.2.2"
428 | resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-3.2.2.tgz#31ea21a734bab9bbb0f32466d893aea51e4a3c64"
429 | integrity sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=
430 | dependencies:
431 | is-buffer "^1.1.5"
432 |
433 | kind-of@^6.0.0:
434 | version "6.0.2"
435 | resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.2.tgz#01146b36a6218e64e58f3a8d66de5d7fc6f6d051"
436 | integrity sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==
437 |
438 | loader-utils@^0.2.16:
439 | version "0.2.17"
440 | resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-0.2.17.tgz#f86e6374d43205a6e6c60e9196f17c0299bfb348"
441 | integrity sha1-+G5jdNQyBabmxg6RlvF8Apm/s0g=
442 | dependencies:
443 | big.js "^3.1.3"
444 | emojis-list "^2.0.0"
445 | json5 "^0.5.0"
446 | object-assign "^4.0.1"
447 |
448 | lodash.isempty@4.4.0:
449 | version "4.4.0"
450 | resolved "https://registry.yarnpkg.com/lodash.isempty/-/lodash.isempty-4.4.0.tgz#6f86cbedd8be4ec987be9aaf33c9684db1b31e7e"
451 | integrity sha1-b4bL7di+TsmHvpqvM8loTbGzHn4=
452 |
453 | lodash.omitby@4.6.0:
454 | version "4.6.0"
455 | resolved "https://registry.yarnpkg.com/lodash.omitby/-/lodash.omitby-4.6.0.tgz#5c15ff4754ad555016b53c041311e8f079204791"
456 | integrity sha1-XBX/R1StVVAWtTwEExHo8HkgR5E=
457 |
458 | lru-cache@^4.1.2:
459 | version "4.1.4"
460 | resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-4.1.4.tgz#51cc46e8e6d9530771c857e24ccc720ecdbcc031"
461 | integrity sha512-EPstzZ23znHUVLKj+lcXO1KvZkrlw+ZirdwvOmnAnA/1PB4ggyXJ77LRkCqkff+ShQ+cqoxCxLQOh4cKITO5iA==
462 | dependencies:
463 | pseudomap "^1.0.2"
464 | yallist "^3.0.2"
465 |
466 | magic-string@0.25.1, magic-string@^0.25.1:
467 | version "0.25.1"
468 | resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.25.1.tgz#b1c248b399cd7485da0fe7385c2fc7011843266e"
469 | integrity sha512-sCuTz6pYom8Rlt4ISPFn6wuFodbKMIHUMv4Qko9P17dpxb7s52KJTmRuZZqHdGmLCK9AOcDare039nRIcfdkEg==
470 | dependencies:
471 | sourcemap-codec "^1.4.1"
472 |
473 | magic-string@^0.25.5:
474 | version "0.25.7"
475 | resolved "https://registry.npmjs.org/magic-string/-/magic-string-0.25.7.tgz#3f497d6fd34c669c6798dcb821f2ef31f5445051"
476 | integrity sha512-4CrMT5DOHTDk4HYDlzmwu4FVCcIYI8gauveasrdCu2IKIFOJ3f0v/8MDGJCDL9oD2ppz/Av1b0Nj345H9M+XIA==
477 | dependencies:
478 | sourcemap-codec "^1.4.4"
479 |
480 | math-random@^1.0.1:
481 | version "1.0.1"
482 | resolved "https://registry.yarnpkg.com/math-random/-/math-random-1.0.1.tgz#8b3aac588b8a66e4975e3cdea67f7bb329601fac"
483 | integrity sha1-izqsWIuKZuSXXjzepn97sylgH6w=
484 |
485 | merge-source-map@^1.1.0:
486 | version "1.1.0"
487 | resolved "https://registry.yarnpkg.com/merge-source-map/-/merge-source-map-1.1.0.tgz#2fdde7e6020939f70906a68f2d7ae685e4c8c646"
488 | integrity sha512-Qkcp7P2ygktpMPh2mCQZaf3jhN6D3Z/qVZHSdWvQ+2Ef5HgRAPBO57A77+ENm0CPx2+1Ce/MYKi3ymqdfuqibw==
489 | dependencies:
490 | source-map "^0.6.1"
491 |
492 | micromatch@^2.3.11:
493 | version "2.3.11"
494 | resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-2.3.11.tgz#86677c97d1720b363431d04d0d15293bd38c1565"
495 | integrity sha1-hmd8l9FyCzY0MdBNDRUpO9OMFWU=
496 | dependencies:
497 | arr-diff "^2.0.0"
498 | array-unique "^0.2.1"
499 | braces "^1.8.2"
500 | expand-brackets "^0.1.4"
501 | extglob "^0.3.1"
502 | filename-regex "^2.0.0"
503 | is-extglob "^1.0.0"
504 | is-glob "^2.0.1"
505 | kind-of "^3.0.2"
506 | normalize-path "^2.0.1"
507 | object.omit "^2.0.0"
508 | parse-glob "^3.0.4"
509 | regex-cache "^0.4.2"
510 |
511 | ms@^2.1.1:
512 | version "2.1.1"
513 | resolved "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz#30a5864eb3ebb0a66f2ebe6d727af06a09d86e0a"
514 | integrity sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==
515 |
516 | normalize-path@^2.0.1:
517 | version "2.1.1"
518 | resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-2.1.1.tgz#1ab28b556e198363a8c1a6f7e6fa20137fe6aed9"
519 | integrity sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=
520 | dependencies:
521 | remove-trailing-separator "^1.0.1"
522 |
523 | object-assign@^4.0.1:
524 | version "4.1.1"
525 | resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863"
526 | integrity sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=
527 |
528 | object.omit@^2.0.0:
529 | version "2.0.1"
530 | resolved "https://registry.yarnpkg.com/object.omit/-/object.omit-2.0.1.tgz#1a9c744829f39dbb858c76ca3579ae2a54ebd1fa"
531 | integrity sha1-Gpx0SCnznbuFjHbKNXmuKlTr0fo=
532 | dependencies:
533 | for-own "^0.1.4"
534 | is-extendable "^0.1.1"
535 |
536 | parse-glob@^3.0.4:
537 | version "3.0.4"
538 | resolved "https://registry.yarnpkg.com/parse-glob/-/parse-glob-3.0.4.tgz#b2c376cfb11f35513badd173ef0bb6e3a388391c"
539 | integrity sha1-ssN2z7EfNVE7rdFz7wu246OIORw=
540 | dependencies:
541 | glob-base "^0.3.0"
542 | is-dotfile "^1.0.0"
543 | is-extglob "^1.0.0"
544 | is-glob "^2.0.0"
545 |
546 | path-parse@^1.0.5:
547 | version "1.0.6"
548 | resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.6.tgz#d62dbb5679405d72c4737ec58600e9ddcf06d24c"
549 | integrity sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==
550 |
551 | postcss-modules-local-by-default@^1.1.1:
552 | version "1.2.0"
553 | resolved "https://registry.yarnpkg.com/postcss-modules-local-by-default/-/postcss-modules-local-by-default-1.2.0.tgz#f7d80c398c5a393fa7964466bd19500a7d61c069"
554 | integrity sha1-99gMOYxaOT+nlkRmvRlQCn1hwGk=
555 | dependencies:
556 | css-selector-tokenizer "^0.7.0"
557 | postcss "^6.0.1"
558 |
559 | postcss-modules-scope@^1.0.2:
560 | version "1.1.0"
561 | resolved "https://registry.yarnpkg.com/postcss-modules-scope/-/postcss-modules-scope-1.1.0.tgz#d6ea64994c79f97b62a72b426fbe6056a194bb90"
562 | integrity sha1-1upkmUx5+XtipytCb75gVqGUu5A=
563 | dependencies:
564 | css-selector-tokenizer "^0.7.0"
565 | postcss "^6.0.1"
566 |
567 | postcss-modules-sync@^1.0.0:
568 | version "1.0.0"
569 | resolved "https://registry.yarnpkg.com/postcss-modules-sync/-/postcss-modules-sync-1.0.0.tgz#619a719cf78dd16a4834135140b324cf77334be1"
570 | integrity sha1-YZpxnPeN0WpINBNRQLMkz3czS+E=
571 | dependencies:
572 | generic-names "^1.0.2"
573 | icss-replace-symbols "^1.0.2"
574 | postcss "^5.2.5"
575 | postcss-modules-local-by-default "^1.1.1"
576 | postcss-modules-scope "^1.0.2"
577 | string-hash "^1.1.0"
578 |
579 | postcss-selector-parser@^3.1.1:
580 | version "3.1.1"
581 | resolved "https://registry.yarnpkg.com/postcss-selector-parser/-/postcss-selector-parser-3.1.1.tgz#4f875f4afb0c96573d5cf4d74011aee250a7e865"
582 | integrity sha1-T4dfSvsMllc9XPTXQBGu4lCn6GU=
583 | dependencies:
584 | dot-prop "^4.1.1"
585 | indexes-of "^1.0.1"
586 | uniq "^1.0.1"
587 |
588 | postcss@^5.2.5:
589 | version "5.2.18"
590 | resolved "https://registry.yarnpkg.com/postcss/-/postcss-5.2.18.tgz#badfa1497d46244f6390f58b319830d9107853c5"
591 | integrity sha512-zrUjRRe1bpXKsX1qAJNJjqZViErVuyEkMTRrwu4ud4sbTtIBRmtaYDrHmcGgmrbsW3MHfmtIf+vJumgQn+PrXg==
592 | dependencies:
593 | chalk "^1.1.3"
594 | js-base64 "^2.1.9"
595 | source-map "^0.5.6"
596 | supports-color "^3.2.3"
597 |
598 | postcss@^6.0.1, postcss@^6.0.20:
599 | version "6.0.23"
600 | resolved "https://registry.yarnpkg.com/postcss/-/postcss-6.0.23.tgz#61c82cc328ac60e677645f979054eb98bc0e3324"
601 | integrity sha512-soOk1h6J3VMTZtVeVpv15/Hpdl2cBLX3CAw4TAbkpTJiNPk9YP/zWcD1ND+xEtvyuuvKzbxliTOIyvkSeSJ6ag==
602 | dependencies:
603 | chalk "^2.4.1"
604 | source-map "^0.6.1"
605 | supports-color "^5.4.0"
606 |
607 | preserve@^0.2.0:
608 | version "0.2.0"
609 | resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b"
610 | integrity sha1-gV7R9uvGWSb4ZbMQwHE7yzMVzks=
611 |
612 | prettier@1.13.7:
613 | version "1.13.7"
614 | resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.13.7.tgz#850f3b8af784a49a6ea2d2eaa7ed1428a34b7281"
615 | integrity sha512-KIU72UmYPGk4MujZGYMFwinB7lOf2LsDNGSOC8ufevsrPLISrZbNJlWstRi3m0AMuszbH+EFSQ/r6w56RSPK6w==
616 |
617 | prettier@^1.0.0:
618 | version "1.15.2"
619 | resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.15.2.tgz#d31abe22afa4351efa14c7f8b94b58bb7452205e"
620 | integrity sha512-YgPLFFA0CdKL4Eg2IHtUSjzj/BWgszDHiNQAe0VAIBse34148whfdzLagRL+QiKS+YfK5ftB6X4v/MBw8yCoug==
621 |
622 | pseudomap@^1.0.2:
623 | version "1.0.2"
624 | resolved "https://registry.yarnpkg.com/pseudomap/-/pseudomap-1.0.2.tgz#f052a28da70e618917ef0a8ac34c1ae5a68286b3"
625 | integrity sha1-8FKijacOYYkX7wqKw0wa5aaChrM=
626 |
627 | querystring@^0.2.0:
628 | version "0.2.0"
629 | resolved "https://registry.yarnpkg.com/querystring/-/querystring-0.2.0.tgz#b209849203bb25df820da756e747005878521620"
630 | integrity sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA=
631 |
632 | randomatic@^3.0.0:
633 | version "3.1.1"
634 | resolved "https://registry.yarnpkg.com/randomatic/-/randomatic-3.1.1.tgz#b776efc59375984e36c537b2f51a1f0aff0da1ed"
635 | integrity sha512-TuDE5KxZ0J461RVjrJZCJc+J+zCkTb1MbH9AQUq68sMhOMcy9jLcb3BrZKgp9q9Ncltdg4QVqWrH02W2EFFVYw==
636 | dependencies:
637 | is-number "^4.0.0"
638 | kind-of "^6.0.0"
639 | math-random "^1.0.1"
640 |
641 | regenerate@^1.2.1:
642 | version "1.4.0"
643 | resolved "https://registry.yarnpkg.com/regenerate/-/regenerate-1.4.0.tgz#4a856ec4b56e4077c557589cae85e7a4c8869a11"
644 | integrity sha512-1G6jJVDWrt0rK99kBjvEtziZNCICAuvIPkSiUFIQxVP06RCVpq3dmDo2oi6ABpYaDYaTRr67BEhL8r1wgEZZKg==
645 |
646 | regex-cache@^0.4.2:
647 | version "0.4.4"
648 | resolved "https://registry.yarnpkg.com/regex-cache/-/regex-cache-0.4.4.tgz#75bdc58a2a1496cec48a12835bc54c8d562336dd"
649 | integrity sha512-nVIZwtCjkC9YgvWkpM55B5rBhBYRZhAaJbgcFYXXsHnbZ9UZI9nnVWYZpBlCqv9ho2eZryPnWrZGsOdPwVWXWQ==
650 | dependencies:
651 | is-equal-shallow "^0.1.3"
652 |
653 | regexpu-core@^1.0.0:
654 | version "1.0.0"
655 | resolved "https://registry.yarnpkg.com/regexpu-core/-/regexpu-core-1.0.0.tgz#86a763f58ee4d7c2f6b102e4764050de7ed90c6b"
656 | integrity sha1-hqdj9Y7k18L2sQLkdkBQ3n7ZDGs=
657 | dependencies:
658 | regenerate "^1.2.1"
659 | regjsgen "^0.2.0"
660 | regjsparser "^0.1.4"
661 |
662 | regjsgen@^0.2.0:
663 | version "0.2.0"
664 | resolved "https://registry.yarnpkg.com/regjsgen/-/regjsgen-0.2.0.tgz#6c016adeac554f75823fe37ac05b92d5a4edb1f7"
665 | integrity sha1-bAFq3qxVT3WCP+N6wFuS1aTtsfc=
666 |
667 | regjsparser@^0.1.4:
668 | version "0.1.5"
669 | resolved "https://registry.yarnpkg.com/regjsparser/-/regjsparser-0.1.5.tgz#7ee8f84dc6fa792d3fd0ae228d24bd949ead205c"
670 | integrity sha1-fuj4Tcb6eS0/0K4ijSS9lJ6tIFw=
671 | dependencies:
672 | jsesc "~0.5.0"
673 |
674 | remove-trailing-separator@^1.0.1:
675 | version "1.1.0"
676 | resolved "https://registry.yarnpkg.com/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz#c24bce2a283adad5bc3f58e0d48249b92379d8ef"
677 | integrity sha1-wkvOKig62tW8P1jg1IJJuSN52O8=
678 |
679 | repeat-element@^1.1.2:
680 | version "1.1.3"
681 | resolved "https://registry.yarnpkg.com/repeat-element/-/repeat-element-1.1.3.tgz#782e0d825c0c5a3bb39731f84efee6b742e6b1ce"
682 | integrity sha512-ahGq0ZnV5m5XtZLMb+vP76kcAM5nkLqk0lpqAuojSKGgQtn4eRi4ZZGm2olo2zKFH+sMsWaqOCW1dqAnOru72g==
683 |
684 | repeat-string@^1.5.2:
685 | version "1.6.1"
686 | resolved "https://registry.yarnpkg.com/repeat-string/-/repeat-string-1.6.1.tgz#8dcae470e1c88abc2d600fff4a776286da75e637"
687 | integrity sha1-jcrkcOHIirwtYA//Sndihtp15jc=
688 |
689 | resolve@1.8.1:
690 | version "1.8.1"
691 | resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.8.1.tgz#82f1ec19a423ac1fbd080b0bab06ba36e84a7a26"
692 | integrity sha512-AicPrAC7Qu1JxPCZ9ZgCZlY35QgFnNqc+0LtbRNxnVw4TXvjQ72wnuL9JQcEBgXkI9JM8MsT9kaQoHcpCRJOYA==
693 | dependencies:
694 | path-parse "^1.0.5"
695 |
696 | rollup-plugin-prettier@^0.5.0:
697 | version "0.5.0"
698 | resolved "https://registry.yarnpkg.com/rollup-plugin-prettier/-/rollup-plugin-prettier-0.5.0.tgz#25950b990a8f521206d44ee911486229b91a86bf"
699 | integrity sha512-F00UUEShD6J9s96yLPSajLyAI0IRjysbsHUpw4laJMisvdLb7llsLdm88gPKAZSykqgU97GF0S6btSflSruuyg==
700 | dependencies:
701 | diff "3.5.0"
702 | lodash.isempty "4.4.0"
703 | lodash.omitby "4.6.0"
704 | magic-string "0.25.1"
705 | prettier "^1.0.0"
706 |
707 | rollup-plugin-strip@^1.2.0:
708 | version "1.2.0"
709 | resolved "https://registry.yarnpkg.com/rollup-plugin-strip/-/rollup-plugin-strip-1.2.0.tgz#ed7efd63c3789d37402eee9d37c743a24d9d7711"
710 | integrity sha512-vAn+U/hY+RkcR3xhXKXfoTs2XbXmIScy6zs+kVTPujt5c+XfXtv/7j+hRwuqo++otR9n0Qsh6bgGlPk+ku/M5Q==
711 | dependencies:
712 | estree-walker "^0.5.2"
713 | magic-string "^0.25.1"
714 | rollup-pluginutils "^2.3.3"
715 |
716 | rollup-plugin-typescript2@^0.18.0:
717 | version "0.18.0"
718 | resolved "https://registry.yarnpkg.com/rollup-plugin-typescript2/-/rollup-plugin-typescript2-0.18.0.tgz#ab3f7003f47c3858810d516e4d3fada546bfb1df"
719 | integrity sha512-AL7LJl31bYO/x8zO1fuE7ACn/2nDs9DVYL3qjiWSYg5LC4EV/iKuCL4Fm6pjzEqCB4fFIMXoUuGUf5R+BLNKSg==
720 | dependencies:
721 | fs-extra "7.0.0"
722 | resolve "1.8.1"
723 | rollup-pluginutils "2.3.3"
724 | tslib "1.9.3"
725 |
726 | rollup-plugin-vue@^4.6.2:
727 | version "4.6.2"
728 | resolved "https://registry.npmjs.org/rollup-plugin-vue/-/rollup-plugin-vue-4.6.2.tgz#13ef8c551825f3956f4b43542830f4f6e0a90169"
729 | integrity sha512-02Xmcn5bewk0mTQNliRS5/dp1xf0whPtHV/5DAjbsqiFZvRvf5cBDKIpxAWdnOTyxXO/BaT/E9GTxnCOmt4AIQ==
730 | dependencies:
731 | "@vue/component-compiler" "^3.6"
732 | "@vue/component-compiler-utils" "^2.1.0"
733 | debug "^4.1.1"
734 | hash-sum "^1.0.2"
735 | querystring "^0.2.0"
736 | rollup-pluginutils "^2.0.1"
737 | source-map "0.7.3"
738 | vue-runtime-helpers "1.0.0"
739 |
740 | rollup-pluginutils@2.3.3, rollup-pluginutils@^2.0.1, rollup-pluginutils@^2.3.3:
741 | version "2.3.3"
742 | resolved "https://registry.yarnpkg.com/rollup-pluginutils/-/rollup-pluginutils-2.3.3.tgz#3aad9b1eb3e7fe8262820818840bf091e5ae6794"
743 | integrity sha512-2XZwja7b6P5q4RZ5FhyX1+f46xi1Z3qBKigLRZ6VTZjwbN0K1IFGMlwm06Uu0Emcre2Z63l77nq/pzn+KxIEoA==
744 | dependencies:
745 | estree-walker "^0.5.2"
746 | micromatch "^2.3.11"
747 |
748 | source-map@0.6.*, source-map@^0.6.1, source-map@~0.6.0:
749 | version "0.6.1"
750 | resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263"
751 | integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==
752 |
753 | source-map@0.7.3:
754 | version "0.7.3"
755 | resolved "https://registry.npmjs.org/source-map/-/source-map-0.7.3.tgz#5302f8169031735226544092e64981f751750383"
756 | integrity sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ==
757 |
758 | source-map@^0.5.6:
759 | version "0.5.7"
760 | resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc"
761 | integrity sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=
762 |
763 | sourcemap-codec@^1.4.1:
764 | version "1.4.3"
765 | resolved "https://registry.yarnpkg.com/sourcemap-codec/-/sourcemap-codec-1.4.3.tgz#0ba615b73ec35112f63c2f2d9e7c3f87282b0e33"
766 | integrity sha512-vFrY/x/NdsD7Yc8mpTJXuao9S8lq08Z/kOITHz6b7YbfI9xL8Spe5EvSQUHOI7SbpY8bRPr0U3kKSsPuqEGSfA==
767 |
768 | sourcemap-codec@^1.4.4:
769 | version "1.4.8"
770 | resolved "https://registry.npmjs.org/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz#ea804bd94857402e6992d05a38ef1ae35a9ab4c4"
771 | integrity sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA==
772 |
773 | string-hash@^1.1.0:
774 | version "1.1.3"
775 | resolved "https://registry.yarnpkg.com/string-hash/-/string-hash-1.1.3.tgz#e8aafc0ac1855b4666929ed7dd1275df5d6c811b"
776 | integrity sha1-6Kr8CsGFW0Zmkp7X3RJ1311sgRs=
777 |
778 | strip-ansi@^3.0.0:
779 | version "3.0.1"
780 | resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-3.0.1.tgz#6a385fb8853d952d5ff05d0e8aaf94278dc63dcf"
781 | integrity sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=
782 | dependencies:
783 | ansi-regex "^2.0.0"
784 |
785 | supports-color@^2.0.0:
786 | version "2.0.0"
787 | resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7"
788 | integrity sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=
789 |
790 | supports-color@^3.2.3:
791 | version "3.2.3"
792 | resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-3.2.3.tgz#65ac0504b3954171d8a64946b2ae3cbb8a5f54f6"
793 | integrity sha1-ZawFBLOVQXHYpklGsq48u4pfVPY=
794 | dependencies:
795 | has-flag "^1.0.0"
796 |
797 | supports-color@^5.3.0, supports-color@^5.4.0:
798 | version "5.5.0"
799 | resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f"
800 | integrity sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==
801 | dependencies:
802 | has-flag "^3.0.0"
803 |
804 | tslib@1.9.3:
805 | version "1.9.3"
806 | resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.3.tgz#d7e4dd79245d85428c4d7e4822a79917954ca286"
807 | integrity sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ==
808 |
809 | typescript@^3.1.6:
810 | version "3.1.6"
811 | resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.1.6.tgz#b6543a83cfc8c2befb3f4c8fba6896f5b0c9be68"
812 | integrity sha512-tDMYfVtvpb96msS1lDX9MEdHrW4yOuZ4Kdc4Him9oU796XldPYF/t2+uKoX0BBa0hXXwDlqYQbXY5Rzjzc5hBA==
813 |
814 | uniq@^1.0.1:
815 | version "1.0.1"
816 | resolved "https://registry.yarnpkg.com/uniq/-/uniq-1.0.1.tgz#b31c5ae8254844a3a8281541ce2b04b865a734ff"
817 | integrity sha1-sxxa6CVIRKOoKBVBzisEuGWnNP8=
818 |
819 | universalify@^0.1.0:
820 | version "0.1.2"
821 | resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.2.tgz#b646f69be3942dabcecc9d6639c80dc105efaa66"
822 | integrity sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==
823 |
824 | vue-runtime-helpers@1.0.0:
825 | version "1.0.0"
826 | resolved "https://registry.npmjs.org/vue-runtime-helpers/-/vue-runtime-helpers-1.0.0.tgz#af5fe1c8d727beb680b2eb9d791c8e022342e54d"
827 | integrity sha512-DgwCNgIXkq1GJsWwtFOjA/K2nxpjyon/QqAut0EiwrMHBatAPbfdqksDdRoK15b5YrSJRa59rx3pc0L6V4udUA==
828 |
829 | vue-template-compiler@^2.5.17:
830 | version "2.5.17"
831 | resolved "https://registry.yarnpkg.com/vue-template-compiler/-/vue-template-compiler-2.5.17.tgz#52a4a078c327deb937482a509ae85c06f346c3cb"
832 | integrity sha512-63uI4syCwtGR5IJvZM0LN5tVsahrelomHtCxvRkZPJ/Tf3ADm1U1wG6KWycK3qCfqR+ygM5vewUvmJ0REAYksg==
833 | dependencies:
834 | de-indent "^1.0.2"
835 | he "^1.1.0"
836 |
837 | vue-template-es2015-compiler@^1.6.0:
838 | version "1.6.0"
839 | resolved "https://registry.yarnpkg.com/vue-template-es2015-compiler/-/vue-template-es2015-compiler-1.6.0.tgz#dc42697133302ce3017524356a6c61b7b69b4a18"
840 | integrity sha512-x3LV3wdmmERhVCYy3quqA57NJW7F3i6faas++pJQWtknWT+n7k30F4TVdHvCLn48peTJFRvCpxs3UuFPqgeELg==
841 |
842 | yallist@^3.0.2:
843 | version "3.0.3"
844 | resolved "https://registry.yarnpkg.com/yallist/-/yallist-3.0.3.tgz#b4b049e314be545e3ce802236d6cd22cd91c3de9"
845 | integrity sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==
846 |
--------------------------------------------------------------------------------
/test/index.test.ts:
--------------------------------------------------------------------------------
1 | import path from 'path'
2 | import { Bundler, Config, Options } from '../src'
3 |
4 | process.env.BABEL_ENV = 'anything-not-test'
5 |
6 | function fixture(...args: string[]) {
7 | return path.join(__dirname, 'fixtures', ...args)
8 | }
9 |
10 | function generate(config: Config, options: Options) {
11 | const bundler = new Bundler(config, {
12 | logLevel: 'quiet',
13 | configFile: false,
14 | ...options
15 | })
16 | return bundler.run()
17 | }
18 |
19 | function snapshot(
20 | {
21 | title,
22 | input,
23 | cwd
24 | }: { title: string; input: string | string[]; cwd?: string },
25 | config?: Config
26 | ) {
27 | test(title, async () => {
28 | const { bundles } = await generate(
29 | {
30 | input,
31 | ...config
32 | },
33 | {
34 | rootDir: cwd
35 | }
36 | )
37 | for (const bundle of bundles) {
38 | for (const relative of bundle.keys()) {
39 | const asset = bundle.get(relative)
40 | expect(asset && asset.source).toMatchSnapshot(`${title} ${relative}`)
41 | }
42 | }
43 | })
44 | }
45 |
46 | snapshot({
47 | title: 'defaults',
48 | input: 'index.js',
49 | cwd: fixture('defaults')
50 | })
51 |
52 | snapshot(
53 | {
54 | title: 'banner:true default',
55 | input: 'index.js',
56 | cwd: fixture('banner/default')
57 | },
58 | {
59 | banner: true
60 | }
61 | )
62 |
63 | snapshot(
64 | {
65 | title: 'banner:object',
66 | input: 'default.js',
67 | cwd: fixture()
68 | },
69 | {
70 | banner: {
71 | author: 'author',
72 | license: 'GPL',
73 | name: 'name',
74 | version: '1.2.3'
75 | }
76 | }
77 | )
78 |
79 | snapshot(
80 | {
81 | title: 'banner:string',
82 | input: 'default.js',
83 | cwd: fixture()
84 | },
85 | {
86 | banner: 'woot'
87 | }
88 | )
89 |
90 | snapshot(
91 | {
92 | title: 'exclude file',
93 | input: 'index.js',
94 | cwd: fixture('exclude-file')
95 | },
96 | {
97 | externals: ['./foo.js']
98 | }
99 | )
100 |
101 | snapshot(
102 | {
103 | title: 'extendOptions',
104 | input: ['foo.js', 'bar.js'],
105 | cwd: fixture('extend-options')
106 | },
107 | {
108 | output: {
109 | format: ['umd', 'umd-min', 'cjs']
110 | },
111 | extendConfig(config, { format }) {
112 | if (format === 'umd') {
113 | config.output.moduleName = 'umd'
114 | }
115 | if (format.endsWith('-min')) {
116 | config.output.moduleName = 'min'
117 | }
118 | return config
119 | }
120 | }
121 | )
122 |
123 | snapshot(
124 | {
125 | title: 'bundle-node-modules',
126 | input: 'index.js',
127 | cwd: fixture('bundle-node-modules')
128 | },
129 | {
130 | bundleNodeModules: true
131 | }
132 | )
133 |
134 | snapshot({
135 | title: 'async',
136 | input: 'index.js',
137 | cwd: fixture('async')
138 | })
139 |
140 | snapshot({
141 | title: 'babel:with-config',
142 | input: 'index.js',
143 | cwd: fixture('babel/with-config')
144 | })
145 |
146 | snapshot(
147 | {
148 | title: 'babel:disable-config',
149 | input: 'index.js',
150 | cwd: fixture('babel/with-config')
151 | },
152 | {
153 | babel: {
154 | babelrc: false
155 | }
156 | }
157 | )
158 |
159 | snapshot({
160 | title: 'babel:object-rest-spread',
161 | input: 'index.js',
162 | cwd: fixture('babel/object-rest-spread')
163 | })
164 |
165 | snapshot(
166 | {
167 | title: 'uglify',
168 | input: 'index.js',
169 | cwd: fixture('uglify')
170 | },
171 | {
172 | output: {
173 | format: 'cjs-min'
174 | }
175 | }
176 | )
177 |
178 | snapshot(
179 | {
180 | title: 'inline-certain-modules',
181 | input: 'index.js',
182 | cwd: fixture('inline-certain-modules')
183 | },
184 | {
185 | bundleNodeModules: ['fake-module']
186 | }
187 | )
188 |
189 | snapshot({
190 | title: 'vue plugin',
191 | input: 'component.vue',
192 | cwd: fixture('vue')
193 | })
194 |
195 | snapshot({
196 | title: 'Typescript',
197 | input: 'index.ts',
198 | cwd: fixture('typescript')
199 | })
200 |
201 | snapshot(
202 | {
203 | title: 'custom rollup plugin',
204 | input: 'index.js',
205 | cwd: fixture('custom-rollup-plugin')
206 | },
207 | {
208 | plugins: {
209 | strip: {
210 | functions: ['console.log']
211 | }
212 | }
213 | }
214 | )
215 |
216 | snapshot(
217 | {
218 | title: 'custom scoped rollup plugin',
219 | input: 'index.js',
220 | cwd: fixture('custom-scoped-rollup-plugin')
221 | },
222 | {
223 | plugins: {
224 | '@rollup/plugin-strip': {
225 | functions: ['console.log']
226 | }
227 | }
228 | }
229 | )
230 |
231 | snapshot(
232 | {
233 | title: '`@rollup/plugin-replace` can accepts custom options',
234 | input: 'index.js',
235 | cwd: fixture('custom-scoped-rollup-plugin/replace')
236 | },
237 | {
238 | plugins: {
239 | replace: {
240 | 'process.env.NODE_ENV': JSON.stringify('production')
241 | }
242 | }
243 | }
244 | )
245 |
246 | snapshot(
247 | {
248 | title: 'target:browser',
249 | input: 'index.js',
250 | cwd: fixture('target/browser')
251 | },
252 | {
253 | output: {
254 | target: 'browser'
255 | }
256 | }
257 | )
258 |
259 | snapshot(
260 | {
261 | title: 'umd and iife should drop process.env.NODE_ENV',
262 | input: 'index.js',
263 | cwd: fixture('format')
264 | },
265 | {
266 | output: {
267 | format: ['umd', 'umd-min', 'iife', 'iife-min'],
268 | moduleName: 'dropNodeEnv'
269 | }
270 | }
271 | )
272 |
273 | snapshot(
274 | {
275 | title: 'umd and iife should preserve existing env.NODE_ENV',
276 | input: 'index.js',
277 | cwd: fixture('format')
278 | },
279 | {
280 | output: {
281 | format: ['umd', 'umd-min', 'iife', 'iife-min'],
282 | moduleName: 'dropNodeEnv'
283 | },
284 | env: { NODE_ENV: 'production' }
285 | }
286 | )
287 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | /* Basic Options */
4 | "target": "es2017" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */,
5 | "module": "esnext" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */,
6 | "lib": [
7 | "es2017"
8 | ] /* Specify library files to be included in the compilation. */,
9 | // "allowJs": true /* Allow javascript files to be compiled. */,
10 | // "checkJs": true, /* Report errors in .js files. */
11 | // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
12 | // "declaration": true, /* Generates corresponding '.d.ts' file. */
13 | // "declarationDir": "types",
14 | // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
15 | // "sourceMap": true, /* Generates corresponding '.map' file. */
16 | // "outFile": "./", /* Concatenate and emit output to single file. */
17 | "outDir": "lib" /* Redirect output structure to the directory. */,
18 | // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
19 | // "composite": true, /* Enable project compilation */
20 | // "removeComments": true, /* Do not emit comments to output. */
21 | // "noEmit": true, /* Do not emit outputs. */
22 | // "importHelpers": true, /* Import emit helpers from 'tslib'. */
23 | // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
24 | // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
25 |
26 | /* Strict Type-Checking Options */
27 | "strict": true /* Enable all strict type-checking options. */,
28 | "noImplicitAny": true /* Raise error on expressions and declarations with an implied 'any' type. */,
29 | "strictNullChecks": true /* Enable strict null checks. */,
30 | // "strictFunctionTypes": true, /* Enable strict checking of function types. */
31 | // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
32 | // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
33 | "noImplicitThis": true /* Raise error on 'this' expressions with an implied 'any' type. */,
34 | "alwaysStrict": true /* Parse in strict mode and emit "use strict" for each source file. */,
35 |
36 | /* Additional Checks */
37 | // "noUnusedLocals": true, /* Report errors on unused locals. */
38 | // "noUnusedParameters": true, /* Report errors on unused parameters. */
39 | // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
40 | // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
41 |
42 | /* Module Resolution Options */
43 | "moduleResolution": "node" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */,
44 | // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
45 | // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
46 | // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
47 | // "typeRoots": [], /* List of folders to include type definitions from. */
48 | // "types": [], /* Type declaration files to be included in compilation. */
49 | // "allowSyntheticDefaultImports": true /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */,
50 | "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
51 | // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
52 | /* Source Map Options */
53 | // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
54 | // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
55 | // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
56 | // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
57 | /* Experimental Options */
58 | // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
59 | // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
60 | },
61 | "include": ["src/**/*.ts", "types.d.ts", "test/**/*.test.ts"]
62 | }
63 |
--------------------------------------------------------------------------------
/tsconfig.types.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | /* Basic Options */
4 | "target": "es2017" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */,
5 | "module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */,
6 | "lib": [
7 | "es2017"
8 | ] /* Specify library files to be included in the compilation. */,
9 | // "allowJs": true /* Allow javascript files to be compiled. */,
10 | // "checkJs": true, /* Report errors in .js files. */
11 | // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
12 | "declaration": true /* Generates corresponding '.d.ts' file. */,
13 | "declarationDir": "types",
14 | // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
15 | // "sourceMap": true, /* Generates corresponding '.map' file. */
16 | // "outFile": "./", /* Concatenate and emit output to single file. */
17 | "outDir": "lib" /* Redirect output structure to the directory. */,
18 | // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
19 | // "composite": true, /* Enable project compilation */
20 | // "removeComments": true, /* Do not emit comments to output. */
21 | // "noEmit": true, /* Do not emit outputs. */
22 | // "importHelpers": true, /* Import emit helpers from 'tslib'. */
23 | // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
24 | // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
25 |
26 | /* Strict Type-Checking Options */
27 | "strict": true /* Enable all strict type-checking options. */,
28 | "noImplicitAny": true /* Raise error on expressions and declarations with an implied 'any' type. */,
29 | "strictNullChecks": true /* Enable strict null checks. */,
30 | // "strictFunctionTypes": true, /* Enable strict checking of function types. */
31 | // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
32 | // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
33 | "noImplicitThis": true /* Raise error on 'this' expressions with an implied 'any' type. */,
34 | "alwaysStrict": true /* Parse in strict mode and emit "use strict" for each source file. */,
35 | "skipLibCheck": true,
36 | /* Additional Checks */
37 | // "noUnusedLocals": true, /* Report errors on unused locals. */
38 | // "noUnusedParameters": true, /* Report errors on unused parameters. */
39 | // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
40 | // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
41 |
42 | /* Module Resolution Options */
43 | "moduleResolution": "node" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */,
44 | // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
45 | // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
46 | // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
47 | // "typeRoots": [], /* List of folders to include type definitions from. */
48 | // "types": [], /* Type declaration files to be included in compilation. */
49 | // "allowSyntheticDefaultImports": true /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */,
50 | "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
51 | // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
52 | /* Source Map Options */
53 | // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
54 | // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
55 | // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
56 | // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
57 | /* Experimental Options */
58 | // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
59 | // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
60 | },
61 | "include": ["src/**/*.ts", "types.d.ts"]
62 | }
63 |
--------------------------------------------------------------------------------
/types.d.ts:
--------------------------------------------------------------------------------
1 | declare module '*.json'
2 |
3 | declare module 'tinydate' {
4 | type Tinydate = (template: string) => (date?: Date) => string
5 | const tinydate: Tinydate
6 | export = tinydate
7 | }
8 |
9 | declare module '@rollup/plugin-babel' {
10 | import { createConfigItem } from '@babel/core'
11 | const createBabelInputPluginFactory: (
12 | callback: (babelCore: { createConfigItem: typeof createConfigItem }) => any
13 | ) => any
14 | export { createBabelInputPluginFactory }
15 | }
16 |
17 | declare module 'babel-plugin-alter-object-assign'
18 |
19 | declare module 'text-table' {
20 | interface Options {
21 | stringLength?(str: string): number
22 | }
23 | type Table = (rows: Array>, opts?: Options) => string
24 | const table: Table
25 | export = table
26 | }
27 |
28 | declare module 'resolve'
29 | declare module 'stringify-author' {
30 | type Stringify = (author: any) => string
31 | const stringify: Stringify
32 | export = stringify
33 | }
34 |
--------------------------------------------------------------------------------