Skip to content

Commit

Permalink
fix(webpack): allow files with .cjs extension to be transpiled (#10340
Browse files Browse the repository at this point in the history
)

[release]
  • Loading branch information
rchl committed Jun 23, 2022
1 parent e5efc25 commit 7a25294
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/cli/test/unit/__snapshots__/webpack.test.js.snap
Expand Up @@ -61,7 +61,7 @@ exports[`webpack nuxt webpack module.rules 1`] = `
},
Object {
\\"exclude\\": [Function exclude],
\\"test\\": /\\\\.m?jsx?$/i,
\\"test\\": /\\\\.(c|m)?jsx?$/i,
\\"type\\": \\"javascript/auto\\",
\\"use\\": Array [
Object {
Expand Down Expand Up @@ -674,7 +674,7 @@ exports[`webpack nuxt webpack module.rules loader=vue- 1`] = `
exports[`webpack nuxt webpack module.rules test=.jsx 1`] = `
"Object {
\\"exclude\\": [Function exclude],
\\"test\\": /\\\\.m?jsx?$/i,
\\"test\\": /\\\\.(c|m)?jsx?$/i,
\\"type\\": \\"javascript/auto\\",
\\"use\\": Array [
Object {
Expand Down
4 changes: 2 additions & 2 deletions packages/webpack/src/config/base.js
Expand Up @@ -239,7 +239,7 @@ export default class WebpackBaseConfig {

return {
resolve: {
extensions: ['.wasm', '.mjs', '.js', '.json', '.vue', '.jsx'],
extensions: ['.wasm', '.mjs', '.cjs', '.js', '.json', '.vue', '.jsx'],
alias: this.alias(),
modules: webpackModulesDir,
plugins: resolvePlugins
Expand Down Expand Up @@ -329,7 +329,7 @@ export default class WebpackBaseConfig {
]
},
{
test: /\.m?jsx?$/i,
test: /\.(c|m)?jsx?$/i,
type: 'javascript/auto',
exclude: (file) => {
file = file.split(/node_modules(.*)/)[1]
Expand Down

0 comments on commit 7a25294

Please sign in to comment.