Skip to content

Commit

Permalink
fix: 🐛 SWC and babel fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jsimck committed Feb 22, 2022
1 parent f00c359 commit 4a872dc
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
27 changes: 13 additions & 14 deletions packages/cli/src/commands/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,20 +116,19 @@ const dev: HandlerFn = async args => {
// Create compiler
const compiler = webpack(config);

// Start watch mode & create dev server for HMR (only on client bundle)
await Promise.all(
[
watchCompiler(compiler, args, imaConfig),
!args.forceSPA &&
createDevServer(
compiler.compilers.find(({ name }) =>
args.forceSPAWithHMR ? name === 'client' : name === 'client.es'
),
devServerConfig.hostname,
devServerConfig.port
),
].filter(Boolean)
);
// Start watch compiler
await watchCompiler(compiler, args, imaConfig);

// Start HMR dev server
if (!args.forceSPA) {
await createDevServer(
compiler.compilers.find(({ name }) =>
args.forceSPAWithHMR ? name === 'client' : name === 'client.es'
),
devServerConfig.hostname,
devServerConfig.port
);
}

// Start nodemon and application server
startNodemon(args);
Expand Down
5 changes: 3 additions & 2 deletions packages/cli/src/webpack/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export default async (
? '[path][name]__[local]--[hash:base64:5]'
: '[hash:base64]',
},
sourceMap: useSourceMaps,
sourceMap: imaConfig.experiments?.swc, // Doesn't currently work with babel
},
},
]
Expand All @@ -112,6 +112,7 @@ export default async (
[
'postcss-preset-env',
{
browsers: 'defaults',
autoprefixer: {
flexbox: 'no-2009',
},
Expand Down Expand Up @@ -178,7 +179,7 @@ export default async (
}).toString()}`,
useHMR &&
isDebug &&
`@ima/hmr-client/dist/imaHmrClient?${new URLSearchParams({
`@ima/hmr-client/dist/imaHmrClient.js?${new URLSearchParams({
port: devServerConfig.port.toString(),
hostname: devServerConfig.hostname,
public: devServerConfig.public,
Expand Down
3 changes: 2 additions & 1 deletion packages/cli/src/webpack/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ function createCacheKey(
*/
hash.update(
JSON.stringify({
experiments: JSON.stringify(imaConfig.experiments),
experimentsNativeCss: imaConfig.experiments?.nativeCss,
experimentsSwc: imaConfig.experiments?.swc,
command: ctx.command,
forceSPA: ctx.forceSPA,
forceSPAWithHMR: ctx.forceSPAWithHMR,
Expand Down

0 comments on commit 4a872dc

Please sign in to comment.