Skip to content

Instantly share code, notes, and snippets.

@majo44
Last active April 26, 2023 12:59
Show Gist options
  • Save majo44/e774abdc4aea027d11df1ee8582e97ee to your computer and use it in GitHub Desktop.
Save majo44/e774abdc4aea027d11df1ee8582e97ee to your computer and use it in GitHub Desktop.
`resolve.extensionAlias` is not taking in account for the dynamic imports expressions evaluation
const x = 'a';
import(`./lazy-${x}.js`);
export const msg = 'hello';
{
"name": "untitled",
"version": "1.0.0",
"type": "module",
"scripts": {
"build": "webpack"
},
"dependencies": {
"webpack": "5.80.0",
"webpack-cli": "5.0.2",
"ts-loader": "9.4.2",
"typescript": "5.0.4"
}
}
{
"compilerOptions": {
"module": "ESNext",
"target": "ESNext",
"sourceMap": true
},
"exclude": [
"node_modules"
]
}
import { join, dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
const __dirname = dirname(fileURLToPath(import.meta.url));
const config = {
mode: 'development',
entry: './index.ts',
devtool: false,
output: {
path: join(__dirname, 'dist'),
publicPath: '/'
},
module: {
rules: [
{
test: /\.[t]sx?$/,
loader: 'ts-loader'
}
]
},
resolve: {
extensions: [ '.ts', '.tsx', '.js', '.jsx' ],
extensionAlias: {
'.js': [ '.js', '.ts', '.tsx' ]
}
}
};
export default config;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment