@sewing-kit/plugin-package-esmodules
Advanced tools
+8
-10
@@ -6,13 +6,11 @@ "use strict"; | ||
| }); | ||
| Object.defineProperty(exports, "default", { | ||
| enumerable: true, | ||
| get: function () { | ||
| return _pluginPackageEsmodules.default; | ||
| } | ||
| }); | ||
| var _pluginPackageEsmodules = require("./plugin-package-esmodules"); | ||
| var _pluginPackageEsmodules = _interopRequireDefault(require("./plugin-package-esmodules")); | ||
| Object.keys(_pluginPackageEsmodules).forEach(function (key) { | ||
| if (key === "default" || key === "__esModule") return; | ||
| Object.defineProperty(exports, key, { | ||
| enumerable: true, | ||
| get: function get() { | ||
| return _pluginPackageEsmodules[key]; | ||
| } | ||
| }); | ||
| }); | ||
| function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
@@ -6,6 +6,4 @@ "use strict"; | ||
| }); | ||
| exports["default"] = void 0; | ||
| exports.default = void 0; | ||
| var _path = require("path"); | ||
| var _immer = require("immer"); | ||
@@ -19,32 +17,32 @@ | ||
| function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } | ||
| require("@sewing-kit/types"); | ||
| function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } | ||
| require("@sewing-kit/plugin-package-base"); | ||
| function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
| const PLUGIN = 'SewingKit.package-esmodules'; | ||
| const VARIANT = 'esmodules'; | ||
| function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } | ||
| function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); } | ||
| function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); } | ||
| function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } } | ||
| var PLUGIN = 'SewingKit.package-esmodules'; | ||
| var VARIANT = 'esmodules'; | ||
| var _default = (0, _pluginUtilities.createRootPlugin)(PLUGIN, function (tasks) { | ||
| tasks.build.tap(PLUGIN, function (_ref) { | ||
| var workspace = _ref.workspace, | ||
| hooks = _ref.hooks; | ||
| hooks["package"].tap(PLUGIN, function (_ref2) { | ||
| var pkg = _ref2.pkg, | ||
| hooks = _ref2.hooks; | ||
| hooks.variants.tap(PLUGIN, function (variants) { | ||
| return [].concat(_toConsumableArray(variants), [_defineProperty({}, VARIANT, true)]); | ||
| }); | ||
| hooks.configure.tap(PLUGIN, function (configurationHooks, _ref4) { | ||
| var esmodules = _ref4.esmodules; | ||
| var _default = (0, _pluginUtilities.createPlugin)({ | ||
| id: PLUGIN, | ||
| target: _pluginUtilities.PluginTarget.Root | ||
| }, tasks => { | ||
| tasks.build.tap(PLUGIN, ({ | ||
| workspace, | ||
| hooks | ||
| }) => { | ||
| hooks.configure.tap(PLUGIN, hooks => { | ||
| if (hooks.packageBuildArtifacts) { | ||
| hooks.packageBuildArtifacts.tapPromise(PLUGIN, async artifacts => [...artifacts, ...workspace.packages.map(pkg => pkg.fs.buildPath('esm')), ...(await Promise.all(workspace.packages.map(pkg => pkg.fs.glob('./*.mjs')))).flat()]); | ||
| } | ||
| }); | ||
| hooks.package.tap(PLUGIN, ({ | ||
| pkg, | ||
| hooks | ||
| }) => { | ||
| hooks.variants.tap(PLUGIN, variants => [...variants, { | ||
| [VARIANT]: true | ||
| }]); | ||
| hooks.configure.tap(PLUGIN, (configurationHooks, { | ||
| esmodules | ||
| }) => { | ||
| if (!esmodules) { | ||
@@ -55,3 +53,3 @@ return; | ||
| if (configurationHooks.babelConfig) { | ||
| configurationHooks.babelConfig.tap(PLUGIN, function (babelConfig) { | ||
| configurationHooks.babelConfig.tap(PLUGIN, babelConfig => { | ||
| return (0, _immer.produce)(babelConfig, (0, _pluginBabel.updateBabelPreset)(['babel-preset-shopify', 'babel-preset-shopify/web', 'babel-preset-shopify/node'], { | ||
@@ -62,58 +60,25 @@ modules: false | ||
| } | ||
| }); | ||
| hooks.steps.tap(PLUGIN, (steps, { | ||
| config, | ||
| variant: { | ||
| esmodules | ||
| } | ||
| }) => { | ||
| if (!esmodules) { | ||
| return steps; | ||
| } | ||
| configurationHooks.output.tap(PLUGIN, function (output) { | ||
| return (0, _path.join)(output, 'esm'); | ||
| const outputPath = pkg.fs.buildPath('esm'); | ||
| return (0, _immer.produce)(steps, steps => { | ||
| steps.push((0, _pluginBabel.createCompileBabelStep)(pkg, workspace, config, { | ||
| outputPath, | ||
| configFile: 'babel.esm.js' | ||
| }), (0, _pluginPackageUtilities.createWriteEntriesStep)(pkg, { | ||
| outputPath, | ||
| extension: '.mjs', | ||
| contents: relative => `export * from ${JSON.stringify(relative)};\nexport {default} from ${JSON.stringify(relative)};` | ||
| })); | ||
| }); | ||
| }); | ||
| hooks.steps.tapPromise(PLUGIN, | ||
| /*#__PURE__*/ | ||
| function () { | ||
| var _ref6 = _asyncToGenerator( | ||
| /*#__PURE__*/ | ||
| regeneratorRuntime.mark(function _callee(steps, _ref5) { | ||
| var config, esmodules, outputPath; | ||
| return regeneratorRuntime.wrap(function _callee$(_context) { | ||
| while (1) { | ||
| switch (_context.prev = _context.next) { | ||
| case 0: | ||
| config = _ref5.config, esmodules = _ref5.variant.esmodules; | ||
| if (esmodules) { | ||
| _context.next = 3; | ||
| break; | ||
| } | ||
| return _context.abrupt("return", steps); | ||
| case 3: | ||
| _context.next = 5; | ||
| return config.output.promise(pkg.fs.buildPath()); | ||
| case 5: | ||
| outputPath = _context.sent; | ||
| return _context.abrupt("return", (0, _immer.produce)(steps, function (steps) { | ||
| steps.push((0, _pluginBabel.createCompileBabelStep)(pkg, workspace, config, { | ||
| outputPath: outputPath, | ||
| configFile: 'babel.esm.js' | ||
| }), (0, _pluginPackageUtilities.createWriteEntriesStep)(pkg, { | ||
| outputPath: outputPath, | ||
| extension: '.mjs', | ||
| contents: function contents(relative) { | ||
| return "export * from ".concat(JSON.stringify(relative), ";"); | ||
| } | ||
| })); | ||
| })); | ||
| case 7: | ||
| case "end": | ||
| return _context.stop(); | ||
| } | ||
| } | ||
| }, _callee); | ||
| })); | ||
| return function (_x, _x2) { | ||
| return _ref6.apply(this, arguments); | ||
| }; | ||
| }()); | ||
| }); | ||
@@ -123,2 +88,2 @@ }); | ||
| exports["default"] = _default; | ||
| exports.default = _default; |
@@ -1,2 +0,2 @@ | ||
| export * from './plugin-package-esmodules'; | ||
| export { default } from './plugin-package-esmodules'; | ||
| //# sourceMappingURL=index.d.ts.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC"} | ||
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,4BAA4B,CAAC"} |
| "use strict"; | ||
| function __export(m) { | ||
| for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
| } | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| __export(require("./plugin-package-esmodules")); | ||
| var plugin_package_esmodules_1 = require("./plugin-package-esmodules"); | ||
| exports.default = plugin_package_esmodules_1.default; |
| declare const VARIANT = "esmodules"; | ||
| declare module '@sewing-kit/core/build/ts/tasks/build/types' { | ||
| declare module '@sewing-kit/types' { | ||
| interface BuildPackageOptions { | ||
@@ -7,4 +7,4 @@ [VARIANT]: boolean; | ||
| } | ||
| declare const _default: (tasks: import("@sewing-kit/core").RunnerTasks) => void; | ||
| declare const _default: import("@sewing-kit/core").RootPlugin; | ||
| export default _default; | ||
| //# sourceMappingURL=plugin-package-esmodules.d.ts.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"plugin-package-esmodules.d.ts","sourceRoot":"","sources":["../../src/plugin-package-esmodules.ts"],"names":[],"mappings":"AAWA,QAAA,MAAM,OAAO,cAAc,CAAC;AAE5B,OAAO,QAAQ,6CAA6C,CAAC;IAC3D,UAAU,mBAAmB;QAC3B,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;KACpB;CACF;;AAED,wBA2DG"} | ||
| {"version":3,"file":"plugin-package-esmodules.d.ts","sourceRoot":"","sources":["../../src/plugin-package-esmodules.ts"],"names":[],"mappings":"AAYA,QAAA,MAAM,OAAO,cAAc,CAAC;AAE5B,OAAO,QAAQ,mBAAmB,CAAC;IACjC,UAAU,mBAAmB;QAC3B,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;KACpB;CACF;;AAED,wBAuEE"} |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| const path_1 = require("path"); | ||
| const immer_1 = require("immer"); | ||
@@ -10,4 +9,13 @@ const plugin_utilities_1 = require("@sewing-kit/plugin-utilities"); | ||
| const VARIANT = 'esmodules'; | ||
| exports.default = plugin_utilities_1.createRootPlugin(PLUGIN, (tasks) => { | ||
| exports.default = plugin_utilities_1.createPlugin({ id: PLUGIN, target: plugin_utilities_1.PluginTarget.Root }, (tasks) => { | ||
| tasks.build.tap(PLUGIN, ({ workspace, hooks }) => { | ||
| hooks.configure.tap(PLUGIN, (hooks) => { | ||
| if (hooks.packageBuildArtifacts) { | ||
| hooks.packageBuildArtifacts.tapPromise(PLUGIN, async (artifacts) => [ | ||
| ...artifacts, | ||
| ...workspace.packages.map((pkg) => pkg.fs.buildPath('esm')), | ||
| ...(await Promise.all(workspace.packages.map((pkg) => pkg.fs.glob('./*.mjs')))).flat(), | ||
| ]); | ||
| } | ||
| }); | ||
| hooks.package.tap(PLUGIN, ({ pkg, hooks }) => { | ||
@@ -31,9 +39,8 @@ hooks.variants.tap(PLUGIN, (variants) => [ | ||
| } | ||
| configurationHooks.output.tap(PLUGIN, (output) => path_1.join(output, 'esm')); | ||
| }); | ||
| hooks.steps.tapPromise(PLUGIN, async (steps, { config, variant: { esmodules } }) => { | ||
| hooks.steps.tap(PLUGIN, (steps, { config, variant: { esmodules } }) => { | ||
| if (!esmodules) { | ||
| return steps; | ||
| } | ||
| const outputPath = await config.output.promise(pkg.fs.buildPath()); | ||
| const outputPath = pkg.fs.buildPath('esm'); | ||
| return immer_1.produce(steps, (steps) => { | ||
@@ -46,3 +53,3 @@ steps.push(plugin_babel_1.createCompileBabelStep(pkg, workspace, config, { | ||
| extension: '.mjs', | ||
| contents: (relative) => `export * from ${JSON.stringify(relative)};`, | ||
| contents: (relative) => `export * from ${JSON.stringify(relative)};\nexport {default} from ${JSON.stringify(relative)};`, | ||
| })); | ||
@@ -49,0 +56,0 @@ }); |
+2
-1
@@ -1,1 +0,2 @@ | ||
| export * from "./build/ts"; | ||
| export * from "./build/ts/index"; | ||
| export {default} from "./build/ts/index"; |
+5
-2
| { | ||
| "name": "@sewing-kit/plugin-package-esmodules", | ||
| "version": "0.0.2", | ||
| "version": "0.0.3", | ||
| "sideEffects": false, | ||
@@ -9,3 +9,6 @@ "publishConfig": { | ||
| }, | ||
| "gitHead": "013c63fcec7455a0d165706a87ee713d7983b5fe" | ||
| "dependencies": { | ||
| "immer": "^3.2.0" | ||
| }, | ||
| "gitHead": "b92b7a4350e29b5c1500b895558743767617d725" | ||
| } |
+1
-1
@@ -1,1 +0,1 @@ | ||
| export * from './plugin-package-esmodules'; | ||
| export {default} from './plugin-package-esmodules'; |
@@ -1,5 +0,4 @@ | ||
| import {join} from 'path'; | ||
| import {produce} from 'immer'; | ||
| import {createRootPlugin} from '@sewing-kit/plugin-utilities'; | ||
| import {createPlugin, PluginTarget} from '@sewing-kit/plugin-utilities'; | ||
| import {createWriteEntriesStep} from '@sewing-kit/plugin-package-utilities'; | ||
@@ -10,2 +9,4 @@ import { | ||
| } from '@sewing-kit/plugin-babel'; | ||
| import {} from '@sewing-kit/types'; | ||
| import {} from '@sewing-kit/plugin-package-base'; | ||
@@ -15,3 +16,3 @@ const PLUGIN = 'SewingKit.package-esmodules'; | ||
| declare module '@sewing-kit/core/build/ts/tasks/build/types' { | ||
| declare module '@sewing-kit/types' { | ||
| interface BuildPackageOptions { | ||
@@ -22,37 +23,47 @@ [VARIANT]: boolean; | ||
| export default createRootPlugin(PLUGIN, (tasks) => { | ||
| tasks.build.tap(PLUGIN, ({workspace, hooks}) => { | ||
| hooks.package.tap(PLUGIN, ({pkg, hooks}) => { | ||
| hooks.variants.tap(PLUGIN, (variants) => [ | ||
| ...variants, | ||
| {[VARIANT]: true}, | ||
| ]); | ||
| hooks.configure.tap(PLUGIN, (configurationHooks, {esmodules}) => { | ||
| if (!esmodules) { | ||
| return; | ||
| export default createPlugin( | ||
| {id: PLUGIN, target: PluginTarget.Root}, | ||
| (tasks) => { | ||
| tasks.build.tap(PLUGIN, ({workspace, hooks}) => { | ||
| hooks.configure.tap(PLUGIN, (hooks) => { | ||
| if (hooks.packageBuildArtifacts) { | ||
| hooks.packageBuildArtifacts.tapPromise(PLUGIN, async (artifacts) => [ | ||
| ...artifacts, | ||
| ...workspace.packages.map((pkg) => pkg.fs.buildPath('esm')), | ||
| ...(await Promise.all( | ||
| workspace.packages.map((pkg) => pkg.fs.glob('./*.mjs')), | ||
| )).flat(), | ||
| ]); | ||
| } | ||
| }); | ||
| if (configurationHooks.babelConfig) { | ||
| configurationHooks.babelConfig.tap(PLUGIN, (babelConfig) => { | ||
| return produce( | ||
| babelConfig, | ||
| updateBabelPreset( | ||
| [ | ||
| 'babel-preset-shopify', | ||
| 'babel-preset-shopify/web', | ||
| 'babel-preset-shopify/node', | ||
| ], | ||
| {modules: false}, | ||
| ), | ||
| ); | ||
| }); | ||
| } | ||
| hooks.package.tap(PLUGIN, ({pkg, hooks}) => { | ||
| hooks.variants.tap(PLUGIN, (variants) => [ | ||
| ...variants, | ||
| {[VARIANT]: true}, | ||
| ]); | ||
| configurationHooks.output.tap(PLUGIN, (output) => join(output, 'esm')); | ||
| }); | ||
| hooks.configure.tap(PLUGIN, (configurationHooks, {esmodules}) => { | ||
| if (!esmodules) { | ||
| return; | ||
| } | ||
| hooks.steps.tapPromise( | ||
| PLUGIN, | ||
| async (steps, {config, variant: {esmodules}}) => { | ||
| if (configurationHooks.babelConfig) { | ||
| configurationHooks.babelConfig.tap(PLUGIN, (babelConfig) => { | ||
| return produce( | ||
| babelConfig, | ||
| updateBabelPreset( | ||
| [ | ||
| 'babel-preset-shopify', | ||
| 'babel-preset-shopify/web', | ||
| 'babel-preset-shopify/node', | ||
| ], | ||
| {modules: false}, | ||
| ), | ||
| ); | ||
| }); | ||
| } | ||
| }); | ||
| hooks.steps.tap(PLUGIN, (steps, {config, variant: {esmodules}}) => { | ||
| if (!esmodules) { | ||
@@ -62,3 +73,3 @@ return steps; | ||
| const outputPath = await config.output.promise(pkg.fs.buildPath()); | ||
| const outputPath = pkg.fs.buildPath('esm'); | ||
@@ -75,10 +86,12 @@ return produce(steps, (steps) => { | ||
| contents: (relative) => | ||
| `export * from ${JSON.stringify(relative)};`, | ||
| `export * from ${JSON.stringify( | ||
| relative, | ||
| )};\nexport {default} from ${JSON.stringify(relative)};`, | ||
| }), | ||
| ); | ||
| }); | ||
| }, | ||
| ); | ||
| }); | ||
| }); | ||
| }); | ||
| }); | ||
| }); | ||
| }, | ||
| ); |
+1
-0
@@ -18,4 +18,5 @@ { | ||
| {"path": "../plugin-package-utilities"}, | ||
| {"path": "../plugin-package-base"}, | ||
| {"path": "../plugin-babel"} | ||
| ] | ||
| } |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { | ||
| value: true | ||
| }); | ||
| exports["default"] = buildJavaScript; | ||
| var _immer = require("immer"); | ||
| var _common = require("./common"); | ||
| require("@sewing-kit/plugin-webpack"); | ||
| function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } | ||
| function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } | ||
| function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } | ||
| function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); } | ||
| function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); } | ||
| function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } } | ||
| function addBaseBabelPreset(babelConfig) { | ||
| return (0, _immer.produce)(babelConfig, function (babelConfig) { | ||
| babelConfig.presets = babelConfig.presets || []; | ||
| babelConfig.presets.push('babel-preset-shopify'); | ||
| }); | ||
| } | ||
| function addJsExtensions(extensions) { | ||
| return ['.js', '.mjs'].concat(_toConsumableArray(extensions)); | ||
| } | ||
| function buildJavaScript(_ref) { | ||
| var hooks = _ref.hooks; | ||
| hooks["package"].tap(_common.PLUGIN, function (_ref2) { | ||
| var hooks = _ref2.hooks; | ||
| hooks.configure.tap(_common.PLUGIN, function (configurationHooks) { | ||
| if (configurationHooks.babelConfig) { | ||
| configurationHooks.babelConfig.tap(_common.PLUGIN, addBaseBabelPreset); | ||
| } | ||
| configurationHooks.extensions.tap(_common.PLUGIN, addJsExtensions); | ||
| }); | ||
| }); | ||
| hooks.webApp.tap(_common.PLUGIN, function (_ref3) { | ||
| var hooks = _ref3.hooks; | ||
| hooks.configure.tap(_common.PLUGIN, function (configurationHooks) { | ||
| configurationHooks.extensions.tap(_common.PLUGIN, addJsExtensions); | ||
| if (configurationHooks.babelConfig) { | ||
| configurationHooks.babelConfig.tap(_common.PLUGIN, addBaseBabelPreset); | ||
| } | ||
| if (configurationHooks.webpackRules) { | ||
| configurationHooks.webpackRules.tapPromise(_common.PLUGIN, | ||
| /*#__PURE__*/ | ||
| function () { | ||
| var _ref4 = _asyncToGenerator( | ||
| /*#__PURE__*/ | ||
| regeneratorRuntime.mark(function _callee(rules, target) { | ||
| var options; | ||
| return regeneratorRuntime.wrap(function _callee$(_context) { | ||
| while (1) { | ||
| switch (_context.prev = _context.next) { | ||
| case 0: | ||
| _context.t0 = configurationHooks.babelConfig; | ||
| if (!_context.t0) { | ||
| _context.next = 5; | ||
| break; | ||
| } | ||
| _context.next = 4; | ||
| return configurationHooks.babelConfig.promise({}, target); | ||
| case 4: | ||
| _context.t0 = _context.sent; | ||
| case 5: | ||
| options = _context.t0; | ||
| return _context.abrupt("return", (0, _immer.produce)(rules, function (rules) { | ||
| rules.push({ | ||
| test: /\.m?js/, | ||
| exclude: /node_modules/, | ||
| loader: 'babel-loader', | ||
| options: options | ||
| }); | ||
| })); | ||
| case 7: | ||
| case "end": | ||
| return _context.stop(); | ||
| } | ||
| } | ||
| }, _callee); | ||
| })); | ||
| return function (_x, _x2) { | ||
| return _ref4.apply(this, arguments); | ||
| }; | ||
| }()); | ||
| } | ||
| }); | ||
| }); | ||
| } |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { | ||
| value: true | ||
| }); | ||
| exports.PLUGIN = void 0; | ||
| var PLUGIN = 'SewingKit.javascript'; | ||
| exports.PLUGIN = PLUGIN; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { | ||
| value: true | ||
| }); | ||
| exports["default"] = lintJavaScript; | ||
| var _common = require("./common"); | ||
| require("@sewing-kit/plugin-eslint"); | ||
| function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } | ||
| function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); } | ||
| function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); } | ||
| function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } } | ||
| function lintJavaScript(_ref) { | ||
| var hooks = _ref.hooks; | ||
| hooks.configure.tap(_common.PLUGIN, function (hooks) { | ||
| if (hooks.eslintExtensions) { | ||
| hooks.eslintExtensions.tap(_common.PLUGIN, function (extensions) { | ||
| return [].concat(_toConsumableArray(extensions), ['.mjs', '.js']); | ||
| }); | ||
| } | ||
| }); | ||
| } |
| "use strict"; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { | ||
| value: true | ||
| }); | ||
| exports["default"] = void 0; | ||
| var _pluginUtilities = require("@sewing-kit/plugin-utilities"); | ||
| var _common = require("./common"); | ||
| function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj["default"] = obj; return newObj; } } | ||
| var _default = (0, _pluginUtilities.createRootPlugin)(_common.PLUGIN, function (tasks) { | ||
| tasks.test.tapPromise(_common.PLUGIN, (0, _pluginUtilities.lazy)(function () { | ||
| return Promise.resolve().then(function () { | ||
| return _interopRequireWildcard(require('./test')); | ||
| }); | ||
| })); | ||
| tasks.build.tapPromise(_common.PLUGIN, (0, _pluginUtilities.lazy)(function () { | ||
| return Promise.resolve().then(function () { | ||
| return _interopRequireWildcard(require('./build')); | ||
| }); | ||
| })); | ||
| tasks.lint.tapPromise(_common.PLUGIN, (0, _pluginUtilities.lazy)(function () { | ||
| return Promise.resolve().then(function () { | ||
| return _interopRequireWildcard(require('./lint')); | ||
| }); | ||
| })); | ||
| }); | ||
| exports["default"] = _default; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { | ||
| value: true | ||
| }); | ||
| exports["default"] = void 0; | ||
| var _path = require("path"); | ||
| var _immer = require("immer"); | ||
| var _core = require("@sewing-kit/core"); | ||
| var _pluginUtilities = require("@sewing-kit/plugin-utilities"); | ||
| var _pluginPackageUtilities = require("@sewing-kit/plugin-package-utilities"); | ||
| var _pluginBabel = require("@sewing-kit/plugin-babel"); | ||
| require("@sewing-kit/plugin-jest"); | ||
| function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } | ||
| function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } | ||
| function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
| function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } | ||
| function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); } | ||
| function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); } | ||
| function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } } | ||
| var PLUGIN = 'SewingKit.package-commonjs'; | ||
| var VARIANT = 'node'; | ||
| var EXTENSION = '.node'; | ||
| var _default = (0, _pluginUtilities.createRootPlugin)(PLUGIN, function (tasks) { | ||
| tasks.test.tap(PLUGIN, function (_ref) { | ||
| var hooks = _ref.hooks; | ||
| hooks.project.tap(PLUGIN, function (_ref2) { | ||
| var hooks = _ref2.hooks; | ||
| hooks.configure.tap(PLUGIN, function (hooks) { | ||
| if (hooks.jestExtensions) { | ||
| hooks.jestExtensions.tap(PLUGIN, function (extensions) { | ||
| return [EXTENSION].concat(_toConsumableArray(extensions)); | ||
| }); | ||
| } | ||
| }); | ||
| }); | ||
| }); | ||
| tasks.build.tap(PLUGIN, function (_ref3) { | ||
| var workspace = _ref3.workspace, | ||
| hooks = _ref3.hooks; | ||
| hooks["package"].tap(PLUGIN, function (_ref4) { | ||
| var pkg = _ref4.pkg, | ||
| hooks = _ref4.hooks; | ||
| hooks.variants.tap(PLUGIN, function (variants) { | ||
| // If all the entries already target node, there is no need to do a | ||
| // node-only build (it will match the CommonJS build). | ||
| if (pkg.entries.every(function (_ref5) { | ||
| var runtime = _ref5.runtime; | ||
| return runtime === _core.Runtime.Node; | ||
| })) { | ||
| return variants; | ||
| } | ||
| return [].concat(_toConsumableArray(variants), [_defineProperty({}, VARIANT, true)]); | ||
| }); | ||
| hooks.configure.tap(PLUGIN, function (configurationHooks, _ref7) { | ||
| var node = _ref7.node; | ||
| if (!node) { | ||
| return; | ||
| } | ||
| if (configurationHooks.babelConfig) { | ||
| configurationHooks.babelConfig.tap(PLUGIN, function (babelConfig) { | ||
| return (0, _immer.produce)(babelConfig, function (babelConfig) { | ||
| (0, _pluginBabel.changeBabelPreset)(['babel-preset-shopify', 'babel-preset-shopify/web'], 'babel-preset-shopify/node')(babelConfig); | ||
| (0, _pluginBabel.updateBabelPreset)('babel-preset-shopify/node', { | ||
| modules: 'commonjs' | ||
| })(babelConfig); | ||
| }); | ||
| }); | ||
| } | ||
| configurationHooks.output.tap(PLUGIN, function (output) { | ||
| return (0, _path.join)(output, 'node'); | ||
| }); | ||
| }); | ||
| hooks.steps.tapPromise(PLUGIN, | ||
| /*#__PURE__*/ | ||
| function () { | ||
| var _ref9 = _asyncToGenerator( | ||
| /*#__PURE__*/ | ||
| regeneratorRuntime.mark(function _callee(steps, _ref8) { | ||
| var config, node, outputPath; | ||
| return regeneratorRuntime.wrap(function _callee$(_context) { | ||
| while (1) { | ||
| switch (_context.prev = _context.next) { | ||
| case 0: | ||
| config = _ref8.config, node = _ref8.variant.node; | ||
| if (node) { | ||
| _context.next = 3; | ||
| break; | ||
| } | ||
| return _context.abrupt("return", steps); | ||
| case 3: | ||
| _context.next = 5; | ||
| return config.output.promise(pkg.fs.buildPath()); | ||
| case 5: | ||
| outputPath = _context.sent; | ||
| return _context.abrupt("return", (0, _immer.produce)(steps, function (steps) { | ||
| steps.push((0, _pluginBabel.createCompileBabelStep)(pkg, workspace, config, { | ||
| outputPath: outputPath, | ||
| configFile: 'babel.node.js' | ||
| }), (0, _pluginPackageUtilities.createWriteEntriesStep)(pkg, { | ||
| outputPath: outputPath, | ||
| extension: EXTENSION, | ||
| exclude: function exclude(entry) { | ||
| return entry.runtime === _core.Runtime.Node; | ||
| }, | ||
| contents: function contents(relative) { | ||
| return "module.exports = require(".concat(JSON.stringify(relative), ");"); | ||
| } | ||
| })); | ||
| })); | ||
| case 7: | ||
| case "end": | ||
| return _context.stop(); | ||
| } | ||
| } | ||
| }, _callee); | ||
| })); | ||
| return function (_x, _x2) { | ||
| return _ref9.apply(this, arguments); | ||
| }; | ||
| }()); | ||
| }); | ||
| }); | ||
| }); | ||
| exports["default"] = _default; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { | ||
| value: true | ||
| }); | ||
| exports["default"] = testJavaScript; | ||
| var _immer = require("immer"); | ||
| var _common = require("./common"); | ||
| require("@sewing-kit/plugin-jest"); | ||
| function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } | ||
| function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); } | ||
| function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); } | ||
| function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } } | ||
| function testJavaScript(_ref) { | ||
| var hooks = _ref.hooks; | ||
| hooks.project.tap(_common.PLUGIN, function (_ref2) { | ||
| var hooks = _ref2.hooks; | ||
| hooks.configure.tap(_common.PLUGIN, function (hooks) { | ||
| if (hooks.jestExtensions && hooks.jestTransforms) { | ||
| // Unfortunately, some packages (like `graphql`) use `.mjs` for esmodule | ||
| // versions of the file, which Jest can't parse. To avoid transforming | ||
| // those otherwise-fine files, we prefer .js for tests only. | ||
| hooks.jestExtensions.tap(_common.PLUGIN, function (extensions) { | ||
| return ['.js', '.mjs'].concat(_toConsumableArray(extensions)); | ||
| }); | ||
| hooks.jestTransforms.tap(_common.PLUGIN, function (transforms, _ref3) { | ||
| var babelTransform = _ref3.babelTransform; | ||
| return (0, _immer.produce)(transforms, function (transforms) { | ||
| transforms['^.+\\.[m|j]s$'] = babelTransform; | ||
| }); | ||
| }); | ||
| } | ||
| if (hooks.babelConfig) { | ||
| hooks.babelConfig.tap(_common.PLUGIN, function (babelConfig) { | ||
| return (0, _immer.produce)(babelConfig, function (babelConfig) { | ||
| babelConfig.presets = babelConfig.presets || []; | ||
| babelConfig.presets.push(['babel-preset-shopify/node', { | ||
| modules: 'commonjs' | ||
| }]); | ||
| }); | ||
| }); | ||
| } | ||
| }); | ||
| }); | ||
| } |
| function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } | ||
| function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } | ||
| function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } | ||
| function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); } | ||
| function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); } | ||
| function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } } | ||
| import { produce } from 'immer'; | ||
| import { PLUGIN } from './common'; // Just loaded for its hook augmentations | ||
| import '@sewing-kit/plugin-webpack'; | ||
| function addBaseBabelPreset(babelConfig) { | ||
| return produce(babelConfig, function (babelConfig) { | ||
| babelConfig.presets = babelConfig.presets || []; | ||
| babelConfig.presets.push('babel-preset-shopify'); | ||
| }); | ||
| } | ||
| function addJsExtensions(extensions) { | ||
| return ['.js', '.mjs'].concat(_toConsumableArray(extensions)); | ||
| } | ||
| export default function buildJavaScript(_ref) { | ||
| var hooks = _ref.hooks; | ||
| hooks["package"].tap(PLUGIN, function (_ref2) { | ||
| var hooks = _ref2.hooks; | ||
| hooks.configure.tap(PLUGIN, function (configurationHooks) { | ||
| if (configurationHooks.babelConfig) { | ||
| configurationHooks.babelConfig.tap(PLUGIN, addBaseBabelPreset); | ||
| } | ||
| configurationHooks.extensions.tap(PLUGIN, addJsExtensions); | ||
| }); | ||
| }); | ||
| hooks.webApp.tap(PLUGIN, function (_ref3) { | ||
| var hooks = _ref3.hooks; | ||
| hooks.configure.tap(PLUGIN, function (configurationHooks) { | ||
| configurationHooks.extensions.tap(PLUGIN, addJsExtensions); | ||
| if (configurationHooks.babelConfig) { | ||
| configurationHooks.babelConfig.tap(PLUGIN, addBaseBabelPreset); | ||
| } | ||
| if (configurationHooks.webpackRules) { | ||
| configurationHooks.webpackRules.tapPromise(PLUGIN, | ||
| /*#__PURE__*/ | ||
| function () { | ||
| var _ref4 = _asyncToGenerator( | ||
| /*#__PURE__*/ | ||
| regeneratorRuntime.mark(function _callee(rules, target) { | ||
| var options; | ||
| return regeneratorRuntime.wrap(function _callee$(_context) { | ||
| while (1) { | ||
| switch (_context.prev = _context.next) { | ||
| case 0: | ||
| _context.t0 = configurationHooks.babelConfig; | ||
| if (!_context.t0) { | ||
| _context.next = 5; | ||
| break; | ||
| } | ||
| _context.next = 4; | ||
| return configurationHooks.babelConfig.promise({}, target); | ||
| case 4: | ||
| _context.t0 = _context.sent; | ||
| case 5: | ||
| options = _context.t0; | ||
| return _context.abrupt("return", produce(rules, function (rules) { | ||
| rules.push({ | ||
| test: /\.m?js/, | ||
| exclude: /node_modules/, | ||
| loader: 'babel-loader', | ||
| options: options | ||
| }); | ||
| })); | ||
| case 7: | ||
| case "end": | ||
| return _context.stop(); | ||
| } | ||
| } | ||
| }, _callee); | ||
| })); | ||
| return function (_x, _x2) { | ||
| return _ref4.apply(this, arguments); | ||
| }; | ||
| }()); | ||
| } | ||
| }); | ||
| }); | ||
| } |
| export var PLUGIN = 'SewingKit.javascript'; |
| export * from './plugin-package-esmodules'; |
| function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } | ||
| function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); } | ||
| function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); } | ||
| function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } } | ||
| import { PLUGIN } from './common'; | ||
| import '@sewing-kit/plugin-eslint'; | ||
| export default function lintJavaScript(_ref) { | ||
| var hooks = _ref.hooks; | ||
| hooks.configure.tap(PLUGIN, function (hooks) { | ||
| if (hooks.eslintExtensions) { | ||
| hooks.eslintExtensions.tap(PLUGIN, function (extensions) { | ||
| return [].concat(_toConsumableArray(extensions), ['.mjs', '.js']); | ||
| }); | ||
| } | ||
| }); | ||
| } |
| import { createRootPlugin, lazy } from '@sewing-kit/plugin-utilities'; | ||
| import { PLUGIN } from './common'; | ||
| export default createRootPlugin(PLUGIN, function (tasks) { | ||
| tasks.test.tapPromise(PLUGIN, lazy(function () { | ||
| return import('./test'); | ||
| })); | ||
| tasks.build.tapPromise(PLUGIN, lazy(function () { | ||
| return import('./build'); | ||
| })); | ||
| tasks.lint.tapPromise(PLUGIN, lazy(function () { | ||
| return import('./lint'); | ||
| })); | ||
| }); |
| function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } | ||
| function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } | ||
| function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
| function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } | ||
| function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); } | ||
| function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); } | ||
| function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } } | ||
| import { join } from 'path'; | ||
| import { produce } from 'immer'; | ||
| import { createRootPlugin } from '@sewing-kit/plugin-utilities'; | ||
| import { createWriteEntriesStep } from '@sewing-kit/plugin-package-utilities'; | ||
| import { updateBabelPreset, createCompileBabelStep } from '@sewing-kit/plugin-babel'; | ||
| var PLUGIN = 'SewingKit.package-esmodules'; | ||
| var VARIANT = 'esmodules'; | ||
| export default createRootPlugin(PLUGIN, function (tasks) { | ||
| tasks.build.tap(PLUGIN, function (_ref) { | ||
| var workspace = _ref.workspace, | ||
| hooks = _ref.hooks; | ||
| hooks["package"].tap(PLUGIN, function (_ref2) { | ||
| var pkg = _ref2.pkg, | ||
| hooks = _ref2.hooks; | ||
| hooks.variants.tap(PLUGIN, function (variants) { | ||
| return [].concat(_toConsumableArray(variants), [_defineProperty({}, VARIANT, true)]); | ||
| }); | ||
| hooks.configure.tap(PLUGIN, function (configurationHooks, _ref4) { | ||
| var esmodules = _ref4.esmodules; | ||
| if (!esmodules) { | ||
| return; | ||
| } | ||
| if (configurationHooks.babelConfig) { | ||
| configurationHooks.babelConfig.tap(PLUGIN, function (babelConfig) { | ||
| return produce(babelConfig, updateBabelPreset(['babel-preset-shopify', 'babel-preset-shopify/web', 'babel-preset-shopify/node'], { | ||
| modules: false | ||
| })); | ||
| }); | ||
| } | ||
| configurationHooks.output.tap(PLUGIN, function (output) { | ||
| return join(output, 'esm'); | ||
| }); | ||
| }); | ||
| hooks.steps.tapPromise(PLUGIN, | ||
| /*#__PURE__*/ | ||
| function () { | ||
| var _ref6 = _asyncToGenerator( | ||
| /*#__PURE__*/ | ||
| regeneratorRuntime.mark(function _callee(steps, _ref5) { | ||
| var config, esmodules, outputPath; | ||
| return regeneratorRuntime.wrap(function _callee$(_context) { | ||
| while (1) { | ||
| switch (_context.prev = _context.next) { | ||
| case 0: | ||
| config = _ref5.config, esmodules = _ref5.variant.esmodules; | ||
| if (esmodules) { | ||
| _context.next = 3; | ||
| break; | ||
| } | ||
| return _context.abrupt("return", steps); | ||
| case 3: | ||
| _context.next = 5; | ||
| return config.output.promise(pkg.fs.buildPath()); | ||
| case 5: | ||
| outputPath = _context.sent; | ||
| return _context.abrupt("return", produce(steps, function (steps) { | ||
| steps.push(createCompileBabelStep(pkg, workspace, config, { | ||
| outputPath: outputPath, | ||
| configFile: 'babel.esm.js' | ||
| }), createWriteEntriesStep(pkg, { | ||
| outputPath: outputPath, | ||
| extension: '.mjs', | ||
| contents: function contents(relative) { | ||
| return "export * from ".concat(JSON.stringify(relative), ";"); | ||
| } | ||
| })); | ||
| })); | ||
| case 7: | ||
| case "end": | ||
| return _context.stop(); | ||
| } | ||
| } | ||
| }, _callee); | ||
| })); | ||
| return function (_x, _x2) { | ||
| return _ref6.apply(this, arguments); | ||
| }; | ||
| }()); | ||
| }); | ||
| }); | ||
| }); |
| function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } | ||
| function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } | ||
| function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
| function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } | ||
| function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); } | ||
| function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); } | ||
| function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } } | ||
| import { join } from 'path'; | ||
| import { produce } from 'immer'; | ||
| import { Runtime } from '@sewing-kit/core'; | ||
| import { createRootPlugin } from '@sewing-kit/plugin-utilities'; | ||
| import { createWriteEntriesStep } from '@sewing-kit/plugin-package-utilities'; | ||
| import { changeBabelPreset, updateBabelPreset, createCompileBabelStep } from '@sewing-kit/plugin-babel'; | ||
| import '@sewing-kit/plugin-jest'; | ||
| var PLUGIN = 'SewingKit.package-commonjs'; | ||
| var VARIANT = 'node'; | ||
| var EXTENSION = '.node'; | ||
| export default createRootPlugin(PLUGIN, function (tasks) { | ||
| tasks.test.tap(PLUGIN, function (_ref) { | ||
| var hooks = _ref.hooks; | ||
| hooks.project.tap(PLUGIN, function (_ref2) { | ||
| var hooks = _ref2.hooks; | ||
| hooks.configure.tap(PLUGIN, function (hooks) { | ||
| if (hooks.jestExtensions) { | ||
| hooks.jestExtensions.tap(PLUGIN, function (extensions) { | ||
| return [EXTENSION].concat(_toConsumableArray(extensions)); | ||
| }); | ||
| } | ||
| }); | ||
| }); | ||
| }); | ||
| tasks.build.tap(PLUGIN, function (_ref3) { | ||
| var workspace = _ref3.workspace, | ||
| hooks = _ref3.hooks; | ||
| hooks["package"].tap(PLUGIN, function (_ref4) { | ||
| var pkg = _ref4.pkg, | ||
| hooks = _ref4.hooks; | ||
| hooks.variants.tap(PLUGIN, function (variants) { | ||
| // If all the entries already target node, there is no need to do a | ||
| // node-only build (it will match the CommonJS build). | ||
| if (pkg.entries.every(function (_ref5) { | ||
| var runtime = _ref5.runtime; | ||
| return runtime === Runtime.Node; | ||
| })) { | ||
| return variants; | ||
| } | ||
| return [].concat(_toConsumableArray(variants), [_defineProperty({}, VARIANT, true)]); | ||
| }); | ||
| hooks.configure.tap(PLUGIN, function (configurationHooks, _ref7) { | ||
| var node = _ref7.node; | ||
| if (!node) { | ||
| return; | ||
| } | ||
| if (configurationHooks.babelConfig) { | ||
| configurationHooks.babelConfig.tap(PLUGIN, function (babelConfig) { | ||
| return produce(babelConfig, function (babelConfig) { | ||
| changeBabelPreset(['babel-preset-shopify', 'babel-preset-shopify/web'], 'babel-preset-shopify/node')(babelConfig); | ||
| updateBabelPreset('babel-preset-shopify/node', { | ||
| modules: 'commonjs' | ||
| })(babelConfig); | ||
| }); | ||
| }); | ||
| } | ||
| configurationHooks.output.tap(PLUGIN, function (output) { | ||
| return join(output, 'node'); | ||
| }); | ||
| }); | ||
| hooks.steps.tapPromise(PLUGIN, | ||
| /*#__PURE__*/ | ||
| function () { | ||
| var _ref9 = _asyncToGenerator( | ||
| /*#__PURE__*/ | ||
| regeneratorRuntime.mark(function _callee(steps, _ref8) { | ||
| var config, node, outputPath; | ||
| return regeneratorRuntime.wrap(function _callee$(_context) { | ||
| while (1) { | ||
| switch (_context.prev = _context.next) { | ||
| case 0: | ||
| config = _ref8.config, node = _ref8.variant.node; | ||
| if (node) { | ||
| _context.next = 3; | ||
| break; | ||
| } | ||
| return _context.abrupt("return", steps); | ||
| case 3: | ||
| _context.next = 5; | ||
| return config.output.promise(pkg.fs.buildPath()); | ||
| case 5: | ||
| outputPath = _context.sent; | ||
| return _context.abrupt("return", produce(steps, function (steps) { | ||
| steps.push(createCompileBabelStep(pkg, workspace, config, { | ||
| outputPath: outputPath, | ||
| configFile: 'babel.node.js' | ||
| }), createWriteEntriesStep(pkg, { | ||
| outputPath: outputPath, | ||
| extension: EXTENSION, | ||
| exclude: function exclude(entry) { | ||
| return entry.runtime === Runtime.Node; | ||
| }, | ||
| contents: function contents(relative) { | ||
| return "module.exports = require(".concat(JSON.stringify(relative), ");"); | ||
| } | ||
| })); | ||
| })); | ||
| case 7: | ||
| case "end": | ||
| return _context.stop(); | ||
| } | ||
| } | ||
| }, _callee); | ||
| })); | ||
| return function (_x, _x2) { | ||
| return _ref9.apply(this, arguments); | ||
| }; | ||
| }()); | ||
| }); | ||
| }); | ||
| }); |
| function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } | ||
| function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); } | ||
| function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); } | ||
| function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } } | ||
| import { produce } from 'immer'; | ||
| import { PLUGIN } from './common'; | ||
| import '@sewing-kit/plugin-jest'; | ||
| export default function testJavaScript(_ref) { | ||
| var hooks = _ref.hooks; | ||
| hooks.project.tap(PLUGIN, function (_ref2) { | ||
| var hooks = _ref2.hooks; | ||
| hooks.configure.tap(PLUGIN, function (hooks) { | ||
| if (hooks.jestExtensions && hooks.jestTransforms) { | ||
| // Unfortunately, some packages (like `graphql`) use `.mjs` for esmodule | ||
| // versions of the file, which Jest can't parse. To avoid transforming | ||
| // those otherwise-fine files, we prefer .js for tests only. | ||
| hooks.jestExtensions.tap(PLUGIN, function (extensions) { | ||
| return ['.js', '.mjs'].concat(_toConsumableArray(extensions)); | ||
| }); | ||
| hooks.jestTransforms.tap(PLUGIN, function (transforms, _ref3) { | ||
| var babelTransform = _ref3.babelTransform; | ||
| return produce(transforms, function (transforms) { | ||
| transforms['^.+\\.[m|j]s$'] = babelTransform; | ||
| }); | ||
| }); | ||
| } | ||
| if (hooks.babelConfig) { | ||
| hooks.babelConfig.tap(PLUGIN, function (babelConfig) { | ||
| return produce(babelConfig, function (babelConfig) { | ||
| babelConfig.presets = babelConfig.presets || []; | ||
| babelConfig.presets.push(['babel-preset-shopify/node', { | ||
| modules: 'commonjs' | ||
| }]); | ||
| }); | ||
| }); | ||
| } | ||
| }); | ||
| }); | ||
| } |
| import { produce } from 'immer'; | ||
| import { PLUGIN } from './common'; // Just loaded for its hook augmentations | ||
| import '@sewing-kit/plugin-webpack'; | ||
| function addBaseBabelPreset(babelConfig) { | ||
| return produce(babelConfig, babelConfig => { | ||
| babelConfig.presets = babelConfig.presets || []; | ||
| babelConfig.presets.push('babel-preset-shopify'); | ||
| }); | ||
| } | ||
| function addJsExtensions(extensions) { | ||
| return ['.js', '.mjs', ...extensions]; | ||
| } | ||
| export default function buildJavaScript({ | ||
| hooks | ||
| }) { | ||
| hooks.package.tap(PLUGIN, ({ | ||
| hooks | ||
| }) => { | ||
| hooks.configure.tap(PLUGIN, configurationHooks => { | ||
| if (configurationHooks.babelConfig) { | ||
| configurationHooks.babelConfig.tap(PLUGIN, addBaseBabelPreset); | ||
| } | ||
| configurationHooks.extensions.tap(PLUGIN, addJsExtensions); | ||
| }); | ||
| }); | ||
| hooks.webApp.tap(PLUGIN, ({ | ||
| hooks | ||
| }) => { | ||
| hooks.configure.tap(PLUGIN, configurationHooks => { | ||
| configurationHooks.extensions.tap(PLUGIN, addJsExtensions); | ||
| if (configurationHooks.babelConfig) { | ||
| configurationHooks.babelConfig.tap(PLUGIN, addBaseBabelPreset); | ||
| } | ||
| if (configurationHooks.webpackRules) { | ||
| configurationHooks.webpackRules.tapPromise(PLUGIN, async (rules, target) => { | ||
| const options = configurationHooks.babelConfig && (await configurationHooks.babelConfig.promise({}, target)); | ||
| return produce(rules, rules => { | ||
| rules.push({ | ||
| test: /\.m?js/, | ||
| exclude: /node_modules/, | ||
| loader: 'babel-loader', | ||
| options | ||
| }); | ||
| }); | ||
| }); | ||
| } | ||
| }); | ||
| }); | ||
| } |
| export const PLUGIN = 'SewingKit.javascript'; |
| export * from './plugin-package-esmodules'; |
| import { PLUGIN } from './common'; | ||
| import '@sewing-kit/plugin-eslint'; | ||
| export default function lintJavaScript({ | ||
| hooks | ||
| }) { | ||
| hooks.configure.tap(PLUGIN, hooks => { | ||
| if (hooks.eslintExtensions) { | ||
| hooks.eslintExtensions.tap(PLUGIN, extensions => [...extensions, '.mjs', '.js']); | ||
| } | ||
| }); | ||
| } |
| import { createRootPlugin, lazy } from '@sewing-kit/plugin-utilities'; | ||
| import { PLUGIN } from './common'; | ||
| export default createRootPlugin(PLUGIN, tasks => { | ||
| tasks.test.tapPromise(PLUGIN, lazy(() => import('./test'))); | ||
| tasks.build.tapPromise(PLUGIN, lazy(() => import('./build'))); | ||
| tasks.lint.tapPromise(PLUGIN, lazy(() => import('./lint'))); | ||
| }); |
| import { join } from 'path'; | ||
| import { produce } from 'immer'; | ||
| import { createRootPlugin } from '@sewing-kit/plugin-utilities'; | ||
| import { createWriteEntriesStep } from '@sewing-kit/plugin-package-utilities'; | ||
| import { updateBabelPreset, createCompileBabelStep } from '@sewing-kit/plugin-babel'; | ||
| const PLUGIN = 'SewingKit.package-esmodules'; | ||
| const VARIANT = 'esmodules'; | ||
| export default createRootPlugin(PLUGIN, tasks => { | ||
| tasks.build.tap(PLUGIN, ({ | ||
| workspace, | ||
| hooks | ||
| }) => { | ||
| hooks.package.tap(PLUGIN, ({ | ||
| pkg, | ||
| hooks | ||
| }) => { | ||
| hooks.variants.tap(PLUGIN, variants => [...variants, { | ||
| [VARIANT]: true | ||
| }]); | ||
| hooks.configure.tap(PLUGIN, (configurationHooks, { | ||
| esmodules | ||
| }) => { | ||
| if (!esmodules) { | ||
| return; | ||
| } | ||
| if (configurationHooks.babelConfig) { | ||
| configurationHooks.babelConfig.tap(PLUGIN, babelConfig => { | ||
| return produce(babelConfig, updateBabelPreset(['babel-preset-shopify', 'babel-preset-shopify/web', 'babel-preset-shopify/node'], { | ||
| modules: false | ||
| })); | ||
| }); | ||
| } | ||
| configurationHooks.output.tap(PLUGIN, output => join(output, 'esm')); | ||
| }); | ||
| hooks.steps.tapPromise(PLUGIN, async (steps, { | ||
| config, | ||
| variant: { | ||
| esmodules | ||
| } | ||
| }) => { | ||
| if (!esmodules) { | ||
| return steps; | ||
| } | ||
| const outputPath = await config.output.promise(pkg.fs.buildPath()); | ||
| return produce(steps, steps => { | ||
| steps.push(createCompileBabelStep(pkg, workspace, config, { | ||
| outputPath, | ||
| configFile: 'babel.esm.js' | ||
| }), createWriteEntriesStep(pkg, { | ||
| outputPath, | ||
| extension: '.mjs', | ||
| contents: relative => `export * from ${JSON.stringify(relative)};` | ||
| })); | ||
| }); | ||
| }); | ||
| }); | ||
| }); | ||
| }); |
| import { join } from 'path'; | ||
| import { produce } from 'immer'; | ||
| import { Runtime } from '@sewing-kit/core'; | ||
| import { createRootPlugin } from '@sewing-kit/plugin-utilities'; | ||
| import { createWriteEntriesStep } from '@sewing-kit/plugin-package-utilities'; | ||
| import { changeBabelPreset, updateBabelPreset, createCompileBabelStep } from '@sewing-kit/plugin-babel'; | ||
| import '@sewing-kit/plugin-jest'; | ||
| const PLUGIN = 'SewingKit.package-commonjs'; | ||
| const VARIANT = 'node'; | ||
| const EXTENSION = '.node'; | ||
| export default createRootPlugin(PLUGIN, tasks => { | ||
| tasks.test.tap(PLUGIN, ({ | ||
| hooks | ||
| }) => { | ||
| hooks.project.tap(PLUGIN, ({ | ||
| hooks | ||
| }) => { | ||
| hooks.configure.tap(PLUGIN, hooks => { | ||
| if (hooks.jestExtensions) { | ||
| hooks.jestExtensions.tap(PLUGIN, extensions => [EXTENSION, ...extensions]); | ||
| } | ||
| }); | ||
| }); | ||
| }); | ||
| tasks.build.tap(PLUGIN, ({ | ||
| workspace, | ||
| hooks | ||
| }) => { | ||
| hooks.package.tap(PLUGIN, ({ | ||
| pkg, | ||
| hooks | ||
| }) => { | ||
| hooks.variants.tap(PLUGIN, variants => { | ||
| // If all the entries already target node, there is no need to do a | ||
| // node-only build (it will match the CommonJS build). | ||
| if (pkg.entries.every(({ | ||
| runtime | ||
| }) => runtime === Runtime.Node)) { | ||
| return variants; | ||
| } | ||
| return [...variants, { | ||
| [VARIANT]: true | ||
| }]; | ||
| }); | ||
| hooks.configure.tap(PLUGIN, (configurationHooks, { | ||
| node | ||
| }) => { | ||
| if (!node) { | ||
| return; | ||
| } | ||
| if (configurationHooks.babelConfig) { | ||
| configurationHooks.babelConfig.tap(PLUGIN, babelConfig => { | ||
| return produce(babelConfig, babelConfig => { | ||
| changeBabelPreset(['babel-preset-shopify', 'babel-preset-shopify/web'], 'babel-preset-shopify/node')(babelConfig); | ||
| updateBabelPreset('babel-preset-shopify/node', { | ||
| modules: 'commonjs' | ||
| })(babelConfig); | ||
| }); | ||
| }); | ||
| } | ||
| configurationHooks.output.tap(PLUGIN, output => join(output, 'node')); | ||
| }); | ||
| hooks.steps.tapPromise(PLUGIN, async (steps, { | ||
| config, | ||
| variant: { | ||
| node | ||
| } | ||
| }) => { | ||
| if (!node) { | ||
| return steps; | ||
| } | ||
| const outputPath = await config.output.promise(pkg.fs.buildPath()); | ||
| return produce(steps, steps => { | ||
| steps.push(createCompileBabelStep(pkg, workspace, config, { | ||
| outputPath, | ||
| configFile: 'babel.node.js' | ||
| }), createWriteEntriesStep(pkg, { | ||
| outputPath, | ||
| extension: EXTENSION, | ||
| exclude: entry => entry.runtime === Runtime.Node, | ||
| contents: relative => `module.exports = require(${JSON.stringify(relative)});` | ||
| })); | ||
| }); | ||
| }); | ||
| }); | ||
| }); | ||
| }); |
| import { produce } from 'immer'; | ||
| import { PLUGIN } from './common'; | ||
| import '@sewing-kit/plugin-jest'; | ||
| export default function testJavaScript({ | ||
| hooks | ||
| }) { | ||
| hooks.project.tap(PLUGIN, ({ | ||
| hooks | ||
| }) => { | ||
| hooks.configure.tap(PLUGIN, hooks => { | ||
| if (hooks.jestExtensions && hooks.jestTransforms) { | ||
| // Unfortunately, some packages (like `graphql`) use `.mjs` for esmodule | ||
| // versions of the file, which Jest can't parse. To avoid transforming | ||
| // those otherwise-fine files, we prefer .js for tests only. | ||
| hooks.jestExtensions.tap(PLUGIN, extensions => ['.js', '.mjs', ...extensions]); | ||
| hooks.jestTransforms.tap(PLUGIN, (transforms, { | ||
| babelTransform | ||
| }) => { | ||
| return produce(transforms, transforms => { | ||
| transforms['^.+\\.[m|j]s$'] = babelTransform; | ||
| }); | ||
| }); | ||
| } | ||
| if (hooks.babelConfig) { | ||
| hooks.babelConfig.tap(PLUGIN, babelConfig => { | ||
| return produce(babelConfig, babelConfig => { | ||
| babelConfig.presets = babelConfig.presets || []; | ||
| babelConfig.presets.push(['babel-preset-shopify/node', { | ||
| modules: 'commonjs' | ||
| }]); | ||
| }); | ||
| }); | ||
| } | ||
| }); | ||
| }); | ||
| } |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { | ||
| value: true | ||
| }); | ||
| exports.default = buildJavaScript; | ||
| var _immer = require("immer"); | ||
| var _common = require("./common"); | ||
| require("@sewing-kit/plugin-webpack"); | ||
| // Just loaded for its hook augmentations | ||
| function addBaseBabelPreset(babelConfig) { | ||
| return (0, _immer.produce)(babelConfig, babelConfig => { | ||
| babelConfig.presets = babelConfig.presets || []; | ||
| babelConfig.presets.push('babel-preset-shopify'); | ||
| }); | ||
| } | ||
| function addJsExtensions(extensions) { | ||
| return ['.js', '.mjs', ...extensions]; | ||
| } | ||
| function buildJavaScript({ | ||
| hooks | ||
| }) { | ||
| hooks.package.tap(_common.PLUGIN, ({ | ||
| hooks | ||
| }) => { | ||
| hooks.configure.tap(_common.PLUGIN, configurationHooks => { | ||
| if (configurationHooks.babelConfig) { | ||
| configurationHooks.babelConfig.tap(_common.PLUGIN, addBaseBabelPreset); | ||
| } | ||
| configurationHooks.extensions.tap(_common.PLUGIN, addJsExtensions); | ||
| }); | ||
| }); | ||
| hooks.webApp.tap(_common.PLUGIN, ({ | ||
| hooks | ||
| }) => { | ||
| hooks.configure.tap(_common.PLUGIN, configurationHooks => { | ||
| configurationHooks.extensions.tap(_common.PLUGIN, addJsExtensions); | ||
| if (configurationHooks.babelConfig) { | ||
| configurationHooks.babelConfig.tap(_common.PLUGIN, addBaseBabelPreset); | ||
| } | ||
| if (configurationHooks.webpackRules) { | ||
| configurationHooks.webpackRules.tapPromise(_common.PLUGIN, async (rules, target) => { | ||
| const options = configurationHooks.babelConfig && (await configurationHooks.babelConfig.promise({}, target)); | ||
| return (0, _immer.produce)(rules, rules => { | ||
| rules.push({ | ||
| test: /\.m?js/, | ||
| exclude: /node_modules/, | ||
| loader: 'babel-loader', | ||
| options | ||
| }); | ||
| }); | ||
| }); | ||
| } | ||
| }); | ||
| }); | ||
| } |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { | ||
| value: true | ||
| }); | ||
| exports.PLUGIN = void 0; | ||
| const PLUGIN = 'SewingKit.javascript'; | ||
| exports.PLUGIN = PLUGIN; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { | ||
| value: true | ||
| }); | ||
| var _pluginPackageEsmodules = require("./plugin-package-esmodules"); | ||
| Object.keys(_pluginPackageEsmodules).forEach(function (key) { | ||
| if (key === "default" || key === "__esModule") return; | ||
| Object.defineProperty(exports, key, { | ||
| enumerable: true, | ||
| get: function () { | ||
| return _pluginPackageEsmodules[key]; | ||
| } | ||
| }); | ||
| }); |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { | ||
| value: true | ||
| }); | ||
| exports.default = lintJavaScript; | ||
| var _common = require("./common"); | ||
| require("@sewing-kit/plugin-eslint"); | ||
| function lintJavaScript({ | ||
| hooks | ||
| }) { | ||
| hooks.configure.tap(_common.PLUGIN, hooks => { | ||
| if (hooks.eslintExtensions) { | ||
| hooks.eslintExtensions.tap(_common.PLUGIN, extensions => [...extensions, '.mjs', '.js']); | ||
| } | ||
| }); | ||
| } |
| "use strict"; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { | ||
| value: true | ||
| }); | ||
| exports.default = void 0; | ||
| var _pluginUtilities = require("@sewing-kit/plugin-utilities"); | ||
| var _common = require("./common"); | ||
| function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } | ||
| var _default = (0, _pluginUtilities.createRootPlugin)(_common.PLUGIN, tasks => { | ||
| tasks.test.tapPromise(_common.PLUGIN, (0, _pluginUtilities.lazy)(() => Promise.resolve().then(() => _interopRequireWildcard(require('./test'))))); | ||
| tasks.build.tapPromise(_common.PLUGIN, (0, _pluginUtilities.lazy)(() => Promise.resolve().then(() => _interopRequireWildcard(require('./build'))))); | ||
| tasks.lint.tapPromise(_common.PLUGIN, (0, _pluginUtilities.lazy)(() => Promise.resolve().then(() => _interopRequireWildcard(require('./lint'))))); | ||
| }); | ||
| exports.default = _default; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { | ||
| value: true | ||
| }); | ||
| exports.default = void 0; | ||
| var _path = require("path"); | ||
| var _immer = require("immer"); | ||
| var _pluginUtilities = require("@sewing-kit/plugin-utilities"); | ||
| var _pluginPackageUtilities = require("@sewing-kit/plugin-package-utilities"); | ||
| var _pluginBabel = require("@sewing-kit/plugin-babel"); | ||
| const PLUGIN = 'SewingKit.package-esmodules'; | ||
| const VARIANT = 'esmodules'; | ||
| var _default = (0, _pluginUtilities.createRootPlugin)(PLUGIN, tasks => { | ||
| tasks.build.tap(PLUGIN, ({ | ||
| workspace, | ||
| hooks | ||
| }) => { | ||
| hooks.package.tap(PLUGIN, ({ | ||
| pkg, | ||
| hooks | ||
| }) => { | ||
| hooks.variants.tap(PLUGIN, variants => [...variants, { | ||
| [VARIANT]: true | ||
| }]); | ||
| hooks.configure.tap(PLUGIN, (configurationHooks, { | ||
| esmodules | ||
| }) => { | ||
| if (!esmodules) { | ||
| return; | ||
| } | ||
| if (configurationHooks.babelConfig) { | ||
| configurationHooks.babelConfig.tap(PLUGIN, babelConfig => { | ||
| return (0, _immer.produce)(babelConfig, (0, _pluginBabel.updateBabelPreset)(['babel-preset-shopify', 'babel-preset-shopify/web', 'babel-preset-shopify/node'], { | ||
| modules: false | ||
| })); | ||
| }); | ||
| } | ||
| configurationHooks.output.tap(PLUGIN, output => (0, _path.join)(output, 'esm')); | ||
| }); | ||
| hooks.steps.tapPromise(PLUGIN, async (steps, { | ||
| config, | ||
| variant: { | ||
| esmodules | ||
| } | ||
| }) => { | ||
| if (!esmodules) { | ||
| return steps; | ||
| } | ||
| const outputPath = await config.output.promise(pkg.fs.buildPath()); | ||
| return (0, _immer.produce)(steps, steps => { | ||
| steps.push((0, _pluginBabel.createCompileBabelStep)(pkg, workspace, config, { | ||
| outputPath, | ||
| configFile: 'babel.esm.js' | ||
| }), (0, _pluginPackageUtilities.createWriteEntriesStep)(pkg, { | ||
| outputPath, | ||
| extension: '.mjs', | ||
| contents: relative => `export * from ${JSON.stringify(relative)};` | ||
| })); | ||
| }); | ||
| }); | ||
| }); | ||
| }); | ||
| }); | ||
| exports.default = _default; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { | ||
| value: true | ||
| }); | ||
| exports.default = void 0; | ||
| var _path = require("path"); | ||
| var _immer = require("immer"); | ||
| var _core = require("@sewing-kit/core"); | ||
| var _pluginUtilities = require("@sewing-kit/plugin-utilities"); | ||
| var _pluginPackageUtilities = require("@sewing-kit/plugin-package-utilities"); | ||
| var _pluginBabel = require("@sewing-kit/plugin-babel"); | ||
| require("@sewing-kit/plugin-jest"); | ||
| const PLUGIN = 'SewingKit.package-commonjs'; | ||
| const VARIANT = 'node'; | ||
| const EXTENSION = '.node'; | ||
| var _default = (0, _pluginUtilities.createRootPlugin)(PLUGIN, tasks => { | ||
| tasks.test.tap(PLUGIN, ({ | ||
| hooks | ||
| }) => { | ||
| hooks.project.tap(PLUGIN, ({ | ||
| hooks | ||
| }) => { | ||
| hooks.configure.tap(PLUGIN, hooks => { | ||
| if (hooks.jestExtensions) { | ||
| hooks.jestExtensions.tap(PLUGIN, extensions => [EXTENSION, ...extensions]); | ||
| } | ||
| }); | ||
| }); | ||
| }); | ||
| tasks.build.tap(PLUGIN, ({ | ||
| workspace, | ||
| hooks | ||
| }) => { | ||
| hooks.package.tap(PLUGIN, ({ | ||
| pkg, | ||
| hooks | ||
| }) => { | ||
| hooks.variants.tap(PLUGIN, variants => { | ||
| // If all the entries already target node, there is no need to do a | ||
| // node-only build (it will match the CommonJS build). | ||
| if (pkg.entries.every(({ | ||
| runtime | ||
| }) => runtime === _core.Runtime.Node)) { | ||
| return variants; | ||
| } | ||
| return [...variants, { | ||
| [VARIANT]: true | ||
| }]; | ||
| }); | ||
| hooks.configure.tap(PLUGIN, (configurationHooks, { | ||
| node | ||
| }) => { | ||
| if (!node) { | ||
| return; | ||
| } | ||
| if (configurationHooks.babelConfig) { | ||
| configurationHooks.babelConfig.tap(PLUGIN, babelConfig => { | ||
| return (0, _immer.produce)(babelConfig, babelConfig => { | ||
| (0, _pluginBabel.changeBabelPreset)(['babel-preset-shopify', 'babel-preset-shopify/web'], 'babel-preset-shopify/node')(babelConfig); | ||
| (0, _pluginBabel.updateBabelPreset)('babel-preset-shopify/node', { | ||
| modules: 'commonjs' | ||
| })(babelConfig); | ||
| }); | ||
| }); | ||
| } | ||
| configurationHooks.output.tap(PLUGIN, output => (0, _path.join)(output, 'node')); | ||
| }); | ||
| hooks.steps.tapPromise(PLUGIN, async (steps, { | ||
| config, | ||
| variant: { | ||
| node | ||
| } | ||
| }) => { | ||
| if (!node) { | ||
| return steps; | ||
| } | ||
| const outputPath = await config.output.promise(pkg.fs.buildPath()); | ||
| return (0, _immer.produce)(steps, steps => { | ||
| steps.push((0, _pluginBabel.createCompileBabelStep)(pkg, workspace, config, { | ||
| outputPath, | ||
| configFile: 'babel.node.js' | ||
| }), (0, _pluginPackageUtilities.createWriteEntriesStep)(pkg, { | ||
| outputPath, | ||
| extension: EXTENSION, | ||
| exclude: entry => entry.runtime === _core.Runtime.Node, | ||
| contents: relative => `module.exports = require(${JSON.stringify(relative)});` | ||
| })); | ||
| }); | ||
| }); | ||
| }); | ||
| }); | ||
| }); | ||
| exports.default = _default; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { | ||
| value: true | ||
| }); | ||
| exports.default = testJavaScript; | ||
| var _immer = require("immer"); | ||
| var _common = require("./common"); | ||
| require("@sewing-kit/plugin-jest"); | ||
| function testJavaScript({ | ||
| hooks | ||
| }) { | ||
| hooks.project.tap(_common.PLUGIN, ({ | ||
| hooks | ||
| }) => { | ||
| hooks.configure.tap(_common.PLUGIN, hooks => { | ||
| if (hooks.jestExtensions && hooks.jestTransforms) { | ||
| // Unfortunately, some packages (like `graphql`) use `.mjs` for esmodule | ||
| // versions of the file, which Jest can't parse. To avoid transforming | ||
| // those otherwise-fine files, we prefer .js for tests only. | ||
| hooks.jestExtensions.tap(_common.PLUGIN, extensions => ['.js', '.mjs', ...extensions]); | ||
| hooks.jestTransforms.tap(_common.PLUGIN, (transforms, { | ||
| babelTransform | ||
| }) => { | ||
| return (0, _immer.produce)(transforms, transforms => { | ||
| transforms['^.+\\.[m|j]s$'] = babelTransform; | ||
| }); | ||
| }); | ||
| } | ||
| if (hooks.babelConfig) { | ||
| hooks.babelConfig.tap(_common.PLUGIN, babelConfig => { | ||
| return (0, _immer.produce)(babelConfig, babelConfig => { | ||
| babelConfig.presets = babelConfig.presets || []; | ||
| babelConfig.presets.push(['babel-preset-shopify/node', { | ||
| modules: 'commonjs' | ||
| }]); | ||
| }); | ||
| }); | ||
| } | ||
| }); | ||
| }); | ||
| } |
| export default function buildJavaScript({ hooks, }: import('@sewing-kit/core').BuildTask): void; | ||
| //# sourceMappingURL=build.d.ts.map |
| {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/build.ts"],"names":[],"mappings":"AAkBA,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,EACtC,KAAK,GACN,EAAE,OAAO,kBAAkB,EAAE,SAAS,QAwCtC"} |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| const immer_1 = require("immer"); | ||
| const common_1 = require("./common"); | ||
| function addBaseBabelPreset(babelConfig) { | ||
| return immer_1.produce(babelConfig, (babelConfig) => { | ||
| babelConfig.presets = babelConfig.presets || []; | ||
| babelConfig.presets.push('babel-preset-shopify'); | ||
| }); | ||
| } | ||
| function addJsExtensions(extensions) { | ||
| return ['.js', '.mjs', ...extensions]; | ||
| } | ||
| function buildJavaScript({ hooks, }) { | ||
| hooks.package.tap(common_1.PLUGIN, ({ hooks }) => { | ||
| hooks.configure.tap(common_1.PLUGIN, (configurationHooks) => { | ||
| if (configurationHooks.babelConfig) { | ||
| configurationHooks.babelConfig.tap(common_1.PLUGIN, addBaseBabelPreset); | ||
| } | ||
| configurationHooks.extensions.tap(common_1.PLUGIN, addJsExtensions); | ||
| }); | ||
| }); | ||
| hooks.webApp.tap(common_1.PLUGIN, ({ hooks }) => { | ||
| hooks.configure.tap(common_1.PLUGIN, (configurationHooks) => { | ||
| configurationHooks.extensions.tap(common_1.PLUGIN, addJsExtensions); | ||
| if (configurationHooks.babelConfig) { | ||
| configurationHooks.babelConfig.tap(common_1.PLUGIN, addBaseBabelPreset); | ||
| } | ||
| if (configurationHooks.webpackRules) { | ||
| configurationHooks.webpackRules.tapPromise(common_1.PLUGIN, async (rules, target) => { | ||
| const options = configurationHooks.babelConfig && | ||
| (await configurationHooks.babelConfig.promise({}, target)); | ||
| return immer_1.produce(rules, (rules) => { | ||
| rules.push({ | ||
| test: /\.m?js/, | ||
| exclude: /node_modules/, | ||
| loader: 'babel-loader', | ||
| options, | ||
| }); | ||
| }); | ||
| }); | ||
| } | ||
| }); | ||
| }); | ||
| } | ||
| exports.default = buildJavaScript; |
| export declare const PLUGIN = "SewingKit.javascript"; | ||
| //# sourceMappingURL=common.d.ts.map |
| {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/common.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,MAAM,yBAAyB,CAAC"} |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.PLUGIN = 'SewingKit.javascript'; |
| export default function lintJavaScript({ hooks, }: import('@sewing-kit/core').LintTask): void; | ||
| //# sourceMappingURL=lint.d.ts.map |
| {"version":3,"file":"lint.d.ts","sourceRoot":"","sources":["../../src/lint.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,EACrC,KAAK,GACN,EAAE,OAAO,kBAAkB,EAAE,QAAQ,QAUrC"} |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| const common_1 = require("./common"); | ||
| function lintJavaScript({ hooks, }) { | ||
| hooks.configure.tap(common_1.PLUGIN, (hooks) => { | ||
| if (hooks.eslintExtensions) { | ||
| hooks.eslintExtensions.tap(common_1.PLUGIN, (extensions) => [ | ||
| ...extensions, | ||
| '.mjs', | ||
| '.js', | ||
| ]); | ||
| } | ||
| }); | ||
| } | ||
| exports.default = lintJavaScript; |
| declare const _default: (tasks: import("@sewing-kit/core").RunnerTasks) => void; | ||
| export default _default; | ||
| //# sourceMappingURL=plugin-javascript.d.ts.map |
| {"version":3,"file":"plugin-javascript.d.ts","sourceRoot":"","sources":["../../src/plugin-javascript.ts"],"names":[],"mappings":";AAGA,wBAIG"} |
| "use strict"; | ||
| var __importStar = (this && this.__importStar) || function (mod) { | ||
| if (mod && mod.__esModule) return mod; | ||
| var result = {}; | ||
| if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; | ||
| result["default"] = mod; | ||
| return result; | ||
| }; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| const plugin_utilities_1 = require("@sewing-kit/plugin-utilities"); | ||
| const common_1 = require("./common"); | ||
| exports.default = plugin_utilities_1.createRootPlugin(common_1.PLUGIN, (tasks) => { | ||
| tasks.test.tapPromise(common_1.PLUGIN, plugin_utilities_1.lazy(() => Promise.resolve().then(() => __importStar(require('./test'))))); | ||
| tasks.build.tapPromise(common_1.PLUGIN, plugin_utilities_1.lazy(() => Promise.resolve().then(() => __importStar(require('./build'))))); | ||
| tasks.lint.tapPromise(common_1.PLUGIN, plugin_utilities_1.lazy(() => Promise.resolve().then(() => __importStar(require('./lint'))))); | ||
| }); |
| declare const _default: (tasks: import("@sewing-kit/core").RunnerTasks) => void; | ||
| export default _default; | ||
| //# sourceMappingURL=plugin-json.d.ts.map |
| {"version":3,"file":"plugin-json.d.ts","sourceRoot":"","sources":["../../src/plugin-json.ts"],"names":[],"mappings":";AASA,wBAwBG"} |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| const plugin_utilities_1 = require("@sewing-kit/plugin-utilities"); | ||
| const PLUGIN = 'SewingKit.json'; | ||
| function addJsonExtension(extensions) { | ||
| return ['.json', ...extensions]; | ||
| } | ||
| exports.default = plugin_utilities_1.createRootPlugin(PLUGIN, (tasks) => { | ||
| tasks.build.tap(PLUGIN, ({ hooks }) => { | ||
| hooks.package.tap(PLUGIN, ({ hooks }) => { | ||
| hooks.configure.tap(PLUGIN, (configurationHooks) => { | ||
| configurationHooks.extensions.tap(PLUGIN, addJsonExtension); | ||
| }); | ||
| }); | ||
| hooks.webApp.tap(PLUGIN, ({ hooks }) => { | ||
| hooks.configure.tap(PLUGIN, (configurationHooks) => { | ||
| configurationHooks.extensions.tap(PLUGIN, addJsonExtension); | ||
| }); | ||
| }); | ||
| }); | ||
| tasks.test.tap(PLUGIN, ({ hooks }) => { | ||
| hooks.project.tap(PLUGIN, ({ hooks }) => { | ||
| hooks.configure.tap(PLUGIN, (hooks) => { | ||
| if (hooks.jestExtensions) { | ||
| hooks.jestExtensions.tap(PLUGIN, addJsonExtension); | ||
| } | ||
| }); | ||
| }); | ||
| }); | ||
| }); |
| declare const VARIANT = "node"; | ||
| declare module '@sewing-kit/core/build/ts/tasks/build/types' { | ||
| interface BuildPackageOptions { | ||
| [VARIANT]: boolean; | ||
| } | ||
| } | ||
| declare const _default: (tasks: import("@sewing-kit/core").RunnerTasks) => void; | ||
| export default _default; | ||
| //# sourceMappingURL=plugin-package-node.d.ts.map |
| {"version":3,"file":"plugin-package-node.d.ts","sourceRoot":"","sources":["../../src/plugin-package-node.ts"],"names":[],"mappings":"AAcA,QAAA,MAAM,OAAO,SAAS,CAAC;AAGvB,OAAO,QAAQ,6CAA6C,CAAC;IAC3D,UAAU,mBAAmB;QAC3B,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;KACpB;CACF;;AAED,wBA6EG"} |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| const path_1 = require("path"); | ||
| const immer_1 = require("immer"); | ||
| const core_1 = require("@sewing-kit/core"); | ||
| const plugin_utilities_1 = require("@sewing-kit/plugin-utilities"); | ||
| const plugin_package_utilities_1 = require("@sewing-kit/plugin-package-utilities"); | ||
| const plugin_babel_1 = require("@sewing-kit/plugin-babel"); | ||
| const PLUGIN = 'SewingKit.package-commonjs'; | ||
| const VARIANT = 'node'; | ||
| const EXTENSION = '.node'; | ||
| exports.default = plugin_utilities_1.createRootPlugin(PLUGIN, (tasks) => { | ||
| tasks.test.tap(PLUGIN, ({ hooks }) => { | ||
| hooks.project.tap(PLUGIN, ({ hooks }) => { | ||
| hooks.configure.tap(PLUGIN, (hooks) => { | ||
| if (hooks.jestExtensions) { | ||
| hooks.jestExtensions.tap(PLUGIN, (extensions) => [ | ||
| EXTENSION, | ||
| ...extensions, | ||
| ]); | ||
| } | ||
| }); | ||
| }); | ||
| }); | ||
| tasks.build.tap(PLUGIN, ({ workspace, hooks }) => { | ||
| hooks.package.tap(PLUGIN, ({ pkg, hooks }) => { | ||
| hooks.variants.tap(PLUGIN, (variants) => { | ||
| // If all the entries already target node, there is no need to do a | ||
| // node-only build (it will match the CommonJS build). | ||
| if (pkg.entries.every(({ runtime }) => runtime === core_1.Runtime.Node)) { | ||
| return variants; | ||
| } | ||
| return [...variants, { [VARIANT]: true }]; | ||
| }); | ||
| hooks.configure.tap(PLUGIN, (configurationHooks, { node }) => { | ||
| if (!node) { | ||
| return; | ||
| } | ||
| if (configurationHooks.babelConfig) { | ||
| configurationHooks.babelConfig.tap(PLUGIN, (babelConfig) => { | ||
| return immer_1.produce(babelConfig, (babelConfig) => { | ||
| plugin_babel_1.changeBabelPreset(['babel-preset-shopify', 'babel-preset-shopify/web'], 'babel-preset-shopify/node')(babelConfig); | ||
| plugin_babel_1.updateBabelPreset('babel-preset-shopify/node', { | ||
| modules: 'commonjs', | ||
| })(babelConfig); | ||
| }); | ||
| }); | ||
| } | ||
| configurationHooks.output.tap(PLUGIN, (output) => path_1.join(output, 'node')); | ||
| }); | ||
| hooks.steps.tapPromise(PLUGIN, async (steps, { config, variant: { node } }) => { | ||
| if (!node) { | ||
| return steps; | ||
| } | ||
| const outputPath = await config.output.promise(pkg.fs.buildPath()); | ||
| return immer_1.produce(steps, (steps) => { | ||
| steps.push(plugin_babel_1.createCompileBabelStep(pkg, workspace, config, { | ||
| outputPath, | ||
| configFile: 'babel.node.js', | ||
| }), plugin_package_utilities_1.createWriteEntriesStep(pkg, { | ||
| outputPath, | ||
| extension: EXTENSION, | ||
| exclude: (entry) => entry.runtime === core_1.Runtime.Node, | ||
| contents: (relative) => `module.exports = require(${JSON.stringify(relative)});`, | ||
| })); | ||
| }); | ||
| }); | ||
| }); | ||
| }); | ||
| }); |
| export default function testJavaScript({ hooks, }: import('@sewing-kit/core').TestTask): void; | ||
| //# sourceMappingURL=test.d.ts.map |
| {"version":3,"file":"test.d.ts","sourceRoot":"","sources":["../../src/test.ts"],"names":[],"mappings":"AAKA,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,EACrC,KAAK,GACN,EAAE,OAAO,kBAAkB,EAAE,QAAQ,QAiCrC"} |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| const immer_1 = require("immer"); | ||
| const common_1 = require("./common"); | ||
| function testJavaScript({ hooks, }) { | ||
| hooks.project.tap(common_1.PLUGIN, ({ hooks }) => { | ||
| hooks.configure.tap(common_1.PLUGIN, (hooks) => { | ||
| if (hooks.jestExtensions && hooks.jestTransforms) { | ||
| // Unfortunately, some packages (like `graphql`) use `.mjs` for esmodule | ||
| // versions of the file, which Jest can't parse. To avoid transforming | ||
| // those otherwise-fine files, we prefer .js for tests only. | ||
| hooks.jestExtensions.tap(common_1.PLUGIN, (extensions) => [ | ||
| '.js', | ||
| '.mjs', | ||
| ...extensions, | ||
| ]); | ||
| hooks.jestTransforms.tap(common_1.PLUGIN, (transforms, { babelTransform }) => { | ||
| return immer_1.produce(transforms, (transforms) => { | ||
| transforms['^.+\\.[m|j]s$'] = babelTransform; | ||
| }); | ||
| }); | ||
| } | ||
| if (hooks.babelConfig) { | ||
| hooks.babelConfig.tap(common_1.PLUGIN, (babelConfig) => { | ||
| return immer_1.produce(babelConfig, (babelConfig) => { | ||
| babelConfig.presets = babelConfig.presets || []; | ||
| babelConfig.presets.push([ | ||
| 'babel-preset-shopify/node', | ||
| { modules: 'commonjs' }, | ||
| ]); | ||
| }); | ||
| }); | ||
| } | ||
| }); | ||
| }); | ||
| } | ||
| exports.default = testJavaScript; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
359122
39.46%1
Infinity%17
-77.03%261
-84.62%+ Added
+ Added