Skip to content

feat!: fully native esm#2610

Merged
AviVahl merged 1 commit intomasterfrom
avi/native-esm-engine
Dec 11, 2024
Merged

feat!: fully native esm#2610
AviVahl merged 1 commit intomasterfrom
avi/native-esm-engine

Conversation

@AviVahl
Copy link
Copy Markdown
Contributor

@AviVahl AviVahl commented Dec 8, 2024

  • all packages are now "type": "module"
  • replaced commonjs calls with their esm counterparts
  • ensure all dynamic imports now use pathToFileURL to properly work on win32
  • removed now-unneeded helper that bypassed typescript transpilation to get to the "real" import()
  • changed default output format to esm

};
const handleInitializeError = (e: AnyMessage) => {
rej(new Error(`failed initializing environment ${envName} with error message: ${JSON.stringify(e.data)}`));
rej(new Error(`failed initializing environment ${envName}`, { cause: e.data }));
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this one actually prints the error now :)

@AviVahl AviVahl force-pushed the avi/native-esm-engine branch from ab8afb2 to 512e78b Compare December 10, 2024 15:41
- all packages are now "type": "module"
- replaced commonjs calls with their esm counterparts
- ensure all dynamic imports now use pathToFileURL to properly work on win32
- removed now-unneeded helper that bypassed typescript transpilation to get to the "real" import()
- changed default output format to esm
@AviVahl AviVahl force-pushed the avi/native-esm-engine branch from 512e78b to c3d4a4c Compare December 10, 2024 15:58
if one want to change this to esm, make sure that some bundle splitting is happening.
*/
format: 'iife',
format: 'esm',
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@barak007 let's discuss this. I saw no other way to get native esm working downstream.


const jsOutExtension = '.js' as '.js' | '.mjs';
const nodeFormat = jsOutExtension === '.mjs' ? 'esm' : 'cjs';
const nodeFormat = 'esm' as 'esm' | 'cjs';
Copy link
Copy Markdown
Contributor Author

@AviVahl AviVahl Dec 11, 2024

Choose a reason for hiding this comment

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

^ this is interesting. basically forcing esm

try {
const text = outputFiles[0]!.text;
const module = { exports: { default: undefined as any } };
const require = createRequire(import.meta.url);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

not sure about this. we're in esm context now. manual evaluation with require?

@AviVahl AviVahl merged commit 9175613 into master Dec 11, 2024
@AviVahl AviVahl deleted the avi/native-esm-engine branch December 11, 2024 12:50
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.

1 participant