@repodog/rollup-config 1.2.2 → 1.2.3-alpha-12345.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -13
- package/index.cjs +11 -10
- package/package.json +15 -10
package/README.md
CHANGED
|
@@ -5,21 +5,14 @@ The Repodog Rollup config.
|
|
|
5
5
|
[](https://badge.fury.io/js/%40repodog%2Frollup-config)
|
|
6
6
|
[](LICENSE)
|
|
7
7
|
|
|
8
|
-
## Install package
|
|
8
|
+
## Install package and peer dependency
|
|
9
9
|
|
|
10
10
|
```shell
|
|
11
11
|
# terminal
|
|
12
|
-
npm install @repodog/rollup-config --save-dev
|
|
12
|
+
npm install @repodog/rollup-config rollup --save-dev
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
```shell
|
|
18
|
-
# terminal
|
|
19
|
-
npm install @rollup/plugin-image @rollup/plugin-json @rollup/plugin-node-resolve @rollup/plugin-terser rollup rollup-plugin-analyzer rollup-plugin-copy rollup-plugin-sourcemaps --save-dev
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
**Rollup uses Babel or SWC for code compilation so you will also need to install [`@repodog/babel-config`](../babel-config/README.md) or [`@repodog/swc-config`](../swc-config/README.md) and the relevant dependencies.**
|
|
15
|
+
**Rollup uses Babel or SWC for code compilation so you will also need to install [`@repodog/babel-config`](../babel-config/README.md) or [`@repodog/swc-config`](../swc-config/README.md) and the relevant peer dependencies.**
|
|
23
16
|
|
|
24
17
|
## Use package
|
|
25
18
|
|
|
@@ -62,12 +55,12 @@ module.exports = {
|
|
|
62
55
|
|
|
63
56
|
### Environment variables
|
|
64
57
|
|
|
65
|
-
`MODULE_SYSTEM` = `'esm' || 'cjs'`
|
|
58
|
+
#### `MODULE_SYSTEM` = `'esm' || 'cjs'`
|
|
66
59
|
|
|
67
60
|
Sets `output.format`, directory name within `./dist` output, and the extension of the bundled output file. Default `'esm'`.
|
|
68
61
|
|
|
69
|
-
`NODE_ENV` = `'
|
|
62
|
+
#### `NODE_ENV` = `'production' || 'development' || 'test'`
|
|
70
63
|
|
|
71
|
-
When set to `'
|
|
64
|
+
When set to `'production'`, terser mangles and compresses, the bundle analyser runs, and source maps are omitted.
|
|
72
65
|
|
|
73
66
|
**You cam also use the environment variables outlined in [`@repodog/babel-config`](../babel-config/README.md#environment-variables) or [`@repodog/swc-config`](../swc-config/README.md#environment-variables) to control what is output.**
|
package/index.cjs
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable import/no-extraneous-dependencies */
|
|
2
1
|
const commonjs = require('@rollup/plugin-commonjs');
|
|
3
2
|
const image = require('@rollup/plugin-image');
|
|
4
3
|
const json = require('@rollup/plugin-json');
|
|
@@ -11,7 +10,7 @@ const copy = require('rollup-plugin-copy');
|
|
|
11
10
|
const sourcemaps = require('rollup-plugin-sourcemaps');
|
|
12
11
|
|
|
13
12
|
const { MODULE_SYSTEM = 'esm', NODE_ENV } = process.env;
|
|
14
|
-
const isProdEnv = NODE_ENV === 'production'
|
|
13
|
+
const isProdEnv = NODE_ENV === 'production';
|
|
15
14
|
const packageDir = process.cwd();
|
|
16
15
|
const external = id => !id.startsWith('.') && !id.startsWith('/');
|
|
17
16
|
const outputExtension = MODULE_SYSTEM === 'esm' ? 'mjs' : 'cjs';
|
|
@@ -24,10 +23,11 @@ const sourcemapPathTransform = sourcePath => {
|
|
|
24
23
|
return sourcePath.replace('../../src', `../${basename(packageDir)}/src/`);
|
|
25
24
|
};
|
|
26
25
|
|
|
27
|
-
|
|
26
|
+
const config = (options = {}) => {
|
|
27
|
+
console.log(`> Using @repodog/${options.compiler.name}-config`);
|
|
28
28
|
const extensions = ['.mjs', '.cjs', '.js', '.jsx', '.json', '.ts', '.tsx'];
|
|
29
29
|
|
|
30
|
-
if (!
|
|
30
|
+
if (!options.compiler) {
|
|
31
31
|
throw new Error('config.compiler is a required option. Both babel and swc rollup plugins are supported.');
|
|
32
32
|
}
|
|
33
33
|
|
|
@@ -35,15 +35,14 @@ module.exports = (config = {}) => {
|
|
|
35
35
|
json(),
|
|
36
36
|
nodeResolve({
|
|
37
37
|
extensions,
|
|
38
|
-
preferBuiltins: true,
|
|
39
38
|
}),
|
|
40
39
|
commonjs(),
|
|
41
|
-
|
|
40
|
+
options.compiler,
|
|
42
41
|
image(),
|
|
43
42
|
];
|
|
44
43
|
|
|
45
|
-
if (
|
|
46
|
-
plugins.push(copy(
|
|
44
|
+
if (options.copy) {
|
|
45
|
+
plugins.push(copy(options.copy));
|
|
47
46
|
}
|
|
48
47
|
|
|
49
48
|
if (isProdEnv) {
|
|
@@ -57,7 +56,7 @@ module.exports = (config = {}) => {
|
|
|
57
56
|
|
|
58
57
|
writeFileSync(`${packageDir}/dist/production.analysis.txt`, analysis);
|
|
59
58
|
},
|
|
60
|
-
})
|
|
59
|
+
}),
|
|
61
60
|
);
|
|
62
61
|
}
|
|
63
62
|
|
|
@@ -70,7 +69,7 @@ module.exports = (config = {}) => {
|
|
|
70
69
|
input: `${packageDir}/src/index`,
|
|
71
70
|
onwarn: ({ code, message }) => {
|
|
72
71
|
if (code !== 'THIS_IS_UNDEFIEND') {
|
|
73
|
-
console.error(message);
|
|
72
|
+
console.error(message);
|
|
74
73
|
}
|
|
75
74
|
},
|
|
76
75
|
output: {
|
|
@@ -82,3 +81,5 @@ module.exports = (config = {}) => {
|
|
|
82
81
|
plugins,
|
|
83
82
|
};
|
|
84
83
|
};
|
|
84
|
+
|
|
85
|
+
module.exports = config;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@repodog/rollup-config",
|
|
3
3
|
"description": "The Repodog Rollup config module.",
|
|
4
|
-
"version": "1.2.
|
|
4
|
+
"version": "1.2.3-alpha-12345.0",
|
|
5
5
|
"author": "Dylan Aubrey",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://github.com/badbatch/repodog",
|
|
@@ -15,15 +15,20 @@
|
|
|
15
15
|
"publishConfig": {
|
|
16
16
|
"access": "public"
|
|
17
17
|
},
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@rollup/plugin-commonjs": "^26.0.1",
|
|
20
|
+
"@rollup/plugin-image": "^3.0.3",
|
|
21
|
+
"@rollup/plugin-json": "^6.1.0",
|
|
22
|
+
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
23
|
+
"@rollup/plugin-terser": "^0.4.4",
|
|
24
|
+
"rollup-plugin-analyzer": "^4.0.0",
|
|
25
|
+
"rollup-plugin-copy": "^3.5.0",
|
|
26
|
+
"rollup-plugin-sourcemaps": "^0.6.3"
|
|
27
|
+
},
|
|
18
28
|
"peerDependencies": {
|
|
19
|
-
"
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
"
|
|
23
|
-
"@rollup/plugin-terser": "<1",
|
|
24
|
-
"rollup": "<4",
|
|
25
|
-
"rollup-plugin-analyzer": "<5",
|
|
26
|
-
"rollup-plugin-copy": "<4",
|
|
27
|
-
"rollup-plugin-sourcemaps": "<1"
|
|
29
|
+
"rollup": "<5"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"rollup": "^4.21.2"
|
|
28
33
|
}
|
|
29
34
|
}
|