summaryrefslogtreecommitdiff
path: root/@linaria/packages/babel/src/dynamic-import-noop.ts
diff options
context:
space:
mode:
Diffstat (limited to '@linaria/packages/babel/src/dynamic-import-noop.ts')
-rw-r--r--@linaria/packages/babel/src/dynamic-import-noop.ts26
1 files changed, 26 insertions, 0 deletions
diff --git a/@linaria/packages/babel/src/dynamic-import-noop.ts b/@linaria/packages/babel/src/dynamic-import-noop.ts
new file mode 100644
index 0000000..879fdc4
--- /dev/null
+++ b/@linaria/packages/babel/src/dynamic-import-noop.ts
@@ -0,0 +1,26 @@
+import type { Import } from '@babel/types';
+import type { NodePath } from '@babel/traverse';
+import syntax from '@babel/plugin-syntax-dynamic-import';
+import type { Visitor } from '@babel/traverse';
+import { Core } from './babel';
+
+export default function dynamic({ types: t }: Core): {
+ inherits: any;
+ visitor: Visitor;
+} {
+ return {
+ inherits: syntax,
+ visitor: {
+ Import(path: NodePath<Import>) {
+ const noop = t.arrowFunctionExpression([], t.identifier('undefined'));
+
+ path.parentPath.replaceWith(
+ t.objectExpression([
+ t.objectProperty(t.identifier('then'), noop),
+ t.objectProperty(t.identifier('catch'), noop),
+ ])
+ );
+ },
+ },
+ };
+}