Sitelet https://web.archive.org/web/20201209134956/https://github.com/developit/microbundle/issues/745
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

package.json `babel.presets` not working... #745

Open
mikestopcontinues opened this issue Oct 25, 2020 · 5 comments
Open

package.json `babel.presets` not working... #745

mikestopcontinues opened this issue Oct 25, 2020 · 5 comments

Comments

@mikestopcontinues
Copy link

@mikestopcontinues mikestopcontinues commented Oct 25, 2020 •

I use a shared babel-preset across projects, which I reference from a third party repo. It typically works in package.json as:

{
  "babel": {
    "presets": [
      "module:@namespace/babel-preset"
    ]
  },
}

However, microbundle seems to be silently ignoring it. I get an issue using the pipeline operator. In order for it to detect that plugin, I need to reference it explicitly. But I can't see how I can configure plugins in package.json but not presets unless microbundle is doing something strange under the hood:

{
  "babel": {
    "presets": [
      "module:@sitearcade/babel-preset"
    ],
    "plugins": [
      ["@babel/plugin-proposal-pipeline-operator", {"proposal": "smart"}]
    ]
  },
}

I should add, when running jest (with babel-jest), my preset gets picked up fine.

Any idea what's going on here?

@developit
Copy link
Owner

@developit developit commented Oct 25, 2020

What's the reason for using the module: prefix in your preset name?

@mikestopcontinues
Copy link
Author

@mikestopcontinues mikestopcontinues commented Oct 25, 2020

Because it's got a non-standard name (e.g. not babel-preset-NAME). I tried removing it, but it didn't change anything regarding the bug. It might not still be required as I can't find a docs reference (though here's an issue referencing the practice).

@mikestopcontinues
Copy link
Author

@mikestopcontinues mikestopcontinues commented Nov 4, 2020

Hey, any advice on this?

@developit
Copy link
Owner

@developit developit commented Nov 5, 2020

Sorry about the delay - are you able to give a bit more information about your project's file structure? I'm curious if this is a package.json in the working directory, or if microbundle is being executed from another package.json (since it seems like you're in a monorepo). We don't crawl for Babel presets at all, they are only respected if they are defined in the working directory.

@mikestopcontinues
Copy link
Author

@mikestopcontinues mikestopcontinues commented Nov 5, 2020

Hey, I'm not in a monorepo. I've actually been migrating out of one. Regarding the babel preset, I use it across a handful of projects without a problem, sometimes in babel.config.js instead. It's here, if you want to take a look. Here's the package.json for only of my microbundle repos. All of them have the same issue:

{
  "name": "@sitearcade/request",
  "sideEffects": false,
  "source": "src/index.js",
  "main": "./dist/index.js",
  "jsnext:main": "./dist/index.modern.js",
  "module": "./dist/index.module.js",
  "syntax": {
    "esmodules": "./dist/index.modern.js"
  },
  "exports": {
    ".": {
      "browser": "./dist/index.module.js",
      "import": "./dist/index.module.js",
      "require": "./dist/index.js"
    }
  },
  "files": [
    "dist"
  ],
  "scripts": {
    "start": "microbundle watch --no-compress -f cjs,esm,modern",
    "build": "microbundle --no-compress -f cjs,esm,modern"
  },
  "dependencies": {},
  "devDependencies": {},
  "engines": {
    "node": ">=10"
  },
  "babel": {
    "presets": [
      "module:@sitearcade/babel-preset"
    ]
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.