Skip to content
This repository was archived by the owner on Jul 14, 2023. It is now read-only.

Can’t enable dynamic imports #16

Closed
sabberworm opened this issue Jan 13, 2021 · 2 comments
Closed

Can’t enable dynamic imports #16

sabberworm opened this issue Jan 13, 2021 · 2 comments

Comments

@sabberworm
Copy link

sabberworm commented Jan 13, 2021

I have configured swc-loader as follows:

{
	test: /\.tsx?$/,
	exclude: /\/node_modules\//,
	use: [
		{
			loader: 'swc-loader',
			options: {
				jsc: {
					externalHelpers: true,
					parser: {
						dynamicImport: true,
						syntax: 'typescript',
					},
					transform: {
						react: {
							pragma: 'SnabbdomPragma.createElement',
						},
					},
				},
			},
		},
	],
},

Notice the dynamicImport: true. Yet running webpack yields an error where I use my dynamic import:

error: import(...) expressions requires `jsc.parser.dynamicImport` to be true
  --> /«redacted»/components.ts:21:17
   |
21 |         return (await import(/* webpackChunkName: "accordion" */ 'components/accordion/Tc.Module.Accordion')).default;
   |                       ^^^^^^

Any other location I need to configure dynamicImport: true?

@kdy1
Copy link
Member

kdy1 commented Jan 13, 2021

Can you try changing the order of dynamicImport: true, and syntax: 'typescript'?
`

@sabberworm
Copy link
Author

I tried and it worked. Now I reverted the change and it still works. In any case, I did have some other problems in my config which I eventually ironed out so maybe they caused this. In that case it’d simply be a duplicate of #12

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

2 participants