nrwl / nx-labs

A collection of Nx plugins
MIT License
144 stars 50 forks source link

Deno build doesn't work when using libraries #309

Closed charsleysa closed 1 year ago

charsleysa commented 1 year ago

As part of my work for #306 I discovered that the build doesn't work when using libraries. It looks like the e2e unit tests have missed this. I tested this by adding the following test to the end of the library section of deno-integrated.spec.ts:


    it('should be able to use import alias of lib in app for build', async () => {
      const fnName = names(libName).propertyName;
      updateFile(
        `apps/${appName}/src/main.ts`,
        `import { ${fnName} } from '@proj/${libName}'

console.log(${fnName}())`
      );

      const result = await runNxCommandAsync(`build ${appName}`);
      expect(result.stdout).toContain(
        `Successfully ran target build for project ${appName}`
      );
      expect(workspaceFileExists(`dist/apps/${appName}/main.js`)).toBeTruthy();
    }, 120_000);

which outputs:

    Command failed: yarn nx build deno-app1972974
    error: Uncaught (in promise) Error: Unable to output during bundling.
          const ret = new Error(getStringFromWasm0(arg0, arg1));
                      ^
        at __wbg_new_87297f22973157c8 (https://deno.land/x/emit@0.24.0/emit.generated.js:509:19)
        at <anonymous> (file:///home/codespace/.local/share/deno-wasmbuild/9da37c1955ad9ccc04d9f3aaa76f4ee03ea13face7dcc7bbc42752ce7eb21a53.wasm:1:7369575)
        at <anonymous> (file:///home/codespace/.local/share/deno-wasmbuild/9da37c1955ad9ccc04d9f3aaa76f4ee03ea13face7dcc7bbc42752ce7eb21a53.wasm:1:1541216)
        at <anonymous> (file:///home/codespace/.local/share/deno-wasmbuild/9da37c1955ad9ccc04d9f3aaa76f4ee03ea13face7dcc7bbc42752ce7eb21a53.wasm:1:6482348)
        at <anonymous> (file:///home/codespace/.local/share/deno-wasmbuild/9da37c1955ad9ccc04d9f3aaa76f4ee03ea13face7dcc7bbc42752ce7eb21a53.wasm:1:7329815)
        at __wbg_adapter_46 (https://deno.land/x/emit@0.24.0/emit.generated.js:241:6)
        at real (https://deno.land/x/emit@0.24.0/emit.generated.js:225:14)
        at eventLoopTick (ext:core/01_core.js:183:11)
    error Command failed with exit code 1.

I believe this is a bug in the deno emit library.

charsleysa commented 1 year ago

Turns out it wasn't a bug in the deno emit library, it was the emit executor not handling the deno config properly. The error message provided by deno emit is not very helpful though.