@digigov/cli-build 2.0.0-298cfc51 → 2.0.0-32ae417f

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/babel.common.cjs DELETED
@@ -1,119 +0,0 @@
1
- // Mostly shared from
2
- // https://github.com/mui-org/material-ui/blob/master/babel.config.js
3
- const lib = require("@digigov/cli/lib");
4
-
5
- function makeBabelConfig(dir, opts = { docs: false, proptypes: false }) {
6
- const project = lib.resolveProject(dir);
7
- const aliases = !project.externalLockFile ? lib.aliases(true) : {};
8
-
9
- const BABEL_ENV = process.env.BABEL_ENV || "esm";
10
- const BABEL_PUBLISH = process.env.BABEL_PUBLISH || false;
11
- const NODE_ENV = process.env.NODE_ENV;
12
- const IS_COMMONJS = BABEL_ENV === "cjs" || NODE_ENV === "test";
13
-
14
- const PRESETS = [
15
- [
16
- require.resolve("@babel/preset-env"),
17
- {
18
- modules: IS_COMMONJS ? "commonjs" : false,
19
- },
20
- ],
21
- require.resolve("@babel/preset-react"),
22
- ];
23
-
24
- if (project.isTs) {
25
- PRESETS.push(require.resolve("@babel/preset-typescript"));
26
- }
27
-
28
- const PLUGINS_COMMON = [
29
- require.resolve("babel-plugin-optimize-clsx"),
30
- [
31
- require.resolve("@babel/plugin-proposal-class-properties"),
32
- { loose: true },
33
- ],
34
- [
35
- require.resolve("@babel/plugin-proposal-object-rest-spread"),
36
- { loose: true },
37
- ],
38
- // any package needs to declare 7.4.4 as a runtime dependency. default is ^7.0.0
39
- [require.resolve("@babel/plugin-transform-runtime"), { version: "^7.4.4" }],
40
- // for IE 11 support
41
- require.resolve("@babel/plugin-transform-object-assign"),
42
- require.resolve("babel-plugin-transform-react-constant-elements"),
43
- ];
44
-
45
- const PLUGINS_PUBLISH = [
46
- require.resolve("babel-plugin-transform-dev-warning"),
47
- [
48
- require.resolve("babel-plugin-react-remove-properties"),
49
- { properties: ["data-testid"] },
50
- ],
51
- [
52
- require.resolve("babel-plugin-transform-react-remove-prop-types"),
53
- {
54
- mode: "unsafe-wrap",
55
- },
56
- ],
57
- ];
58
-
59
- const PLUGINS = PLUGINS_COMMON;
60
-
61
- // Apps images are handled using `next-images` plugin. For libraries there is no
62
- // explicit way to provide assets to the App using the library. While not
63
- // considered a very good practice, one way to provide images via libraries is
64
- // to embed the image data into the library code.
65
- if (project.isLib || project.isApp) {
66
- PLUGINS.push(require.resolve("babel-plugin-inline-import-data-uri"));
67
- }
68
-
69
- if (BABEL_PUBLISH) {
70
- PLUGINS.push(...PLUGINS_PUBLISH);
71
- }
72
-
73
- if (!opts.docs) {
74
- let resolverAlias = {};
75
- if (NODE_ENV === "test") resolverAlias = aliases;
76
- if (BABEL_ENV === "cjs") {
77
- resolverAlias = Object.keys(aliases).reduce((acc, key) => {
78
- if (key !== project.name) {
79
- acc[`^${key}/(.+)`] = `${key}/cjs/\\1`;
80
- }
81
- return acc;
82
- }, {});
83
- }
84
-
85
- const RESOLVER = [
86
- require.resolve("babel-plugin-module-resolver"),
87
- {
88
- alias: resolverAlias,
89
- extensions: [".js", ".jsx", ".ts", ".tsx", ".json"],
90
- loglevel: "silent",
91
- },
92
- ];
93
- PLUGINS.push(RESOLVER);
94
- }
95
-
96
- if (project.isApp) {
97
- PRESETS.push(require.resolve("next/babel"));
98
- }
99
-
100
- const CONFIG = {
101
- presets: PRESETS,
102
- plugins: PLUGINS,
103
- ignore: [/@babel[\\|/]runtime/],
104
- env: {
105
- coverage: {
106
- plugins: [require.resolve("babel-plugin-istanbul")],
107
- },
108
- test: {
109
- sourceMaps: "both",
110
- plugins: [],
111
- },
112
- },
113
- };
114
- return CONFIG;
115
- }
116
- module.exports = {
117
- makeBabelConfig,
118
- config: makeBabelConfig(),
119
- };
package/babel.config.cjs DELETED
@@ -1 +0,0 @@
1
- module.exports = require("./babel.common.cjs").config;