Coder Social home page Coder Social logo

cjs-esm-skypack-build-rep's Introduction

cjs module with esm first dependency skypack build

Skypack is failing to build cjs projects where a given dependency exports esm (and other) builds.

This cjs module, which simply requires multiformats (exports esm + cjs), aims to replicate the skypack build failure.

Build content

The skypack build result looks like:

import require$$0 from "/-/[email protected]/dist=es2020,mode=imports/optimized/multiformats/cid.js";
const {CID} = require$$0;
var cjsEsmSkypackBuildRep = () => {
  const cid2 = CID.parse("bagaaierasords4njcts6vs7qvdjfcvgnume4hqohf65zsfguprqphs3icwea");
  return cid2;
};
export default cjsEsmSkypackBuildRep;

Where /-/[email protected]/dist=es2020,mode=imports/optimized/multiformats/cid.js source obtained in the browser is:

class CID {
  // ...
}
// ...

export {CID};

Running

Runnable code: https://codepen.io/vascosantos/pen/gOWMbLM

import sth from 'https://cdn.skypack.dev/cjs-esm-skypack-build-rep'

Results on

Uncaught TypeError: Cannot destructure property 'CID' of 'require$$0' as it is null.
    at cjs-esm-skypack-build-rep.js:2

Other Experiments

Not relying on package.json exports

const { CID } = require('multiformats')

Results in exactly the same issue.

Using default exports instead of named exports in a esm module

const testEsmExport = require('esm-export-test-module')

Results in exactly the same issue.

cjs-esm-skypack-build-rep's People

Contributors

vasco-santos avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.