@openeuropa/bcl-builder 1.10.11 → 1.12.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 CHANGED
@@ -97,11 +97,11 @@ We've also added some new variables that overwrite and make use of extra classes
97
97
  Step 1:
98
98
  Depending on your package manager:
99
99
 
100
- Yarn:
100
+ PNPM:
101
101
 
102
- - yarn add @openeuropa/bcl-builder --save
103
- - yarn add @openeuropa/bcl-bootstrap --save
104
- - yarn add @openeuropa/bcl-theme-default --save
102
+ - pnpm add @openeuropa/bcl-builder
103
+ - pnpm add @openeuropa/bcl-bootstrap
104
+ - pnpm add @openeuropa/bcl-theme-default
105
105
 
106
106
  NPM:
107
107
 
package/package.json CHANGED
@@ -2,40 +2,35 @@
2
2
  "name": "@openeuropa/bcl-builder",
3
3
  "author": "European Commission",
4
4
  "license": "EUPL-1.2",
5
- "version": "1.10.11",
5
+ "version": "1.12.0",
6
6
  "description": "Bootstrap Component Library builder",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },
10
10
  "bin": "./bin/build.js",
11
11
  "dependencies": {
12
- "@babel/core": "7.28.4",
13
- "@babel/preset-env": "7.28.3",
14
- "@babel/runtime": "7.28.4",
12
+ "@babel/core": "7.29.0",
13
+ "@babel/preset-env": "7.29.0",
14
+ "@babel/runtime": "7.28.6",
15
15
  "@popperjs/core": "2.11.8",
16
16
  "@rollup/plugin-babel": "6.1.0",
17
- "@rollup/plugin-commonjs": "28.0.7",
17
+ "@rollup/plugin-commonjs": "29.0.0",
18
18
  "@rollup/plugin-node-resolve": "16.0.3",
19
- "@rollup/plugin-replace": "6.0.2",
20
- "autoprefixer": "10.4.21",
21
- "babel-eslint": "10.1.0",
22
- "browser-sync": "3.0.4",
23
- "commander": "14.0.1",
19
+ "@rollup/plugin-replace": "6.0.3",
20
+ "@rollup/plugin-terser": "1.0.0",
21
+ "autoprefixer": "10.4.24",
22
+ "commander": "14.0.3",
24
23
  "copyfiles": "2.4.1",
25
24
  "cross-env": "10.1.0",
26
- "cssnano": "7.1.1",
27
- "eslint": "^9.37.0",
25
+ "cssnano": "7.1.2",
28
26
  "postcss": "8.5.6",
29
27
  "postcss-prefix-selector": "^2.1.1",
30
- "rollup": "4.52.4",
31
- "rollup-plugin-istanbul": "5.0.0",
32
- "rollup-plugin-terser": "7.0.2",
33
- "sass": "1.93.2",
34
- "svg-sprite": "2.0.4",
35
- "svgo": "4.0.0"
28
+ "rollup": "4.59.0",
29
+ "sass": "1.98.0",
30
+ "svg-sprite": "2.0.4"
36
31
  },
37
32
  "engines": {
38
- "node": ">=14.0.0"
33
+ "node": ">=22.0.0"
39
34
  },
40
- "gitHead": "82aecf2f60f8bd8f9afd447ea0d044396f085823"
35
+ "gitHead": "6d1138cf7e70db692c0aae7a598977de7004204e"
41
36
  }
@@ -22,6 +22,7 @@
22
22
  const sass = require("sass");
23
23
  const path = require("path");
24
24
  const fs = require("fs");
25
+ const { pathToFileURL } = require("url");
25
26
  const postcss = require("postcss");
26
27
  const cssnano = require("cssnano");
27
28
  const prefixer = require("postcss-prefix-selector");
@@ -39,6 +40,19 @@ const getPlugins = (options) => {
39
40
  return plugins;
40
41
  };
41
42
 
43
+ const resolveThemeSource = (includePaths, localPath, packagePath) => {
44
+ const candidates = [
45
+ ...(includePaths || []).map((basePath) =>
46
+ path.resolve(basePath, packagePath),
47
+ ),
48
+ // Keep installed package resolution first for compatibility, and only
49
+ // fall back to local workspace sources when building this monorepo.
50
+ path.resolve(process.cwd(), localPath),
51
+ ];
52
+
53
+ return candidates.find((candidate) => fs.existsSync(candidate));
54
+ };
55
+
42
56
  const buildColorScheme = (entry, dest, options) => {
43
57
  const plugins = getPlugins(options);
44
58
 
@@ -51,37 +65,57 @@ const buildColorScheme = (entry, dest, options) => {
51
65
 
52
66
  // Read contents of the entry file and the base color scheme SCSS file
53
67
  const entryVariables = fs.readFileSync(entry, "utf8");
54
- const imports = fs.readFileSync(
55
- path.resolve(
56
- ...(options.includePaths || []),
57
- "@openeuropa/bcl-theme-default/src/scss/color-scheme.scss",
58
- ),
59
- "utf8",
68
+ const importsPath = resolveThemeSource(
69
+ options.includePaths,
70
+ "src/scss/color-scheme.scss",
71
+ "@openeuropa/bcl-theme-default/src/scss/color-scheme.scss",
60
72
  );
61
- const generator = fs.readFileSync(
62
- path.resolve(
63
- ...(options.includePaths || []),
64
- "@openeuropa/bcl-theme-default/src/scss/color_scheme/generator.scss",
65
- ),
66
- "utf8",
73
+ const generatorPath = resolveThemeSource(
74
+ options.includePaths,
75
+ "src/scss/color_scheme/generator.scss",
76
+ "@openeuropa/bcl-theme-default/src/scss/color_scheme/generator.scss",
67
77
  );
68
78
 
79
+ if (!importsPath || !generatorPath) {
80
+ throw new Error(
81
+ "Could not resolve the default theme color-scheme sources.",
82
+ );
83
+ }
84
+
85
+ const imports = fs.readFileSync(importsPath, "utf8");
86
+ const generator = fs.readFileSync(generatorPath, "utf8");
87
+
69
88
  // Concatenate the contents
70
89
  const scssContent = imports + "\n" + entryVariables + "\n" + generator;
71
90
 
72
- const sassResult = sass.renderSync({
73
- data: scssContent,
74
- outFile: dest,
75
- noErrorCss: true,
76
- outputStyle: "expanded",
91
+ const compileOptions = {
92
+ style: "expanded",
77
93
  sourceMap: options.sourceMap !== false,
78
- sourceMapContents: options.sourceMap === true,
79
- sourceMapEmbed: options.sourceMap === true,
80
- includePaths: [
94
+ sourceMapIncludeSources: options.sourceMap === true,
95
+ url: pathToFileURL(entry),
96
+ loadPaths: [
97
+ path.dirname(importsPath),
98
+ path.dirname(generatorPath),
81
99
  path.resolve(process.cwd(), "node_modules"),
82
100
  ...(options.includePaths || []),
83
101
  ],
84
- });
102
+ };
103
+
104
+ const silencedDeprecations = Array.isArray(options.silenceDeprecations)
105
+ ? options.silenceDeprecations
106
+ : undefined;
107
+
108
+ if (silencedDeprecations && silencedDeprecations.length) {
109
+ compileOptions.silenceDeprecations = silencedDeprecations;
110
+ }
111
+
112
+ if (typeof options.quietDeps !== "undefined") {
113
+ compileOptions.quietDeps = options.quietDeps;
114
+ } else if (silencedDeprecations && silencedDeprecations.length) {
115
+ compileOptions.quietDeps = true;
116
+ }
117
+
118
+ const sassResult = sass.compileString(scssContent, compileOptions);
85
119
 
86
120
  postcss(plugins)
87
121
  .use(
@@ -106,7 +140,7 @@ const buildColorScheme = (entry, dest, options) => {
106
140
  .process(sassResult.css, {
107
141
  map:
108
142
  postcssSourceMap === "file"
109
- ? { inline: false, prev: sassResult.map.toString() }
143
+ ? { inline: false, prev: JSON.stringify(sassResult.sourceMap) }
110
144
  : postcssSourceMap,
111
145
  from: entry,
112
146
  to: dest,
@@ -36,7 +36,7 @@ const { babel } = require("@rollup/plugin-babel");
36
36
  const { nodeResolve } = require("@rollup/plugin-node-resolve");
37
37
  const babelPresetEnv = require("@babel/preset-env");
38
38
  const rollup = require("rollup");
39
- const { terser } = require("rollup-plugin-terser");
39
+ const terser = require("@rollup/plugin-terser");
40
40
 
41
41
  module.exports = (input, dest, options) => {
42
42
  const plugins = [
package/scripts/sprite.js CHANGED
@@ -66,15 +66,17 @@ module.exports = (entry, dest, options) => {
66
66
  });
67
67
 
68
68
  files.forEach((file) => {
69
- let filePath;
70
- if (Array.isArray(entry)) {
71
- filePath = path.resolve(entry[0], file);
72
- if (!fs.existsSync(filePath)) {
73
- filePath = path.resolve(entry[1], file);
74
- }
75
- } else {
76
- filePath = path.resolve(entry, file);
69
+ const entryPaths = Array.isArray(entry) ? entry : [entry];
70
+ const filePath = entryPaths
71
+ .map((entryPath) => path.resolve(entryPath, file))
72
+ .find((resolvedPath) => fs.existsSync(resolvedPath));
73
+
74
+ if (!filePath) {
75
+ throw new Error(
76
+ `Could not resolve sprite source "${file}" from: ${entryPaths.join(", ")}`,
77
+ );
77
78
  }
79
+
78
80
  spriter.add(
79
81
  filePath,
80
82
  file,
package/scripts/styles.js CHANGED
@@ -49,15 +49,10 @@ const buildStyles = (entry, dest, options) => {
49
49
  postcssSourceMap = options.sourceMap; // as a file
50
50
  }
51
51
 
52
- const renderOptions = {
53
- file: entry,
54
- outFile: dest,
55
- noErrorCss: true,
56
- outputStyle: "expanded",
52
+ const compileOptions = {
53
+ style: "expanded",
57
54
  sourceMap: options.sourceMap !== false,
58
- sourceMapContents: options.sourceMap === true,
59
- sourceMapEmbed: options.sourceMap === true,
60
- includePaths: [
55
+ loadPaths: [
61
56
  path.resolve(process.cwd(), "node_modules"),
62
57
  ...(options.includePaths || []),
63
58
  ],
@@ -68,16 +63,16 @@ const buildStyles = (entry, dest, options) => {
68
63
  : undefined;
69
64
 
70
65
  if (silencedDeprecations && silencedDeprecations.length) {
71
- renderOptions.silenceDeprecations = silencedDeprecations;
66
+ compileOptions.silenceDeprecations = silencedDeprecations;
72
67
  }
73
68
 
74
69
  if (typeof options.quietDeps !== "undefined") {
75
- renderOptions.quietDeps = options.quietDeps;
70
+ compileOptions.quietDeps = options.quietDeps;
76
71
  } else if (silencedDeprecations && silencedDeprecations.length) {
77
- renderOptions.quietDeps = true;
72
+ compileOptions.quietDeps = true;
78
73
  }
79
74
 
80
- const sassResult = sass.renderSync(renderOptions);
75
+ const sassResult = sass.compile(entry, compileOptions);
81
76
 
82
77
  const processor = postcss(plugins);
83
78
  if (options.prefix) {
@@ -93,7 +88,7 @@ const buildStyles = (entry, dest, options) => {
93
88
  .process(sassResult.css, {
94
89
  map:
95
90
  postcssSourceMap === "file"
96
- ? { inline: false, prev: sassResult.map.toString() }
91
+ ? { inline: false, prev: JSON.stringify(sassResult.sourceMap) }
97
92
  : postcssSourceMap,
98
93
  from: entry,
99
94
  to: dest,