WebPack可以解决数据:文本导入

发布于 2025-02-07 22:46:59 字数 688 浏览 1 评论 0原文

我的应用程序使用具有语法的第三方库:

const module = await import(`data:text/javascript;charset=utf-8,${content}`);

通过WebPack构建时,我会收到以下错误:

ERROR in ./node_modules/@web/test-runner-commands/browser/commands.mjs
Module not found: Error: Can't resolve 'data:text' in 'C:\path_to_project\node_modules\@web\test-runner-commands\browser'

我尝试在WebPack配置中使用Babel-Loader:

module: {
    rules: [
        {
            test: /\.m?js$/,
            include: [
                path.resolve(workingDirectory, 'node_modules/@web')
            ],
            use: 'babel-loader'
        }
    ]
}

我需要帮助弄清楚哪些Loader能够解释表达式。

My app uses a third party library that has the syntax:

const module = await import(`data:text/javascript;charset=utf-8,${content}`);

While building through Webpack I am getting the following error:

ERROR in ./node_modules/@web/test-runner-commands/browser/commands.mjs
Module not found: Error: Can't resolve 'data:text' in 'C:\path_to_project\node_modules\@web\test-runner-commands\browser'

I tried using babel-loader in my Webpack config:

module: {
    rules: [
        {
            test: /\.m?js$/,
            include: [
                path.resolve(workingDirectory, 'node_modules/@web')
            ],
            use: 'babel-loader'
        }
    ]
}

I need help figuring out what loader would be able to interpret the expression.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

疾风者 2025-02-14 22:46:59

两年后有点迟了,但是我收到了相同的错误消息,很难找到任何帮助。

我还在使用Bable-Loader。

  • Disclamer :对我而言,这是“警告”不是“错误”,而是一个不同的图书馆,但除此之外,似乎是同一问题:

警告./node_modules/kotlin-playground/dist/playground.min.js 2:478654-478700
找不到的模块:错误:无法解析“数据:文本”,“ to My-project/node_modules/kotlin-playground/dist'

这是我的WebPack的片段,它摆脱了警告:

module.exports = {
[...]
resolve: {
    extensions: [".ts", ".tsx", ".js", ".jsx", ".json"],
    fallback: {
        "data:text": false
    }
},
module: {
    [...]
}

it's a bit late after 2 years, but I had the same error message and it was hard to find any help.

I'm also using the bable-loader.

  • Disclamer: for me it was a "WARNING" not an "ERROR", and a different library, but other than that, seems to be the same issue:

WARNING in ./node_modules/kotlin-playground/dist/playground.min.js 2:478654-478700
Module not found: Error: Can't resolve 'data:text' in 'path-to-my-project/node_modules/kotlin-playground/dist'

Here is the snippet of my webpack, that got rid of the Warning:

module.exports = {
[...]
resolve: {
    extensions: [".ts", ".tsx", ".js", ".jsx", ".json"],
    fallback: {
        "data:text": false
    }
},
module: {
    [...]
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文