Skip to content

Commit

Permalink
Run .cjs and .mjs files through preset env (#906)
Browse files Browse the repository at this point in the history
  • Loading branch information
askoufis committed Nov 27, 2023
1 parent 56f71e0 commit 00332e8
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .changeset/famous-crabs-complain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'sku': patch
---

Fixes a bug where `.cjs` and `.mjs` files were not being transpiled for browser targets
11 changes: 9 additions & 2 deletions packages/sku/config/webpack/utils/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
const loaders = require('./loaders');
const { resolvePackage } = require('./resolvePackage');

// TODO: Figure out a better way to share this config. This is currently copy-pasted from
// `eslint-config-seek`
const extensions = {
js: ['js', 'cjs', 'mjs', 'jsx'],
ts: ['ts', 'cts', 'mts', 'tsx'],
};

module.exports = {
...loaders,
resolvePackage,
TYPESCRIPT: /\.(ts|tsx)$/,
JAVASCRIPT: /\.js$/,
TYPESCRIPT: new RegExp(`\.(${extensions.ts.join('|')})$`),
JAVASCRIPT: new RegExp(`\.(${extensions.js.join('|')})$`),
LESS: /\.less$/,
IMAGE: [/\.bmp$/, /\.gif$/, /\.jpe?g$/, /\.png$/],
SVG: /\.svg$/,
Expand Down
1 change: 0 additions & 1 deletion tests/__snapshots__/braid-design-system.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4985,7 +4985,6 @@ html:not(.vtjip3z) .ht7o11m {
,
"2.js": "CONTENTS IGNORED IN SNAPSHOT TEST",
"externals.json": "[
"assert",
"crypto",
"fs",
"node:crypto",
Expand Down
9 changes: 1 addition & 8 deletions tests/__snapshots__/sku-webpack-plugin.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -5026,14 +5026,7 @@ html._3ylw6xz ._2h419fj {
}
,
"main.js": "CONTENTS IGNORED IN SNAPSHOT TEST",
"main.js.LICENSE.txt": /*!
* The buffer module from node.js, for the browser.
*
* @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
* @license MIT
*/
/**
"main.js.LICENSE.txt": /**
* @license React
* react-dom.production.min.js
*
Expand Down

0 comments on commit 00332e8

Please sign in to comment.