@atomicsmash/compiler 0.2.0 → 0.2.2

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAkBA,OAAO,CAAC,MAAM,CAAC;IAEd,UAAU,MAAM,CAAC;QAEhB,UAAU,UAAU;YACnB,QAAQ,EAAE,YAAY,GAAG,aAAa,GAAG,MAAM,GAAG,SAAS,CAAC;SAC5D;KACD;CACD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAqBA,OAAO,CAAC,MAAM,CAAC;IAEd,UAAU,MAAM,CAAC;QAEhB,UAAU,UAAU;YACnB,QAAQ,EAAE,YAAY,GAAG,aAAa,GAAG,MAAM,GAAG,SAAS,CAAC;SAC5D;KACD;CACD"}
package/dist/index.js CHANGED
@@ -2,7 +2,9 @@
2
2
  import { sep as pathSeparator, extname, resolve as resolvePath, } from "node:path";
3
3
  import DependencyExtractionWebpackPlugin from "@wordpress/dependency-extraction-webpack-plugin";
4
4
  import CopyPlugin from "copy-webpack-plugin";
5
+ import cssNano from "cssnano";
5
6
  import glob from "fast-glob";
7
+ import postCSSPresetEnv from "postcss-preset-env";
6
8
  import SVGSpritemapPlugin from "svg-spritemap-webpack-plugin";
7
9
  import { TsconfigPathsPlugin } from "tsconfig-paths-webpack-plugin";
8
10
  import webpack from "webpack";
@@ -40,20 +42,35 @@ const MODE = process.env.NODE_ENV === "development" || process.env.NODE_ENV ===
40
42
  : "production";
41
43
  const srcFolder = resolvePath(argv.in);
42
44
  const distFolder = resolvePath(argv.out);
45
+ // @ts-expect-error -- Module doesn't need to be installed in compiler package.
46
+ const tailwindPostCSSPlugin = await import("@tailwindcss/postcss")
47
+ .then((tailwindPostCSS) => [
48
+ tailwindPostCSS.default,
49
+ ])
50
+ .catch(async () =>
51
+ // @ts-expect-error -- Module doesn't need to be installed in compiler package.
52
+ await import("tailwindcss")
53
+ .then((tailwindcss) => [tailwindcss.default])
54
+ .catch(() => []));
43
55
  const postCSSConfig = [
44
56
  [
45
- "tailwindcss",
46
- "postcss-preset-env",
47
- {
57
+ ...tailwindPostCSSPlugin,
58
+ postCSSPresetEnv({
48
59
  stage: 2,
49
60
  features: {
50
61
  "custom-media-queries": true,
51
62
  },
52
- },
63
+ }),
53
64
  ],
54
- ...(MODE === "production" ? ["cssnano"] : []),
65
+ ...(MODE === "production" ? [cssNano] : []),
55
66
  ];
56
67
  const compiler = webpack({
68
+ resolveLoader: {
69
+ modules: [
70
+ "node_modules",
71
+ resolvePath(import.meta.dirname, "../", "node_modules"),
72
+ ],
73
+ },
57
74
  devtool: MODE === "development" ? "source-map" : false,
58
75
  mode: MODE,
59
76
  experiments: {
@@ -94,7 +111,7 @@ const compiler = webpack({
94
111
  use: {
95
112
  loader: "babel-loader",
96
113
  options: {
97
- presets: [["@babel/preset-typescript"], ["@babel/preset-env"]],
114
+ presets: ["@babel/preset-typescript", "@babel/preset-env"],
98
115
  },
99
116
  },
100
117
  exclude: /node_modules/,
@@ -219,10 +236,18 @@ if (argv.watch) {
219
236
  else if (stats) {
220
237
  const info = stats.toJson();
221
238
  if (stats.hasErrors()) {
222
- console.error(info.errors);
239
+ const errors = info.errors;
240
+ console.warn("The compiler produced the following errors: \n");
241
+ for (const error of errors) {
242
+ console.warn(error.message);
243
+ }
223
244
  }
224
245
  if (stats.hasWarnings()) {
225
- console.warn(info.warnings);
246
+ const warnings = info.warnings;
247
+ console.warn("The compiler produced the following warnings: \n");
248
+ for (const warning of warnings) {
249
+ console.warn(warning.message);
250
+ }
226
251
  }
227
252
  }
228
253
  });
@@ -241,12 +266,22 @@ else {
241
266
  else if (stats) {
242
267
  const info = stats.toJson();
243
268
  if (stats.hasErrors()) {
244
- console.error(info.errors);
269
+ const errors = info.errors;
270
+ console.warn("The compiler produced the following errors: \n");
271
+ for (const error of errors) {
272
+ console.warn(error.message);
273
+ }
245
274
  process.exitCode = 1;
246
275
  }
247
276
  if (stats.hasWarnings()) {
248
- console.warn(info.warnings);
249
- process.exitCode = 2;
277
+ const warnings = info.warnings;
278
+ console.warn("The compiler produced the following warnings: \n");
279
+ for (const warning of warnings) {
280
+ console.warn(warning.message);
281
+ }
282
+ if (!stats.hasErrors()) {
283
+ process.exitCode = 2;
284
+ }
250
285
  }
251
286
  }
252
287
  compiler.close((closeError) => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@atomicsmash/compiler",
3
3
  "type": "module",
4
- "version": "0.2.0",
4
+ "version": "0.2.2",
5
5
  "description": "A universal compiler for all Atomic Smash projects.",
6
6
  "keywords": [
7
7
  "cli",