Skip to content
This repository has been archived by the owner on Jan 27, 2025. It is now read-only.

[No Ticket] Fully convert to mjs & adjust babel and test options #348

Merged
merged 5 commits into from
Mar 11, 2024

Conversation

mschuwalow
Copy link
Contributor

Author Todo List:

  • Add/adjust tests (if applicable)
  • Build in CI passes
  • Latest master revision is merged into the branch
  • Self-Review
  • Set Ready For Review status

@mschuwalow mschuwalow self-assigned this Mar 6, 2024
@mschuwalow mschuwalow requested a review from a team as a code owner March 6, 2024 12:38
@mschuwalow mschuwalow changed the title [No Ticket] Adjust babel and test options [No Ticket] Fully convert to mjs & adjust babel and test options Mar 6, 2024
sourcemap: true
dir: OUTPUT_DIR,
entryFileNames: '[name].cjs',
chunkFileNames: '[name]-[hash].cjs',
Copy link
Contributor

Choose a reason for hiding this comment

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

Why chunks? Are you splitting it?

Copy link
Contributor Author

@mschuwalow mschuwalow Mar 6, 2024

Choose a reason for hiding this comment

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

This is internally used by rollup. By default it will generate them with plain .js extension, but if we switch to module, we need to give them explicit .cjs extension (as they are commonjs).

Example:

❯ la dist
Permissions Size User       Group Date Modified Git Name
.rw-r--r--   585 mschuwalow staff  6 Mar 17:09   -I index.cjs
.rw-r--r--   276 mschuwalow staff  6 Mar 17:09   -I index.cjs.map
.rw-r--r--   307 mschuwalow staff  6 Mar 17:09   -I index.cjs.mjs
.rw-r--r--  2.9k mschuwalow staff  6 Mar 17:09   -I index.d.ts
.rw-r--r--   66k mschuwalow staff  6 Mar 17:09   -I initializer-me88Mdta.cjs
.rw-r--r--   64k mschuwalow staff  6 Mar 17:09   -I initializer-me88Mdta.cjs.map
.rw-r--r--   584 mschuwalow staff  6 Mar 17:09   -I internal.cjs
.rw-r--r--   107 mschuwalow staff  6 Mar 17:09   -I internal.cjs.map
.rw-r--r--   470 mschuwalow staff  6 Mar 17:09   -I internal.cjs.mjs
.rw-r--r--  1.1k mschuwalow staff  6 Mar 17:09   -I internal.d.ts
.rw-r--r--  6.6k mschuwalow staff  6 Mar 17:09   -I standard-live-connect.d-CGhFVSFd.d.ts

initializer-* are the ones affected by this setting

@@ -1,5 +1,5 @@
import { EventBus, isObject, expiresInDays } from 'live-connect-common'
import { WrappedStorageHandler } from './handlers/storage-handler'
import { WrappedStorageHandler } from './handlers/storage-handler.js'
Copy link
Contributor

Choose a reason for hiding this comment

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

Importing local ts files as js files? Wut?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Normal node resolution mode. Esm modules want to have an explicit extension.
This can be disabled with --experimental-specifier-resolution=node, but I decided to just stick with the defaults

Copy link
Contributor

Choose a reason for hiding this comment

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

This is wired and contr-intuitive. Can you at least make it consume ts extension? I'm not sure the navigation will work in IntelliJ as it is right now...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can you try navigation out? It should work without any issues (as this is pretty much the 'default' setup now)

rollup/dist.config.js Show resolved Hide resolved
@mschuwalow
Copy link
Contributor Author

Did you checked chrome's dev-tools? Do you see sources there?

For this to work we would need to emit sourcemaps from liveconnectbuilder, which we are not. Here it's really only relevant when getting used as a library.

@@ -3,10 +3,10 @@
import jsdom from 'global-jsdom'
import sinon from 'sinon'
import { expect, use } from 'chai'
import { MinimalLiveConnect, LiveConnect } from '../../src'
import { MinimalLiveConnect, LiveConnect } from '../../src/index.js'
Copy link
Contributor

Choose a reason for hiding this comment

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

Node resolution can't find index automatically?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mschuwalow mschuwalow merged commit ffa862e into master Mar 11, 2024
6 of 10 checks passed
@mschuwalow mschuwalow deleted the test-updates branch March 11, 2024 15:09
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants