mightyplow 5 anni fa
commit
ea6c0d5e92
7 ha cambiato i file con 40 aggiunte e 0 eliminazioni
  1. 1 0
      .gitignore
  2. 0 0
      README.md
  3. 4 0
      index.js
  4. 6 0
      loadable-mock/index.js
  5. 5 0
      package-lock.json
  6. 19 0
      package.json
  7. 5 0
      transform-dynamic-import-loader/index.js

+ 1 - 0
.gitignore

@@ -0,0 +1 @@
+.idea/

+ 0 - 0
README.md


+ 4 - 0
index.js

@@ -0,0 +1,4 @@
+module.exports = {
+    externals: require('./externals'),
+    transformDynamicImportLoader: require('./transform-dynamic-import-loader')
+};

+ 6 - 0
loadable-mock/index.js

@@ -0,0 +1,6 @@
+module.exports = function loadableMock (fn = Function.prototype) {
+    const result = fn();
+    return result && result.default
+        ? result.default
+        : result;
+};

+ 5 - 0
package-lock.json

@@ -0,0 +1,5 @@
+{
+  "name": "@mightyplow/loadable-ssr",
+  "version": "1.0.0",
+  "lockfileVersion": 1
+}

+ 19 - 0
package.json

@@ -0,0 +1,19 @@
+{
+  "name": "@mightyplow/loadable-ssr",
+  "version": "1.0.0",
+  "description": "Helpers for enabling server side rendering with lazy components.",
+  "main": "./index.js",
+  "scripts": {
+    "test": "echo \"Error: no test specified\" && exit 1"
+  },
+  "keywords": [
+    "lazy",
+    "javascript",
+    "performance",
+    "server side rendering",
+    "ssr",
+    "webpack"
+  ],
+  "author": "mightyplow@gmail.com",
+  "license": "Beerware"
+}

+ 5 - 0
transform-dynamic-import-loader/index.js

@@ -0,0 +1,5 @@
+module.exports = function transformDynamicImportLoader (resource) {
+    return /\.(js|jsx|ts|tsx)$/.test(this.resourcePath)
+        ? resource.replace(/import[\s\n]*?[(]/g, 'require(')
+        : resource
+};