Coder Social home page Coder Social logo

babel-plugin-import-glob-array's People

Contributors

dependabot[bot] avatar jescalan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

garnerp sterjoski

babel-plugin-import-glob-array's Issues

[Request] Support export from clauses

This is a super useful plugin, however I wish it supported export from clauses!

These two modules should be equivalent to an importer:

export { resource } from "source/*"
import { resource } from "source/*"
export { resource }

However because this plugin only looks for import declarations and not also export declarations, this ends up not being true.

Doesn't support jsconfig.json path alias.

Hello @jescalan. First of all thanks for making such a superb tool. I was looking for something like this to collect data from MDX blog posts in my Next.js blog and this solves the problem in a really neat way.

I ran into an issue however when I tried using babel module alias in the module import path. Next.js supports it via jsconfig.json.

Am I doing something wrong here? You can see my exact steps in this PR-

https://github.com/itaditya/website/pull/48/files

Usage with Typescript

Hey Jeff

Loving this package, thanks for building this and next-mdx-enhanced ๐Ÿ™

I've got a problem when using it with Typescript:
image

It seems that its unable to recognise this pattern.

Is this something you've come across before?

Cheers!

Support for **

Hi, do you plan to support ** imports like babel-plugin-import-glob?

Next.js + Vercel error

Problem

Hello, thanks for creating this package (and thx for next-mdx-enhanced too) :D

I wanted to set up a Next.js blog using next-mdx-enhanced - and it worked fine locally (both next build and next dev).

But when I try to deploy it on Vercel - it breaks. It says that it cannot find an .mdx-data folder.

Error message

Failed to compile.
./pages/blog/index.tsx
Module not found: Can't resolve '/vercel/fe67864/.mdx-data/115651746382137e132aae2ef68bd767.json' in '/vercel/fe67864/pages/blog'
21:41:05.450  
> Build error occurred
Error: > Build failed because of webpack errors
    at build (/vercel/fe67864/node_modules/next/dist/build/index.js:13:917)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Error: Command "yarn run build" exited with 1

Code

Here is my .babelrc:

{
  "presets": [
    [
      "next/babel",
      {
        "preset-env": {
          "useBuiltIns": "entry",
          "corejs": 3
        }
      }
    ],
    "@emotion/babel-preset-css-prop"
  ],
  "plugins": ["import-glob-array", "emotion"]
}

And next.config.js:

const withImages = require('next-images')
const withFonts = require('next-fonts')
const withOptimizedImages = require('next-optimized-images')

const withMDX = require('next-mdx-enhanced')({
  remarkPlugins: [require('remark-emoji'), require('remark-twemoji'), require('remark-images')],
  rehypePlugins: [ require('rehype-slug'),  require('rehype-autolink-headings')],
  defaultLayout: 'index.tsx'
})

module.exports = withMDX(
  withFonts(
    withOptimizedImages(
      withImages({
        handleImages: ['jpeg', 'svg', 'webp', 'gif'],
        pageExtensions: ['md', 'mdx', 'tsx', 'ts']
      })
    )
  )
)

I have a post list in pages/blog/index.tsx:

import React from 'react'
import { NextPage } from 'next'
import Link from 'next/link'
import 'isomorphic-unfetch'
import { frontMatter, MDXPost } from './*.mdx'

const formatPath = (p: string) => p.replace(/\.mdx$/, '')

const PageList: NextPage = () => {
  const posts = (frontMatter as MDXPost[]) || []

  return (
    <section>
      <h1>My Blog</h1>
      <div>
        {posts?.map((post) => (
          <Link key={post.title} href={formatPath(post.__resourcePath)}>
            <a  href={formatPath(post.__resourcePath)}>
              <figure key={post.title}>
                <img src={post.image} alt="" />
                <figcaption>
                  <h2>{post.title}</h2>
                  <span>{post.date}</span>
                </figcaption>
              </figure>
            </a>
          </Link>
        ))}
      </div>
    </section>
  )
}

export default PageList

and a list of .mdx posts:

โ”œโ”€โ”€ 2020-bundlers-review.mdx
โ”œโ”€โ”€ basis-universal-setup.mdx
โ”œโ”€โ”€ being-a-teen-developer.mdx
โ”œโ”€โ”€ index.tsx
โ”œโ”€โ”€ lets-write-frontend-in-go.mdx
โ”œโ”€โ”€ my-new-website.mdx
โ””โ”€โ”€ tsc-cjs-esm.mdx

Additional info

Repo: https://github.com/talentlessguy/v1rtl_site

Versions:

  • vercel cli: 19.0.1
  • next: 9.4.4
  • next-mdx-enhanced: 3.0.0
  • babel-plugin-import-glob-array: 0.2.0

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.