Skip to content

Conversation

@haroun
Copy link
Contributor

@haroun haroun commented Jun 14, 2024

Summary

Add ESM support

What are the specific steps to test this change?

  1. npm test
  2. you can use starter kit essentials ESM branch https://github.com/apostrophecms/starter-kit-essentials/tree/esm
  3. you can use starter kit assembly essentials ESM branch https://github.com/apostrophecms/starter-kit-assembly-essentials/tree/esm

What kind of change does this PR introduce?

(Check at least one)

  • Bug fix
  • New feature
  • Refactor
  • Documentation
  • Build-related changes
  • Other

Make sure the PR fulfills these requirements:

  • It includes a) the existing issue ID being resolved, b) a convincing reason for adding this feature, or c) a clear description of the bug it resolves
  • The changelog is updated
  • Related documentation has been updated
  • Related tests have been updated

If adding a new feature without an already open issue, it's best to open a feature request issue first and wait for approval before working on it.

Other information:

@haroun haroun self-assigned this Jun 14, 2024
Copy link
Member

@boutell boutell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excited that you're working on this. Some comments re: uniqueness issues that might or might not still be a real thing.

Copy link
Member

@boutell boutell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excited that you're working on this. Some comments re: uniqueness issues that might or might not still be a real thing.

Copy link
Member

@boutell boutell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excited that you're working on this. Some comments re: uniqueness issues that might or might not still be a real thing.

stuartromanek and others added 25 commits August 26, 2024 16:46
* upstream/main: (77 commits)
  PRO-6578: auto import of inline images (apostrophecms#4723)
  Inline array improvements (apostrophecms#4671)
  take credit for the fix as well as the "change" (apostrophecms#4725)
  PRO-6576 fix default values for object fields in widgets and generally unify newInstance implementations (apostrophecms#4722)
  release 4.7.0 (apostrophecms#4717)
  allows to render widgets in published mode (for non localized with pu… (apostrophecms#4709)
  fix subfield imports (it was a bug in fetchRelationships: false) (apostrophecms#4715)
  Add replaces configuration for editor context menus (apostrophecms#4714)
  bump uploadfs dep (apostrophecms#4712)
  add batch operations to pages (apostrophecms#4684)
  PRO-6477 undhandled promise errors (apostrophecms#4700)
  fix slat order (apostrophecms#4710)
  make apostoggle accessible (apostrophecms#4708)
  Improve context menu positions (apostrophecms#4706)
  remove focus blockers in page relationship editor (apostrophecms#4702)
  Release 4.6.1 mergeback (apostrophecms#4703)
  remove z-index bump on area schema fields, boost menu index (apostrophecms#4699)
  Pro 6345 fix deprecated sass (apostrophecms#4640)
  Keep widget focused when menu is open (apostrophecms#4695)
  skipReplace for changeDocIds (apostrophecms#4694)
  ...
haroun added 5 commits October 9, 2024 13:06
* upstream/PRO-4505/modal-priority:
  Modify disabled prop (apostrophecms#4744)
  Fix media manager not handling search results properly (sometimes)
  flex media manager containers
  remove conditional rendering
  lint
  fix line
  wip
  split button focus, widget priority button
  make sure we have modal
  restore focus to last selected item after prop change
  remove logs
  focus considerations for media uploader
  switch promise timeout for nexttick
  retry
  wip
  wip
* upstream/main:
  Focus prioritized UI in on modal open (apostrophecms#4707)
  fix a rare race condition (apostrophecms#4755)
  prevent un-publishing singletons (apostrophecms#4739)
  PRO-6660: modules order (apostrophecms#4745)
  remove unused vue-template-compiler dependency (apostrophecms#4752)
  Fix pnpm: true (apostrophecms#4750)
* upstream/main:
  reverts fn that determines the appropriate priority ui in editor modals. awaits trapfocus (apostrophecms#4765)
  Hotfix changelog (apostrophecms#4758)
@haroun haroun requested review from boutell and myovchev October 11, 2024 15:55
Copy link
Member

@boutell boutell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good stuff, minor notes

* upstream/main:
  handle viewport values for breakpoint preview (apostrophecms#4748)
  Pro 6678 mobile preview dropdown (apostrophecms#4768)
  Fix menu focus (apostrophecms#4767)
  Update changelog for translations (apostrophecms#4766)
  [generate] Translate to German (apostrophecms#4759)
  [generate] Translate to Spanish (apostrophecms#4760)
  [generate] Translate to French (apostrophecms#4761)
  [generate] Translate to Italian (apostrophecms#4762)
  [generate] Translate to Portuguese (Brazil) (apostrophecms#4763)
  [generate] Translate to Slovak (apostrophecms#4764)
@haroun haroun requested a review from boutell October 18, 2024 16:57
@haroun haroun marked this pull request as ready for review October 18, 2024 17:01
* upstream/main:
  Breakpoint clear (apostrophecms#4769)
  sass import warning (apostrophecms#4776)
  PRO-6657: Following values for dynamic choices (apostrophecms#4770)
  warnDev now prefixes in the expected way (apostrophecms#4746)
  Pro 6666 page move setting page as modified (apostrophecms#4771)
Copy link
Member

@boutell boutell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm trying out ESM, and I tried the incremental path of renaming app.js to app.mjs and making it an ES module, and leaving everything else alone to start. That seems to work fine. The page manager comes up OK, for instance.

Then I tried changing modules/default-page/index.js to index.mjs and exporting its contents the ESM way. This fails, the page manager does not show anything and I get browser console errors. If I click New Page, I get a server console error.

Is this kind of incremental transition approach supported? It seems it would be hard to transition otherwise as people will have a mix of module versions etc.

My code is in incremental-esm in testbed. I start it manually with node app.mjs as I haven't touched package.json.

@apostrophecms/page: api-error: manager.newInstance is not a function
 {
  module: '@apostrophecms/page',
  type: 'api-error',
  severity: 'error',
  url: '/api/v1/@apostrophecms/page?aposMode=draft&aposLocale=en',
  path: '/api/v1/@apostrophecms/page',
  method: 'POST',
  ip: '::1',
  query: { aposMode: 'draft', aposLocale: 'en' },
  requestId: 'n3truoelseeqybl6xgwoun9t',
  name: 'error',
  status: 500,
  stack: [
    'at Object.newChild (/Users/boutell/apostrophecms/apostrophe/modules/@apostrophecms/page/index.js:1411:30)',
    'at post (/Users/boutell/apostrophecms/apostrophe/modules/@apostrophecms/page/index.js:465:21)',
    'at process.processTicksAndRejections (node:internal/process/task_queues:95:5)',
    'at async /Users/boutell/apostrophecms/apostrophe/modules/@apostrophecms/module/index.js:191:30'
  ],
  errorPath: undefined,
  data: {}
}

image

Copy link
Member

@boutell boutell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bug is not a bug. We will document that you can't mix .js and .mjs, you must go all the way to "type": "module" and update your .js to ESM syntax.

@haroun haroun merged commit da72efc into apostrophecms:main Oct 25, 2024
9 checks passed
haroun added a commit that referenced this pull request Oct 25, 2024
* main:
  add support for ESM (#4590)
  Sass import warning (#4778)
  Breakpoint clear (#4769)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants