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

import.meta with esbuild-loader #12

Open
JiangWeixian opened this issue Jun 22, 2022 · 0 comments
Open

import.meta with esbuild-loader #12

JiangWeixian opened this issue Jun 22, 2022 · 0 comments
Labels
good first issue Good for newcomers

Comments

@JiangWeixian
Copy link
Contributor

JiangWeixian commented Jun 22, 2022

import.meta not support in esbuild-loader(target: es2017) evanw/esbuild#349

I hack this issue by moving import.meta.webpackContext to js files, like

// utils/webpack-env
// refs: https://webpack.js.org/api/module-variables/#importmetawebpackcontext
export const contextRequire = import.meta.webpackContext('..', {
  recursive: true,
  regExp: /.tsx/,
  mode: 'sync',
})

then use it in App.tsx

import { contextRequire } from '@/utils/webpack-env'

console.log(contextRequire('./pages/index.tsx'))

or try supports options recommended in evanw/esbuild#349 (comment)

@JiangWeixian JiangWeixian mentioned this issue Jun 22, 2022
8 tasks
@JiangWeixian JiangWeixian added the good first issue Good for newcomers label Jun 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant