adapt-authoring-ui 3.0.4 → 3.0.5

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.
@@ -441,6 +441,9 @@ export default class JavaScriptTask {
441
441
  const outputOptions = {
442
442
  file: options.out,
443
443
  format: 'amd',
444
+ // Pin to Rollup v2 output defaults (changed in v4) so the AMD bundle is unaffected by the upgrade
445
+ interop: 'compat',
446
+ esModule: true,
444
447
  plugins: [
445
448
  !isSourceMapped && terser({
446
449
  mangle: false,
package/lib/UiModule.js CHANGED
@@ -1,6 +1,5 @@
1
1
  import { AbstractModule, Hook } from 'adapt-authoring-core'
2
2
  import path from 'path'
3
- import UiBuild from './UiBuild.js'
4
3
 
5
4
  const CSP_POLICY = [
6
5
  "default-src 'self'",
@@ -87,6 +86,7 @@ class UiModule extends AbstractModule {
87
86
  * @return {Promise}
88
87
  */
89
88
  async build () {
89
+ const { default: UiBuild } = await import('./UiBuild.js')
90
90
  const build = new UiBuild({
91
91
  app: this.app,
92
92
  log: this.log.bind(this),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adapt-authoring-ui",
3
- "version": "3.0.4",
3
+ "version": "3.0.5",
4
4
  "description": "Front-end application for the Adapt authoring tool",
5
5
  "homepage": "https://github.com/adapt-security/adapt-authoring-ui",
6
6
  "license": "GPL-3.0",
@@ -17,7 +17,7 @@
17
17
  "@babel/plugin-transform-react-jsx": "^7.20.13",
18
18
  "@babel/preset-env": "^7.23.9",
19
19
  "@babel/preset-react": "^7.18.6",
20
- "@rollup/plugin-babel": "^6.0.3",
20
+ "@rollup/plugin-babel": "^7.1.0",
21
21
  "@rollup/plugin-commonjs": "^29.0.0",
22
22
  "@rollup/plugin-node-resolve": "^16.0.3",
23
23
  "@rollup/plugin-terser": "^1.0.0",
@@ -32,9 +32,9 @@
32
32
  "magic-string": "^0.30.0",
33
33
  "requirejs": "^2.3.6",
34
34
  "resolve": "^1.22.2",
35
- "rollup": "^2.79.1",
35
+ "rollup": "^4.61.0",
36
36
  "rollup-plugin-inject-process-env": "*",
37
- "upath": "^2.0.1"
37
+ "upath": "^3.0.7"
38
38
  },
39
39
  "peerDependencies": {
40
40
  "adapt-authoring-adaptframework": "^3.0.0",
@@ -0,0 +1,84 @@
1
+ import { describe, it, before, after } from 'node:test'
2
+ import assert from 'node:assert/strict'
3
+ import os from 'node:os'
4
+ import path from 'node:path'
5
+ import fs from 'fs-extra'
6
+ import { rollup } from 'rollup'
7
+ import { babel } from '@rollup/plugin-babel'
8
+ import { nodeResolve } from '@rollup/plugin-node-resolve'
9
+ import commonjs from '@rollup/plugin-commonjs'
10
+ import terser from '@rollup/plugin-terser'
11
+
12
+ /**
13
+ * Integration smoke test for the Rollup build. Unlike the pure-utility specs,
14
+ * this drives a real rollup() build through the same plugin stack and output
15
+ * options that lib/JavaScriptTask.js uses, so a breaking Rollup major upgrade
16
+ * (e.g. the v2 -> v4 jump) fails CI instead of silently shipping a broken
17
+ * adapt.min.js. It exercises: the native v4 parser, commonjs/node-resolve/babel
18
+ * plugin compatibility, the AMD output format and the interop/esModule pins.
19
+ */
20
+ describe('JavaScriptTask rollup build (integration)', () => {
21
+ let tmpDir
22
+ let entry
23
+ let out
24
+
25
+ before(() => {
26
+ tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'jstask-build-'))
27
+ // a CommonJS dependency, to exercise @rollup/plugin-commonjs + interop
28
+ fs.writeFileSync(path.join(tmpDir, 'cjsDep.js'), 'module.exports = { greet: name => "hi " + name }\n')
29
+ // a JSX component, to exercise @babel/preset-react under the v4 plugin API
30
+ fs.writeFileSync(path.join(tmpDir, 'widget.jsx'), 'export default () => <div className="widget">hello</div>\n')
31
+ entry = path.join(tmpDir, 'entry.js')
32
+ fs.writeFileSync(entry, [
33
+ 'import cjsDep from "./cjsDep.js"',
34
+ 'import Widget from "./widget.jsx"',
35
+ 'export default { greeting: cjsDep.greet("adapt"), Widget }'
36
+ ].join('\n') + '\n')
37
+ out = path.join(tmpDir, 'adapt.min.js')
38
+ })
39
+
40
+ after(() => {
41
+ fs.removeSync(tmpDir)
42
+ })
43
+
44
+ it('bundles the plugin stack into a loadable AMD module with the v2-compatible output options', async () => {
45
+ const bundle = await rollup({
46
+ input: entry,
47
+ shimMissingExports: true,
48
+ plugins: [
49
+ commonjs(),
50
+ nodeResolve({ browser: true, preferBuiltins: false }),
51
+ babel({
52
+ babelHelpers: 'bundled',
53
+ extensions: ['.js', '.jsx'],
54
+ presets: [
55
+ ['@babel/preset-react', { runtime: 'classic' }],
56
+ ['@babel/preset-env', { useBuiltIns: false }]
57
+ ]
58
+ })
59
+ ]
60
+ })
61
+
62
+ await bundle.write({
63
+ file: out,
64
+ format: 'amd',
65
+ // these mirror the migration-sensitive pins in lib/JavaScriptTask.js
66
+ interop: 'compat',
67
+ esModule: true,
68
+ plugins: [terser({ mangle: false, compress: false })],
69
+ amd: { define: 'require' },
70
+ footer: 'window.__AMD = function(id, value) { window.define(id, function() { return value; }); window.require([id]); return value; };',
71
+ strict: true
72
+ })
73
+ await bundle.close()
74
+
75
+ const code = fs.readFileSync(out, 'utf8')
76
+ assert.ok(code.length > 0, 'bundle should not be empty')
77
+ // amd.define: 'require' renames the AMD wrapper function from define to require
78
+ assert.match(code, /require\(\[/)
79
+ // esModule: true emits the interop marker for the default export
80
+ assert.match(code, /__esModule/)
81
+ // the custom footer must survive into the output
82
+ assert.match(code, /window\.__AMD/)
83
+ })
84
+ })