GithubHelp home page GithubHelp logo

Comments (7)

tommy-mitchell avatar tommy-mitchell commented on June 11, 2024 2

I think the issue is that hashbangs have to be at the start of the file (MDN):

A hashbang comment ... is only valid at the absolute start of a script or module. Note also that no whitespace of any kind is permitted before the #!. The comment consists of all the characters after #! up to the end of the first line; only one such comment is permitted.

esmock is inserting import globals before the hashbang.

from esmock.

koshic avatar koshic commented on June 11, 2024

Very similar issue without hashbang.

foo.js

export default 1;

cli.js

import someConstant from "./foo.js";

console.log(someConstant);

1.js

import esmock from "esmock";

await esmock("./cli.js", {
  "./foo.js": "bar",
});
file:///Users/xxxfoo.js?esmkTreeId=1&esmkModuleId=./foo.js&isfound=true&isesm=false&exportNames=0,1,2,default:1
export const 0 = global.esmockCacheGet("file:///Users/xxx/foo.js?esmkTreeId=1&esmkModuleId=./foo.js&isfound=true&isesm=false&exportNames=0,1,2,default").0
             ^

SyntaxError: Unexpected number
    at CustomizedModuleLoader.moduleStrategy (node:internal/modules/esm/translators:116:18)
    at CustomizedModuleLoader.moduleProvider (node:internal/modules/esm/loader:190:14)

from esmock.

iambumblehead avatar iambumblehead commented on June 11, 2024

esmock is inserting import globals before the hashbang.

I think you are correct :) thanks for finding this. I should have time this evening or tomorrow to look at PRs or try to resolve it myself

from esmock.

iambumblehead avatar iambumblehead commented on June 11, 2024
Screen Shot 2023-07-27 at 8 43 19 PM

I don't know why the win32 error is occurring. The error indicates that paths like "node:fs" are only available in esm to packages using "type": "module", but the error originates inside an esm "load" hook and tests are started inside the tests-source-map folder which includes a package.json with "type": "module"

I don't know what causes the issue

from esmock.

iambumblehead avatar iambumblehead commented on June 11, 2024

related nodejs/node#35518

from esmock.

iambumblehead avatar iambumblehead commented on June 11, 2024

The ci error went away when node 18.16 was pinned. The error occurs on the latest 18.17

A new ticket is created at the node repo here let's see what they say nodejs/node#48948

from esmock.

iambumblehead avatar iambumblehead commented on June 11, 2024

closing with this #217

feel free to reopen for any reason

from esmock.

Related Issues (20)

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.