babel-vite icon indicating copy to clipboard operation
babel-vite copied to clipboard

Fix "eager: true emits require (doesn't exist in browsers) instead of import"

Open ArnaudWeyts opened this issue 1 year ago • 2 comments

What:

Fixes https://github.com/OpenSourceRaidGuild/babel-vite/issues/57

Why:

We expect import to be used instead of require:

const __glob__0_0 = require("./scenarios/baseline-handlebars-list.gjs");
const __glob__0_1 = require("./scenarios/baseline-inner-html.gjs");
const __glob__0_2 = require("./scenarios/ember-get.gjs");
const definedScenarios = {
  "./scenarios/baseline-handlebars-list.gjs": __glob__0_0,
  "./scenarios/baseline-inner-html.gjs": __glob__0_1,
  "./scenarios/ember-get.gjs": __glob__0_2
};

should be

import __glob__0_0 from "./scenarios/baseline-handlebars-list.gjs";
import  __glob__0_1 from "./scenarios/baseline-inner-html.gjs";
import  __glob__0_2 from "./scenarios/ember-get.gjs";
const definedScenarios = {
  "./scenarios/baseline-handlebars-list.gjs": __glob__0_0,
  "./scenarios/baseline-inner-html.gjs": __glob__0_1,
  "./scenarios/ember-get.gjs": __glob__0_2
};

This is already listed in the documentation.

How:

Adapted the transformer and tests.

Checklist:

  • [X] Documentation updated
  • [X] Tests
  • [X] Ready to be merged
  • [ ] Added myself to contributors table

ArnaudWeyts avatar Oct 10 '24 09:10 ArnaudWeyts

@mpeyper Not sure who the right person to tag for this is, is there any feedback from you on this?

ArnaudWeyts avatar Nov 18 '24 09:11 ArnaudWeyts

@mpeyper Happy new year 🥳 Bumping this PR so it doesn't get lost 🙈 Any update on the checks or anything I can help with?

ArnaudWeyts avatar Jan 06 '25 08:01 ArnaudWeyts