Jelajahi Sumber

meta: fix e2e (#3562)

Antoine du Hamel 3 tahun lalu
induk
melakukan
2a4e2bf823
4 mengubah file dengan 38 tambahan dan 688 penghapusan
  1. 34 11
      bin/build-lib.js
  2. 1 3
      e2e/clients/dashboard-compressor/index.html
  3. 3 3
      e2e/clients/index.html
  4. 0 671
      yarn.lock

+ 34 - 11
bin/build-lib.js

@@ -103,13 +103,14 @@ async function buildLib () {
       visitor: {
         // eslint-disable-next-line no-shadow
         ImportDeclaration (path) {
-          const { value } = path.node.source
+          let { value } = path.node.source
           if (value.endsWith('.jsx') && value.startsWith('./')) {
             // Rewrite .jsx imports to .js:
-            path.node.source.value = value.slice(0, -1) // eslint-disable-line no-param-reassign
-          } else if (PACKAGE_JSON_IMPORT.test(value)
-                     && path.node.specifiers.length === 1
-                     && path.node.specifiers[0].type === 'ImportDefaultSpecifier') {
+            value = path.node.source.value = value.slice(0, -1) // eslint-disable-line no-param-reassign,no-multi-assign
+          }
+          if (PACKAGE_JSON_IMPORT.test(value)
+              && path.node.specifiers.length === 1
+              && path.node.specifiers[0].type === 'ImportDefaultSpecifier') {
             // Vendor-in version number from package.json files:
             const version = versionCache.get(file.slice(0, file.indexOf('/src/')))
             if (version != null) {
@@ -121,12 +122,34 @@ async function buildLib () {
                   ]))]),
               )
             }
-          } else if (!value.startsWith('.')
-                     && path.node.specifiers.length === 1
-                     && path.node.specifiers[0].type === 'ImportDefaultSpecifier'
-          ) {
-            // Replace default imports with straight require calls (CommonJS interop):
-            const [{ local }] = path.node.specifiers
+          } else if (path.node.specifiers[0].type === 'ImportDefaultSpecifier') {
+            const [{ local }, ...otherSpecifiers] = path.node.specifiers
+            if (otherSpecifiers.length === 1 && otherSpecifiers[0].type === 'ImportNamespaceSpecifier') {
+              // import defaultVal, * as namespaceImport from '@uppy/package'
+              // is transformed into:
+              // const defaultVal = require('@uppy/package'); const namespaceImport = defaultVal
+              path.insertAfter(
+                t.variableDeclaration('const', [
+                  t.variableDeclarator(
+                    otherSpecifiers[0].local,
+                    local,
+                  ),
+                ]),
+              )
+            } else if (otherSpecifiers.length !== 0) {
+              // import defaultVal, { exportedVal as importedName, other } from '@uppy/package'
+              // is transformed into:
+              // const defaultVal = require('@uppy/package'); const { exportedVal: importedName, other } = defaultVal
+              path.insertAfter(t.variableDeclaration('const', [t.variableDeclarator(
+                t.objectPattern(
+                  otherSpecifiers.map(specifier => t.objectProperty(
+                    t.identifier(specifier.imported.name),
+                    specifier.local,
+                  )),
+                ),
+                local,
+              )]))
+            }
             path.replaceWith(
               t.variableDeclaration('const', [
                 t.variableDeclarator(

+ 1 - 3
e2e/clients/dashboard-compressor/index.html

@@ -5,7 +5,5 @@
     <title>dashboard-compressor</title>
     <script defer type="module" src="app.js"></script>
   </head>
-  <body>
-    <div id="app"></div>
-  </body>
+  <body></body>
 </html>

+ 3 - 3
e2e/clients/index.html

@@ -8,12 +8,12 @@
     <h1>Test apps</h1>
     <nav>
       <ul>
-        <li><a href="dashboard-tus/index.html">dashboard-tus</a></li>
+				<li><a href="dashboard-compressor/index.html">dashboard-compressor</a></li>
+				<li><a href="dashboard-react/index.html">dashboard-react</a></li>
         <li><a href="dashboard-transloadit/index.html">dashboard-transloadit</a></li>
+        <li><a href="dashboard-tus/index.html">dashboard-tus</a></li>
 				<li><a href="dashboard-ui/index.html">dashboard-ui</a></li>
-				<li><a href="dashboard-react/index.html">dashboard-react</a></li>
 				<li><a href="dashboard-vue/index.html">dashboard-vue</a></li>
-				<li><a href="dashboard-compressor/index.html">dashboard-compressor</a></li>
 			</ul>
     <nav>
   </body>

File diff ditekan karena terlalu besar
+ 0 - 671
yarn.lock


Beberapa file tidak ditampilkan karena terlalu banyak file yang berubah dalam diff ini