Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: fully native esm #2610

Merged
merged 1 commit into from
Dec 11, 2024
Merged

feat!: fully native esm #2610

merged 1 commit into from
Dec 11, 2024

Conversation

AviVahl
Copy link
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

@@ -252,7 +252,7 @@ function connectWorkerToHost(envName: string, worker: ReturnType<typeof runWorke
worker.postMessage(message.data);
};
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
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
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.

@@ -87,7 +87,7 @@ export async function runEngine({
outputPath = fs.resolve(rootDir, outputPath);

const jsOutExtension = '.js' as '.js' | '.mjs';
const nodeFormat = jsOutExtension === '.mjs' ? 'esm' : 'cjs';
const nodeFormat = 'esm' as 'esm' | 'cjs';
Copy link
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

@@ -130,6 +131,7 @@ export class NodeConfigManager {
try {
const text = outputFiles[0]!.text;
const module = { exports: { default: undefined as any } };
const require = createRequire(import.meta.url);
Copy link
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
6 checks passed
@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