Skip to content

Commit 15aa5ad

Browse files
committed
Merge branch 'main' into pro-6673-warning-conflict-page-schema
* main: changelog (#4802) fixes modals deep selectors (#4795) fix vue warnings (#4797) Pro 6694 breakpoint preview vite ready (#4789) Resolve yaml dependency conflicts (#4801) PRO-6775: External frontend support, docs cleanup (#4799) sort glob result (#4796) HMR condition argument and widget player fix (#4794) fix permission grid tooltip display (#4792) Fix extra bundle detection (#4791) release 4.9.0 (#4788) Pro 6535 revision (#4787)
2 parents 27a177c + 99b71ba commit 15aa5ad

File tree

24 files changed

+237
-341
lines changed

24 files changed

+237
-341
lines changed

CHANGELOG.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,28 @@
22

33
## UNRELEASED
44

5+
### Fixes
6+
7+
* Extra bundle detection when using external build module works properly now.
8+
* Widget players are now properly invoked when they arrive later in the page load process.
9+
* Fix permission grid tooltip display.
10+
* Fixes a bug that crashes external frontend applications.
11+
* Fixes a false positive warning for module not in use for project level submodules (e.g. `widges/module.js`) and dot-folders (e.g. `.DS_Store`).
12+
* Bumped `express-bearer-token` dependency to address a low-severity `npm audit` warning regarding noncompliant cookie names and values. Apostrophe
13+
did not actually use any noncompliant cookie names or values, so there was no vulnerability in Apostrophe.
14+
15+
### Adds
16+
17+
* It's possible now to target the HMR build when registering via `template.append` and `template.prepend`. Use `when: 'hmr:public'` or `when: 'hmr:apos'` that will be evaluated against the current asset `options.hmr` configuration.
18+
* Adds asset module option `options.modulePreloadPolyfill` (default `true`) to allow disabling the polyfill preload for e.g. external front-ends.
19+
* Adds `bundleMarkup` to the data sent to the external front-end, containing all markup for injecting Apostrophe UI in the front-end.
20+
21+
### Changes
22+
23+
* Removes postcss plugin and webpack loader used for breakpoint preview mode. Uses instead the new `postcss-viewport-to-container-toggle` plugin in the webpack config.
24+
25+
## 4.9.0 (2024-10-31)
26+
527
### Adds
628

729
* Relationship inputs have aria accessibility tags and autocomplete suggestions can be controlled by keyboard.

index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -699,11 +699,18 @@ async function apostrophe(options, telemetry, rootSpan) {
699699
}
700700
}
701701
async function testDir(name) {
702+
if (name.startsWith('.')) {
703+
return;
704+
}
702705
// Projects that have different theme modules activated at different times
703706
// are a frequent source of false positives for this warning, so ignore
704707
// seemingly unused modules with "theme" in the name
705708
if (!validSteps.includes(name)) {
706709
try {
710+
// It's a project level modules definition, skip it.
711+
if (fs.existsSync(path.resolve(self.localModules, name, 'modules.js'))) {
712+
return;
713+
}
707714
const submodule = await self.root.import(path.resolve(self.localModules, name, 'index.js'));
708715
if (submodule && submodule.options && submodule.options.ignoreUnusedFolderWarning) {
709716
return;

modules/@apostrophecms/asset/index.js

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@ module.exports = {
9898
// Force the HMR WS port when it operates on the same process as Apostrophe.
9999
// Most of the time you won't need to change this.
100100
hmrPort: null,
101+
// Let the external build module inject a pollyfill for the module preload,
102+
// adding the `modulepreload` support for the browsers that don't support it.
103+
// Can be disabled in e.g. external front-ends.
104+
modulePreloadPolyfill: true,
101105
// Completely disable the asset runtime auto-build system.
102106
// When an external build module is registered, only manifest data
103107
// will be loaded and no build will be executed.
@@ -477,9 +481,11 @@ module.exports = {
477481
// - `devServer`: if `false`, the dev server is disabled. Otherwise, it's a string
478482
// (enum) `public` or `apos`. Note that if `hmr` is disabled, the dev server will be always
479483
// `false`.
484+
// - `modulePreloadPolyfill`: if `true`, a module preload polyfill is injected.
480485
// - `types`: optional array, if present it represents the only entrypoint types (entrypoint.type)
481486
// that should be built.
482487
// - `sourcemaps`: if `true`, the source maps are generated in production.
488+
// - `postcssViewportToContainerToggle`: the configuration for the breakpoint preview plugin.
483489
//
484490
// Note that this getter depends on the current build task arguments. You shouldn't
485491
// use that directly.
@@ -494,15 +500,22 @@ module.exports = {
494500
isTask: !argv['check-apos-build'],
495501
hmr: self.hasHMR(),
496502
hmrPort: self.options.hmrPort,
497-
sourcemaps: self.options.productionSourceMaps
503+
modulePreloadPolyfill: self.options.modulePreloadPolyfill,
504+
sourcemaps: self.options.productionSourceMaps,
505+
postcssViewportToContainerToggle: {
506+
enable: self.options.breakpointPreviewMode?.enable === true,
507+
debug: self.options.breakpointPreviewMode?.debug === true,
508+
modifierAttr: 'data-breakpoint-preview-mode',
509+
transform: self.options.breakpointPreviewMode?.transform
510+
}
498511
};
499512
options.devServer = !options.isTask && self.hasDevServer()
500513
? self.options.hmr
501514
: false;
502515

503-
// Skip all public and keep only the apos scenes.
516+
// Skip prebundled UI and keep only the apos scenes.
504517
if (!self.options.publicBundle) {
505-
options.types = [ 'apos', 'bundled' ];
518+
options.types = [ 'apos', 'index' ];
506519
}
507520

508521
return options;
@@ -627,7 +640,7 @@ module.exports = {
627640
return;
628641
}
629642

630-
// Hidrate the entrypoints with the saved manifest data and
643+
// Hydrate the entrypoints with the saved manifest data and
631644
// set the current build manifest data.
632645
const buildOptions = self.getBuildOptions();
633646
const entrypoints = await self.getBuildModule().entrypoints(buildOptions);

modules/@apostrophecms/asset/lib/build/external-module-api.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,8 @@ module.exports = (self) => {
6969
// Returns an array of objects with the following properties:
7070
// - `name`: the entrypoint name. It's usually the relative to `ui` folder
7171
// name(`src`, `apos`, `public`) or an extra bundle name.
72+
// - `label`: the human-readable label for the entrypoint, used to print CLI messages.
7273
// - `type`: (enum) the entrypoint type. It can be `index`, `apos`, `custom` (e.g. extra bundles) or
73-
// `bundled` (e.g. `ui/public`). Every type has associated manager that provides handling for the entrypoint.
74-
// - `useMeta`: if `true`, the entrypoint will be created based on the source metadata (see
75-
// `computeSourceMeta()` method).
76-
// - `bundle`: if `true`, the entrypoint should be bundled by the build module.
77-
// - `index`: if `true`, the entrypoint processes only `{name}/index.{js,scss}` module files.
78-
// - `apos`: if `true`, the entrypoint processes components, icons and apps.
7974
// - `ignoreSources`: an array of sources that shouldn't be processed when creating the entrypoint.
8075
// - `sources`: an object with `js` and `scss` arrays of extra sources to be included in the entrypoint.
8176
// These sources are not affected by the `ignoreSources` configuration.
@@ -84,10 +79,15 @@ module.exports = (self) => {
8479
// - `prologue`: a string with the prologue to be added to the entrypoint.
8580
// - `condition`: the JS `module` or `nomodule` condition. Undefined for no specific condition.
8681
// - `outputs`: an array of output extensions for the entrypoint (currently not fully utilized)
82+
// - `inputs`: an array of input extensions for the entrypoint (currently not fully utilized)
8783
// - `scenes`: an array of scenes to be in the final post-bundle step. The scenes are instructions
8884
// for the Apostrophe core to combine the builds and release them. Currently supported scenes are
8985
// `apos` and `public` and custom scene names equal to extra bundle (only those who should be
9086
// loaded separately in the browser).
87+
//
88+
// Additonal properties added after entrypoints are processed by the core and the external build module:
89+
// - `manifest`: object, see the manifest section of `configureBuildModule()` docs for more information.
90+
// - `bundles`: a `Set` containing the bundle names that this entrypoint is part of (both css and js).
9191
getBuildEntrypoints(types, recompute = false) {
9292
if (!self.hasBuildModule()) {
9393
return self.builds;
@@ -323,6 +323,7 @@ function invoke() {
323323
follow: false,
324324
absolute: false
325325
});
326+
files.sort((a, b) => a.localeCompare(b, 'en'));
326327

327328
if (stats) {
328329
// optimize fs calls

modules/@apostrophecms/asset/lib/build/internals.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ module.exports = (self) => {
8888
enhancedConfig.ignoreSources.push(...bundleConfig.scss);
8989
}
9090
// 2.3. Add the extra bundle configuration so that
91-
// it only processes the configured `sources` (`useMeta: false`).
91+
// it only processes the configured `sources`
9292
if (!bundleConfig.main) {
9393
entrypoints.push({
9494
name: bundleName,

modules/@apostrophecms/asset/lib/webpack/apos/webpack.scss.js

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,17 @@
1-
const path = require('path');
2-
const postcssReplaceViewportUnitsPlugin = require('../postcss-replace-viewport-units-plugin');
1+
const postcssViewportToContainerToggle = require('postcss-viewport-to-container-toggle');
32

43
module.exports = (options, apos) => {
54
const postcssPlugins = [
5+
...apos.asset.options.breakpointPreviewMode?.enable === true ? [
6+
postcssViewportToContainerToggle({
7+
modifierAttr: 'data-breakpoint-preview-mode',
8+
debug: apos.asset.options.breakpointPreviewMode?.debug === true,
9+
transform: apos.asset.options.breakpointPreviewMode?.transform || null
10+
})
11+
] : [],
612
'autoprefixer',
713
{}
814
];
9-
let mediaToContainerQueriesLoader = '';
10-
11-
if (apos.asset.options.breakpointPreviewMode?.enable === true) {
12-
postcssPlugins.unshift(
13-
postcssReplaceViewportUnitsPlugin()
14-
);
15-
mediaToContainerQueriesLoader = {
16-
loader: path.resolve(__dirname, '../media-to-container-queries-loader.js'),
17-
options: {
18-
debug: apos.asset.options.breakpointPreviewMode?.debug === true,
19-
transform: apos.asset.options.breakpointPreviewMode?.transform || null
20-
}
21-
};
22-
}
2315

2416
return {
2517
module: {
@@ -28,15 +20,22 @@ module.exports = (options, apos) => {
2820
test: /\.css$/,
2921
use: [
3022
'vue-style-loader',
31-
mediaToContainerQueriesLoader,
32-
'css-loader'
23+
'css-loader',
24+
{
25+
loader: 'postcss-loader',
26+
options: {
27+
sourceMap: true,
28+
postcssOptions: {
29+
plugins: [ postcssPlugins ]
30+
}
31+
}
32+
}
3333
]
3434
},
3535
{
3636
test: /\.s[ac]ss$/,
3737
use: [
3838
'vue-style-loader',
39-
mediaToContainerQueriesLoader,
4039
'css-loader',
4140
{
4241
loader: 'postcss-loader',

modules/@apostrophecms/asset/lib/webpack/media-to-container-queries-loader.js

Lines changed: 0 additions & 94 deletions
This file was deleted.

modules/@apostrophecms/asset/lib/webpack/postcss-replace-viewport-units-plugin.js

Lines changed: 0 additions & 40 deletions
This file was deleted.

modules/@apostrophecms/asset/lib/webpack/src/webpack.scss.js

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,18 @@
1-
const path = require('path');
21
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
3-
const postcssReplaceViewportUnitsPlugin = require('../postcss-replace-viewport-units-plugin');
2+
const postcssViewportToContainerToggle = require('postcss-viewport-to-container-toggle');
43

54
module.exports = (options, apos, srcBuildNames) => {
65
const postcssPlugins = [
6+
...apos.asset.options.breakpointPreviewMode?.enable === true ? [
7+
postcssViewportToContainerToggle({
8+
modifierAttr: 'data-breakpoint-preview-mode',
9+
debug: apos.asset.options.breakpointPreviewMode?.debug === true,
10+
transform: apos.asset.options.breakpointPreviewMode?.transform || null
11+
})
12+
] : [],
713
'autoprefixer',
814
{}
915
];
10-
let mediaToContainerQueriesLoader = '';
11-
12-
if (apos.asset.options.breakpointPreviewMode?.enable === true) {
13-
postcssPlugins.unshift(
14-
postcssReplaceViewportUnitsPlugin()
15-
);
16-
mediaToContainerQueriesLoader = {
17-
loader: path.resolve(__dirname, '../media-to-container-queries-loader.js'),
18-
options: {
19-
debug: apos.asset.options.breakpointPreviewMode?.debug === true,
20-
transform: apos.asset.options.breakpointPreviewMode?.transform || null
21-
}
22-
};
23-
}
2416

2517
return {
2618
module: {
@@ -30,8 +22,8 @@ module.exports = (options, apos, srcBuildNames) => {
3022
use: [
3123
// Instead of style-loader, to avoid FOUC
3224
MiniCssExtractPlugin.loader,
33-
mediaToContainerQueriesLoader,
34-
// Parses CSS imports and make css-loader ignore urls. Urls will still be handled by webpack
25+
// Parses CSS imports and make css-loader ignore urls.
26+
// Urls will still be handled by webpack
3527
{
3628
loader: 'css-loader',
3729
options: { url: false }

0 commit comments

Comments
 (0)