From 25036ca1183a262effb590a14058075b28f24f4e Mon Sep 17 00:00:00 2001 From: Drew Powers Date: Tue, 9 Jun 2020 19:27:16 -0600 Subject: [PATCH] Add buildOptions.metadataDir option --- docs/05-configuration.md | 6 + package.json | 4 +- src/commands/build-util.ts | 72 +++++++++--- src/commands/build.ts | 18 ++- src/commands/dev.ts | 37 ++++-- src/config.ts | 17 +++ test/build/metadata-dir/.gitignore | 1 + test/build/metadata-dir/index.test.js | 9 ++ .../node_modules/shallow-equal/LICENSE | 21 ++++ .../node_modules/shallow-equal/README.md | 38 ++++++ .../shallow-equal/arrays/index.js | 27 +++++ .../shallow-equal/dist/index.cjs.js | 58 +++++++++ .../shallow-equal/dist/index.esm.js | 53 +++++++++ .../shallow-equal/objects/index.js | 31 +++++ .../node_modules/shallow-equal/package.json | 110 ++++++++++++++++++ test/build/metadata-dir/package-lock.json | 11 ++ test/build/metadata-dir/package.json | 13 +++ 17 files changed, 494 insertions(+), 32 deletions(-) create mode 100644 test/build/metadata-dir/.gitignore create mode 100644 test/build/metadata-dir/index.test.js create mode 100644 test/build/metadata-dir/node_modules/shallow-equal/LICENSE create mode 100644 test/build/metadata-dir/node_modules/shallow-equal/README.md create mode 100644 test/build/metadata-dir/node_modules/shallow-equal/arrays/index.js create mode 100644 test/build/metadata-dir/node_modules/shallow-equal/dist/index.cjs.js create mode 100644 test/build/metadata-dir/node_modules/shallow-equal/dist/index.esm.js create mode 100644 test/build/metadata-dir/node_modules/shallow-equal/objects/index.js create mode 100644 test/build/metadata-dir/node_modules/shallow-equal/package.json create mode 100644 test/build/metadata-dir/package-lock.json create mode 100644 test/build/metadata-dir/package.json diff --git a/docs/05-configuration.md b/docs/05-configuration.md index 8e2a4b019f..189fb8c57b 100644 --- a/docs/05-configuration.md +++ b/docs/05-configuration.md @@ -50,6 +50,7 @@ $ snowpack dev --no-bundle "scripts": { /* ... */ }, "installOptions": { /* ... */ }, "devOptions": { /* ... */ }, + "buildOptions": { /* ... */ }, "proxy": { /* ... */ }, } ``` @@ -116,6 +117,11 @@ $ snowpack dev --no-bundle - **`hmr`** | `boolean` | Default: `true` - Toggles whether or not Snowpack dev server should have HMR enabled. +#### Build Options + +- **`metadataDir`** | `string` | Default: `__snowpack__` + - By default, Snowpack outputs Snowpack-related metadata such as HMR and ENV info to a folder called `__snowpack__`. Configure that here (e.g.: `metadataDir: 'static/snowpack'`). + #### Proxy Options ```js diff --git a/package.json b/package.json index d3b3883f30..0ae450b6bb 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,9 @@ "publish": "pika publish", "version": "npm run build", "format": "prettier --write \"src/**/*.ts\"", - "test": "jest test/integration/runner.js --test-timeout=15000 --testMatch \"**/test/**/*.[jt]s?(x)\" -i", + "test": "npm run test:integration && npm run test:build", + "test:build": "jest test/build", + "test:integration": "jest test/integration/runner.js --test-timeout=15000 --testMatch \"**/test/**/*.[jt]s?(x)\" -i", "docs:build": "cat docs/* > www/index.md && npx @11ty/eleventy --config www/.eleventy.js", "docs:watch": "cat docs/* > www/index.md && npx @11ty/eleventy --config www/.eleventy.js --serve", "docs:deploy": "npm run docs:build && cp now.json www/dist && cd www/dist && now" diff --git a/src/commands/build-util.ts b/src/commands/build-util.ts index 230989ecbe..8879ab2cd1 100644 --- a/src/commands/build-util.ts +++ b/src/commands/build-util.ts @@ -4,7 +4,12 @@ import execa from 'execa'; import path from 'path'; import {statSync} from 'fs'; import npmRunPath from 'npm-run-path'; -import {BuildScript, SnowpackPluginBuildArgs, SnowpackPluginBuildResult} from '../config'; +import { + SnowpackConfig, + BuildScript, + SnowpackPluginBuildArgs, + SnowpackPluginBuildResult, +} from '../config'; const IS_PREACT = /from\s+['"]preact['"]/; export function checkIsPreact(filePath: string, contents: string) { @@ -22,28 +27,45 @@ export function isDirectoryImport(fileLoc: string, spec: string): boolean { return false; } -export function wrapImportMeta(code: string, {hmr, env}: {hmr: boolean; env: boolean}) { +export function wrapImportMeta({ + code, + hmr, + env, + buildOptions, +}: { + code: string; + hmr: boolean; + env: boolean; + buildOptions: SnowpackConfig['buildOptions']; +}) { if (!code.includes('import.meta')) { return code; } return ( (hmr - ? `import * as __SNOWPACK_HMR__ from '/__snowpack__/hmr.js';\nimport.meta.hot = __SNOWPACK_HMR__.createHotContext(import.meta.url);\n` + ? `import * as __SNOWPACK_HMR__ from '/${buildOptions.metadataDir}/hmr.js';\nimport.meta.hot = __SNOWPACK_HMR__.createHotContext(import.meta.url);\n` : ``) + (env - ? `import __SNOWPACK_ENV__ from '/__snowpack__/env.js';\nimport.meta.env = __SNOWPACK_ENV__;\n` + ? `import __SNOWPACK_ENV__ from '/${buildOptions.metadataDir}/env.js';\nimport.meta.env = __SNOWPACK_ENV__;\n` : ``) + '\n' + code ); } -export async function wrapCssModuleResponse( - url: string, - code: string, - ext: string, +export async function wrapCssModuleResponse({ + url, + code, + ext, hasHmr = false, -) { + buildOptions, +}: { + url: string; + code: string; + ext: string; + hasHmr?: boolean; + buildOptions: SnowpackConfig['buildOptions']; +}) { let core = new Core(); const {injectableSource, exportTokens} = await core.load(code, url, () => { throw new Error('Imports in CSS Modules are not yet supported.'); @@ -62,7 +84,7 @@ document.head.appendChild(styleEl); ${ hasHmr ? ` -import * as __SNOWPACK_HMR_API__ from '/__snowpack__/hmr.js'; +import * as __SNOWPACK_HMR_API__ from '/${buildOptions.metadataDir}/hmr.js'; import.meta.hot = __SNOWPACK_HMR_API__.createHotContext(import.meta.url); import.meta.hot.accept(({module}) => { code = module.code; @@ -76,14 +98,34 @@ import.meta.hot.dispose(() => { }`; } -export function wrapHtmlResponse(code: string, hasHmr = false) { +export function wrapHtmlResponse({ + code, + hasHmr = false, + buildOptions, +}: { + code: string; + hasHmr?: boolean; + buildOptions: SnowpackConfig['buildOptions']; +}) { if (hasHmr) { - code += ``; + code += ``; } return code; } -export function wrapEsmProxyResponse(url: string, code: string, ext: string, hasHmr = false) { +export function wrapEsmProxyResponse({ + url, + code, + ext, + hasHmr = false, + buildOptions, +}: { + url: string; + code: string; + ext: string; + hasHmr?: boolean; + buildOptions: SnowpackConfig['buildOptions']; +}) { if (ext === '.json') { return ` let json = ${JSON.stringify(JSON.parse(code))}; @@ -91,7 +133,7 @@ export default json; ${ hasHmr ? ` -import * as __SNOWPACK_HMR_API__ from '/__snowpack__/hmr.js'; +import * as __SNOWPACK_HMR_API__ from '/${buildOptions.metadataDir}/hmr.js'; import.meta.hot = __SNOWPACK_HMR_API__.createHotContext(import.meta.url); import.meta.hot.accept(({module}) => { json = module.default; @@ -114,7 +156,7 @@ document.head.appendChild(styleEl); ${ hasHmr ? ` -import * as __SNOWPACK_HMR_API__ from '/__snowpack__/hmr.js'; +import * as __SNOWPACK_HMR_API__ from '/${buildOptions.metadataDir}/hmr.js'; import.meta.hot = __SNOWPACK_HMR_API__.createHotContext(import.meta.url); import.meta.hot.accept(); import.meta.hot.dispose(() => { diff --git a/src/commands/build.ts b/src/commands/build.ts index 42b4797786..68a7e86432 100644 --- a/src/commands/build.ts +++ b/src/commands/build.ts @@ -78,7 +78,7 @@ export async function command(commandOptions: CommandOptions) { } const buildDirectoryLoc = isBundled ? path.join(cwd, `.build`) : config.devOptions.out; - const internalFilesBuildLoc = path.join(buildDirectoryLoc, '__snowpack__'); + const internalFilesBuildLoc = path.join(buildDirectoryLoc, config.buildOptions.metadataDir); const finalDirectoryLoc = config.devOptions.out; if (config.scripts.length <= 1) { @@ -331,7 +331,7 @@ export async function command(commandOptions: CommandOptions) { }); return `/web_modules/${spec}.js`; }); - code = wrapImportMeta(code, {env: true, hmr: false}); + code = wrapImportMeta({code, env: true, hmr: false, buildOptions: config.buildOptions}); } await fs.mkdir(path.dirname(outPath), {recursive: true}); await fs.writeFile(outPath, code); @@ -347,7 +347,12 @@ export async function command(commandOptions: CommandOptions) { const proxiedCode = await fs.readFile(proxiedFileLoc, {encoding: 'utf8'}); const proxiedExt = path.extname(proxiedFileLoc); const proxiedUrl = proxiedFileLoc.substr(buildDirectoryLoc.length); - const proxyCode = await wrapCssModuleResponse(proxiedUrl, proxiedCode, proxiedExt); + const proxyCode = await wrapCssModuleResponse({ + url: proxiedUrl, + code: proxiedCode, + ext: proxiedExt, + buildOptions: config.buildOptions, + }); const proxyFileLoc = proxiedFileLoc.replace('.module.css', '.css.module.js'); await fs.writeFile(proxyFileLoc, proxyCode, {encoding: 'utf8'}); } @@ -355,7 +360,12 @@ export async function command(commandOptions: CommandOptions) { const proxiedCode = await fs.readFile(proxiedFileLoc, {encoding: 'utf8'}); const proxiedExt = path.extname(proxiedFileLoc); const proxiedUrl = proxiedFileLoc.substr(buildDirectoryLoc.length); - const proxyCode = wrapEsmProxyResponse(proxiedUrl, proxiedCode, proxiedExt); + const proxyCode = wrapEsmProxyResponse({ + url: proxiedUrl, + code: proxiedCode, + ext: proxiedExt, + buildOptions: config.buildOptions, + }); const proxyFileLoc = proxiedFileLoc + '.proxy.js'; await fs.writeFile(proxyFileLoc, proxyCode, {encoding: 'utf8'}); } diff --git a/src/commands/dev.ts b/src/commands/dev.ts index e1966a25b9..e657f5360b 100644 --- a/src/commands/dev.ts +++ b/src/commands/dev.ts @@ -492,11 +492,11 @@ export async function command(commandOptions: CommandOptions) { } }); - if (reqPath === '/__snowpack__/hmr.js') { + if (reqPath === `/${config.buildOptions.metadataDir}/hmr.js`) { sendFile(req, res, HMR_DEV_CODE, '.js'); return; } - if (reqPath === '/__snowpack__/env.js') { + if (reqPath === `/${config.buildOptions.metadataDir}/env.js`) { sendFile(req, res, generateEnvModule('development'), '.js'); return; } @@ -598,12 +598,13 @@ export async function command(commandOptions: CommandOptions) { if (virtualResourceResponse) { if (isProxyModule) { responseFileExt = '.js'; - virtualResourceResponse = wrapEsmProxyResponse( - reqPath, - virtualResourceResponse, - requestedFileExt, - true, - ); + virtualResourceResponse = wrapEsmProxyResponse({ + url: reqPath, + code: virtualResourceResponse, + ext: requestedFileExt, + hasHmr: true, + buildOptions: config.buildOptions, + }); } sendFile(req, res, virtualResourceResponse, responseFileExt); return; @@ -627,15 +628,27 @@ export async function command(commandOptions: CommandOptions) { async function wrapResponse(code: string, cssResource: string | undefined) { if (isRoute) { - code = wrapHtmlResponse(code, isHmr); + code = wrapHtmlResponse({code: code, hasHmr: isHmr, buildOptions: config.buildOptions}); } else if (isProxyModule) { responseFileExt = '.js'; - code = wrapEsmProxyResponse(reqPath, code, requestedFileExt, isHmr); + code = wrapEsmProxyResponse({ + url: reqPath, + code, + ext: requestedFileExt, + hasHmr: isHmr, + buildOptions: config.buildOptions, + }); } else if (isCssModule) { responseFileExt = '.js'; - code = await wrapCssModuleResponse(reqPath, code, requestedFileExt, isHmr); + code = await wrapCssModuleResponse({ + url: reqPath, + code, + ext: requestedFileExt, + hasHmr: isHmr, + buildOptions: config.buildOptions, + }); } else if (responseFileExt === '.js') { - code = wrapImportMeta(code, {env: true, hmr: isHmr}); + code = wrapImportMeta({code, env: true, hmr: isHmr, buildOptions: config.buildOptions}); } if (responseFileExt === '.js' && cssResource) { code = `import './${path.basename(reqPath).replace(/.js$/, '.css.proxy.js')}';\n` + code; diff --git a/src/config.ts b/src/config.ts index 2ffb2c27ad..0b63019ae3 100644 --- a/src/config.ts +++ b/src/config.ts @@ -113,6 +113,9 @@ export interface SnowpackConfig { dedupe?: string[]; }; }; + buildOptions: { + metadataDir: string; + }; proxy: Proxy[]; } @@ -150,6 +153,9 @@ const DEFAULT_CONFIG: Partial = { hmr: true, bundle: undefined, }, + buildOptions: { + metadataDir: '__snowpack__', + }, }; const configSchema = { @@ -213,6 +219,12 @@ const configSchema = { }, }, }, + buildOptions: { + type: ['object'], + properties: { + metadataDir: {type: 'string'}, + }, + }, proxy: { type: 'object', }, @@ -229,6 +241,7 @@ function expandCliFlags(flags: CLIFlags): DeepPartial { const result = { installOptions: {} as any, devOptions: {} as any, + buildOptions: {} as any, }; const {help, version, reload, config, ...relevantFlags} = flags; for (const [flag, val] of Object.entries(relevantFlags)) { @@ -448,6 +461,10 @@ function normalizeConfig(config: SnowpackConfig): SnowpackConfig { config.proxy = {} as any; } const allPlugins = {}; + // remove leading/trailing slashes + config.buildOptions.metadataDir = config.buildOptions.metadataDir + .replace(/^(\/|\\)/g, '') // replace leading slash + .replace(/(\/|\\)$/g, ''); // replace trailing slash config.plugins = (config.plugins as any).map((plugin: string | [string, any]) => { const configPluginPath = Array.isArray(plugin) ? plugin[0] : plugin; const configPluginOptions = (Array.isArray(plugin) && plugin[1]) || {}; diff --git a/test/build/metadata-dir/.gitignore b/test/build/metadata-dir/.gitignore new file mode 100644 index 0000000000..378eac25d3 --- /dev/null +++ b/test/build/metadata-dir/.gitignore @@ -0,0 +1 @@ +build diff --git a/test/build/metadata-dir/index.test.js b/test/build/metadata-dir/index.test.js new file mode 100644 index 0000000000..37df1e728a --- /dev/null +++ b/test/build/metadata-dir/index.test.js @@ -0,0 +1,9 @@ +const fs = require('fs'); +const path = require('path'); +const execa = require('execa'); + +it('buildOptions.metadataDir', () => { + execa('node', ['npm', 'run', 'TEST']); + // expect dir in package.json to exist + expect(fs.existsSync(path.resolve(__dirname, 'build', 'static', 'snowpack'))); +}); diff --git a/test/build/metadata-dir/node_modules/shallow-equal/LICENSE b/test/build/metadata-dir/node_modules/shallow-equal/LICENSE new file mode 100644 index 0000000000..f8d348670e --- /dev/null +++ b/test/build/metadata-dir/node_modules/shallow-equal/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright © 2016 Misha Moroshko + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the “Software”), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/test/build/metadata-dir/node_modules/shallow-equal/README.md b/test/build/metadata-dir/node_modules/shallow-equal/README.md new file mode 100644 index 0000000000..d394799505 --- /dev/null +++ b/test/build/metadata-dir/node_modules/shallow-equal/README.md @@ -0,0 +1,38 @@ +Build Status +NPM Version + +## Description + +If you know you have two arrays or two objects in hand, and you want to know if they are shallowly equal or not, this library is for you. + +## Features + +- Super light +- No dependencies +- Thoroughly tested + +## Installation + +```shell +npm install shallow-equal --save +``` + +## Usage + +```js +import { shallowEqualArrays } from "shallow-equal"; + +shallowEqualArrays([1, 2, 3], [1, 2, 3]); // => true +shallowEqualArrays([{ a: 5 }], [{ a: 5 }]); // => false +``` + +```js +import { shallowEqualObjects } from "shallow-equal"; + +shallowEqualObjects({ a: 5, b: "abc" }, { a: 5, b: "abc" }); // => true +shallowEqualObjects({ a: 5, b: {} }, { a: 5, b: {} }); // => false +``` + +## License + +MIT diff --git a/test/build/metadata-dir/node_modules/shallow-equal/arrays/index.js b/test/build/metadata-dir/node_modules/shallow-equal/arrays/index.js new file mode 100644 index 0000000000..89b4633c9f --- /dev/null +++ b/test/build/metadata-dir/node_modules/shallow-equal/arrays/index.js @@ -0,0 +1,27 @@ +'use strict'; + +function shallowEqualArrays(arrA, arrB) { + if (arrA === arrB) { + return true; + } + + if (!arrA || !arrB) { + return false; + } + + var len = arrA.length; + + if (arrB.length !== len) { + return false; + } + + for (var i = 0; i < len; i++) { + if (arrA[i] !== arrB[i]) { + return false; + } + } + + return true; +} + +module.exports = shallowEqualArrays; diff --git a/test/build/metadata-dir/node_modules/shallow-equal/dist/index.cjs.js b/test/build/metadata-dir/node_modules/shallow-equal/dist/index.cjs.js new file mode 100644 index 0000000000..b10f58ae9d --- /dev/null +++ b/test/build/metadata-dir/node_modules/shallow-equal/dist/index.cjs.js @@ -0,0 +1,58 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { value: true }); + +function shallowEqualObjects(objA, objB) { + if (objA === objB) { + return true; + } + + if (!objA || !objB) { + return false; + } + + var aKeys = Object.keys(objA); + var bKeys = Object.keys(objB); + var len = aKeys.length; + + if (bKeys.length !== len) { + return false; + } + + for (var i = 0; i < len; i++) { + var key = aKeys[i]; + + if (objA[key] !== objB[key] || !Object.prototype.hasOwnProperty.call(objB, key)) { + return false; + } + } + + return true; +} + +function shallowEqualArrays(arrA, arrB) { + if (arrA === arrB) { + return true; + } + + if (!arrA || !arrB) { + return false; + } + + var len = arrA.length; + + if (arrB.length !== len) { + return false; + } + + for (var i = 0; i < len; i++) { + if (arrA[i] !== arrB[i]) { + return false; + } + } + + return true; +} + +exports.shallowEqualArrays = shallowEqualArrays; +exports.shallowEqualObjects = shallowEqualObjects; diff --git a/test/build/metadata-dir/node_modules/shallow-equal/dist/index.esm.js b/test/build/metadata-dir/node_modules/shallow-equal/dist/index.esm.js new file mode 100644 index 0000000000..47c474a13c --- /dev/null +++ b/test/build/metadata-dir/node_modules/shallow-equal/dist/index.esm.js @@ -0,0 +1,53 @@ +function shallowEqualObjects(objA, objB) { + if (objA === objB) { + return true; + } + + if (!objA || !objB) { + return false; + } + + var aKeys = Object.keys(objA); + var bKeys = Object.keys(objB); + var len = aKeys.length; + + if (bKeys.length !== len) { + return false; + } + + for (var i = 0; i < len; i++) { + var key = aKeys[i]; + + if (objA[key] !== objB[key] || !Object.prototype.hasOwnProperty.call(objB, key)) { + return false; + } + } + + return true; +} + +function shallowEqualArrays(arrA, arrB) { + if (arrA === arrB) { + return true; + } + + if (!arrA || !arrB) { + return false; + } + + var len = arrA.length; + + if (arrB.length !== len) { + return false; + } + + for (var i = 0; i < len; i++) { + if (arrA[i] !== arrB[i]) { + return false; + } + } + + return true; +} + +export { shallowEqualArrays, shallowEqualObjects }; diff --git a/test/build/metadata-dir/node_modules/shallow-equal/objects/index.js b/test/build/metadata-dir/node_modules/shallow-equal/objects/index.js new file mode 100644 index 0000000000..5556ed3606 --- /dev/null +++ b/test/build/metadata-dir/node_modules/shallow-equal/objects/index.js @@ -0,0 +1,31 @@ +'use strict'; + +function shallowEqualObjects(objA, objB) { + if (objA === objB) { + return true; + } + + if (!objA || !objB) { + return false; + } + + var aKeys = Object.keys(objA); + var bKeys = Object.keys(objB); + var len = aKeys.length; + + if (bKeys.length !== len) { + return false; + } + + for (var i = 0; i < len; i++) { + var key = aKeys[i]; + + if (objA[key] !== objB[key] || !Object.prototype.hasOwnProperty.call(objB, key)) { + return false; + } + } + + return true; +} + +module.exports = shallowEqualObjects; diff --git a/test/build/metadata-dir/node_modules/shallow-equal/package.json b/test/build/metadata-dir/node_modules/shallow-equal/package.json new file mode 100644 index 0000000000..658ba2e8ee --- /dev/null +++ b/test/build/metadata-dir/node_modules/shallow-equal/package.json @@ -0,0 +1,110 @@ +{ + "_from": "shallow-equal", + "_id": "shallow-equal@1.2.1", + "_inBundle": false, + "_integrity": "sha512-S4vJDjHHMBaiZuT9NPb616CSmLf618jawtv3sufLl6ivK8WocjAo58cXwbRV1cgqxH0Qbv+iUt6m05eqEa2IRA==", + "_location": "/shallow-equal", + "_phantomChildren": {}, + "_requested": { + "type": "tag", + "registry": true, + "raw": "shallow-equal", + "name": "shallow-equal", + "escapedName": "shallow-equal", + "rawSpec": "", + "saveSpec": null, + "fetchSpec": "latest" + }, + "_requiredBy": [ + "#USER", + "/" + ], + "_resolved": "https://registry.npmjs.org/shallow-equal/-/shallow-equal-1.2.1.tgz", + "_shasum": "4c16abfa56043aa20d050324efa68940b0da79da", + "_spec": "shallow-equal", + "_where": "/Users/drew/Sites/pikapkg/snowpack/test/build/metadata-dir", + "author": { + "name": "Misha Moroshko", + "email": "michael.moroshko@gmail.com" + }, + "bugs": { + "url": "https://github.com/moroshko/shallow-equal/issues" + }, + "bundleDependencies": false, + "deprecated": false, + "description": "Minimalistic shallow equality check for arrays/objects", + "devDependencies": { + "chai": "^4.2.0", + "eslint": "^6.7.2", + "eslint-plugin-mocha": "^6.2.2", + "esm": "^3.2.25", + "mocha": "^6.2.2", + "nyc": "^14.1.1", + "rollup": "^1.27.8" + }, + "files": [ + "dist", + "arrays", + "objects" + ], + "homepage": "https://github.com/moroshko/shallow-equal#readme", + "keywords": [ + "shallow", + "equality", + "compare", + "comparison", + "shallowequal", + "shallow-equal", + "shallowequals", + "shallow-equals", + "isshallowequal", + "is-shallow-equal", + "equal", + "equals", + "isequal", + "is-equal", + "object", + "array", + "check", + "test" + ], + "license": "MIT", + "main": "dist/index.cjs.js", + "module": "dist/index.esm.js", + "name": "shallow-equal", + "nyc": { + "lines": 100, + "statements": 100, + "functions": 100, + "branches": 100, + "include": [ + "src/*.js" + ], + "exclude": [ + "src/*.test.js" + ], + "reporter": [ + "lcov", + "text-summary" + ], + "check-coverage": true + }, + "repository": { + "type": "git", + "url": "git+https://github.com/moroshko/shallow-equal.git" + }, + "scripts": { + "build": "npm run build:objects && npm run build:arrays && rm -rf dist && npm run build:cjs && npm run build:esm", + "build:arrays": "rm -rf arrays && rollup -f cjs -i src/arrays.js -o arrays/index.js", + "build:cjs": "rollup -f cjs -i src/index.js -o dist/index.cjs.js", + "build:esm": "rollup -f esm -i src/index.js -o dist/index.esm.js", + "build:objects": "rm -rf objects && rollup -f cjs -i src/objects.js -o objects/index.js", + "lint": "eslint src", + "postversion": "git push && git push --tags", + "prebuild": "npm run lint && npm test", + "prepare": "npm run build", + "preversion": "npm run prebuild", + "test": "nyc --require esm mocha 'src/*.test.js'" + }, + "version": "1.2.1" +} diff --git a/test/build/metadata-dir/package-lock.json b/test/build/metadata-dir/package-lock.json new file mode 100644 index 0000000000..6f1a0e941c --- /dev/null +++ b/test/build/metadata-dir/package-lock.json @@ -0,0 +1,11 @@ +{ + "requires": true, + "lockfileVersion": 1, + "dependencies": { + "shallow-equal": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/shallow-equal/-/shallow-equal-1.2.1.tgz", + "integrity": "sha512-S4vJDjHHMBaiZuT9NPb616CSmLf618jawtv3sufLl6ivK8WocjAo58cXwbRV1cgqxH0Qbv+iUt6m05eqEa2IRA==" + } + } +} diff --git a/test/build/metadata-dir/package.json b/test/build/metadata-dir/package.json new file mode 100644 index 0000000000..cb9a6dd570 --- /dev/null +++ b/test/build/metadata-dir/package.json @@ -0,0 +1,13 @@ +{ + "snowpack": { + "buildOptions": { + "metadataDir": "/static/snowpack" + } + }, + "scripts": { + "TEST": "../../../pkg/dist-node/index.bin.js build" + }, + "dependencies": { + "shallow-equal": "^1.2.1" + } +}