未验证 提交 005a8abe 编写于 作者: G Guy Bedford 提交者: GitHub

feat: Webpack loader inlining (#21127)

This picks up on the inlining work in https://github.com/vercel/next.js/pull/20598 to also include webpack loader inlining optimizations.

This includes:
* The dependencies of sass-loader
* resolve-url-loader

And for added benefit:
* babel-plugin-transform-define
* babel-plugin-transform-react-remove-prop-types

style-loader and css-loader didn't inline easily. Perhaps we can come back to these ones.
上级 dc87a843
......@@ -198,7 +198,7 @@ module.exports = (
],
require('./plugins/amp-attributes'),
isProduction && [
require('babel-plugin-transform-react-remove-prop-types'),
require('next/dist/compiled/babel/plugin-transform-react-remove-prop-types'),
{
removeImport: true,
},
......
import loaderUtils from 'loader-utils'
import loaderUtils from 'next/dist/compiled/loader-utils'
import path from 'path'
import { webpack } from 'next/dist/compiled/webpack/webpack'
......
// import babel from 'next/dist/compiled/babel/core'
import loaderUtils from 'loader-utils'
import loaderUtils from 'next/dist/compiled/loader-utils'
import { tracer, traceAsyncFn, traceFn } from '../../../../tracer'
import cache from './cache'
import transform from './transform'
......
import loaderUtils from 'loader-utils'
import loaderUtils from 'next/dist/compiled/loader-utils'
module.exports = function (content, sourceMap) {
this.cacheable()
......
import chalk from 'chalk'
import loaderUtils from 'loader-utils'
import loaderUtils from 'next/dist/compiled/loader-utils'
import path from 'path'
import { webpack } from 'next/dist/compiled/webpack/webpack'
......
......@@ -155,7 +155,7 @@ const customBabelLoader = babelLoader((babel) => {
}
options.plugins.push([
require.resolve('babel-plugin-transform-define'),
require.resolve('next/dist/compiled/babel/plugin-transform-define'),
{
'process.env.NODE_ENV': development ? 'development' : 'production',
'typeof window': isServer ? 'undefined' : 'object',
......
import loaderUtils from 'loader-utils'
import loaderUtils from 'next/dist/compiled/loader-utils'
import { tracer, traceFn } from '../../tracer'
export type ClientPagesLoaderOptions = {
......
import NativeModule from 'module'
import loaderUtils from 'loader-utils'
import loaderUtils from 'next/dist/compiled/loader-utils'
import {
webpack,
isWebpack5,
......
......@@ -36,10 +36,18 @@ function pluginSyntaxJsx() {
return require('@babel/plugin-syntax-jsx')
}
function pluginTransformDefine() {
return require('babel-plugin-transform-define')
}
function pluginTransformModulesCommonjs() {
return require('@babel/plugin-transform-modules-commonjs')
}
function pluginTransformReactRemovePropTypes() {
return require('babel-plugin-transform-react-remove-prop-types')
}
function pluginTransformRuntime() {
return require('@babel/plugin-transform-runtime')
}
......@@ -66,7 +74,9 @@ module.exports = {
pluginSyntaxBigint,
pluginSyntaxDynamicImport,
pluginSyntaxJsx,
pluginTransformDefine,
pluginTransformModulesCommonjs,
pluginTransformReactRemovePropTypes,
pluginTransformRuntime,
presetEnv,
presetReact,
......
module.exports = require('./bundle').pluginTransformDefine()
module.exports = require('./bundle').pluginTransformReactRemovePropTypes()
module.exports = require('./bundle').pluginTransformDefine()
module.exports = require('./bundle').pluginTransformReactRemovePropTypes()
module.exports=(()=>{var e={819:e=>{"use strict";e.exports=JSON.parse('{"type":"object","properties":{"cacheContext":{"description":"The default cache context in order to generate the cache relatively to a path. By default it will use absolute paths.","type":"string"},"cacheKey":{"description":"Allows you to override default cache key generator.","instanceof":"Function"},"cacheIdentifier":{"description":"Provide a cache directory where cache items should be stored (used for default read/write implementation).","type":"string"},"cacheDirectory":{"description":"Provide an invalidation identifier which is used to generate the hashes. You can use it for extra dependencies of loaders (used for default read/write implementation).","type":"string"},"compare":{"description":"Allows you to override default comparison function between the cached dependency and the one is being read. Return true to use the cached resource.","instanceof":"Function"},"precision":{"description":"Round mtime by this number of milliseconds both for stats and deps before passing those params to the comparing function.","type":"number"},"read":{"description":"Allows you to override default read cache data from file.","instanceof":"Function"},"readOnly":{"description":"Allows you to override default value and make the cache read only (useful for some environments where you don\'t want the cache to be updated, only read from it).","type":"boolean"},"write":{"description":"Allows you to override default write cache data to file (e.g. Redis, memcached).","instanceof":"Function"}},"additionalProperties":false}')},612:e=>{"use strict";e.exports=JSON.parse('{"name":"cache-loader","version":"4.1.0","description":"Caches the result of following loaders on disk.","license":"MIT","repository":"webpack-contrib/cache-loader","author":"Tobias Koppers @sokra","homepage":"https://github.com/webpack-contrib/cache-loader","bugs":"https://github.com/webpack-contrib/cache-loader/issues","main":"dist/cjs.js","engines":{"node":">= 8.9.0"},"scripts":{"start":"npm run build -- -w","prebuild":"npm run clean","build":"cross-env NODE_ENV=production babel src -d dist --ignore \\"src/**/*.test.js\\" --copy-files","clean":"del-cli dist","commitlint":"commitlint --from=master","lint:prettier":"prettier \\"{**/*,*}.{js,json,md,yml,css}\\" --list-different","lint:js":"eslint --cache src test","lint":"npm-run-all -l -p \\"lint:**\\"","prepare":"npm run build","release":"standard-version","security":"npm audit","test:only":"cross-env NODE_ENV=test jest","test:watch":"cross-env NODE_ENV=test jest --watch","test:coverage":"cross-env NODE_ENV=test jest --collectCoverageFrom=\\"src/**/*.js\\" --coverage","pretest":"npm run lint","test":"cross-env NODE_ENV=test npm run test:coverage","defaults":"webpack-defaults"},"files":["dist"],"peerDependencies":{"webpack":"^4.0.0"},"dependencies":{"buffer-json":"^2.0.0","find-cache-dir":"^3.0.0","loader-utils":"^1.2.3","mkdirp":"^0.5.1","neo-async":"^2.6.1","schema-utils":"^2.0.0"},"devDependencies":{"@babel/cli":"^7.5.5","@babel/core":"^7.5.5","@babel/preset-env":"^7.5.5","@commitlint/cli":"^8.1.0","@commitlint/config-conventional":"^8.1.0","@webpack-contrib/defaults":"^5.0.2","@webpack-contrib/eslint-config-webpack":"^3.0.0","babel-jest":"^24.8.0","babel-loader":"^8.0.6","commitlint-azure-pipelines-cli":"^1.0.2","cross-env":"^5.2.0","del":"^5.0.0","del-cli":"^2.0.0","eslint":"^6.0.1","eslint-config-prettier":"^6.0.0","eslint-plugin-import":"^2.18.0","file-loader":"^4.1.0","husky":"^3.0.0","jest":"^24.8.0","jest-junit":"^6.4.0","lint-staged":"^9.2.0","memory-fs":"^0.4.1","normalize-path":"^3.0.0","npm-run-all":"^4.1.5","prettier":"^1.18.2","standard-version":"^6.0.1","uuid":"^3.3.2","webpack":"^4.36.1","webpack-cli":"^3.3.6"},"keywords":["webpack"]}')},456:e=>{function stringify(e,t){return JSON.stringify(e,replacer,t)}function parse(e){return JSON.parse(e,reviver)}function replacer(e,t){if(isBufferLike(t)){if(isArray(t.data)){if(t.data.length>0){t.data="base64:"+Buffer.from(t.data).toString("base64")}else{t.data=""}}}return t}function reviver(e,t){if(isBufferLike(t)){if(isArray(t.data)){return Buffer.from(t.data)}else if(isString(t.data)){if(t.data.startsWith("base64:")){return Buffer.from(t.data.slice("base64:".length),"base64")}return Buffer.from(t.data)}}return t}function isBufferLike(e){return isObject(e)&&e.type==="Buffer"&&(isArray(e.data)||isString(e.data))}function isArray(e){return Array.isArray(e)}function isString(e){return typeof e==="string"}function isObject(e){return typeof e==="object"&&e!==null}e.exports={stringify:stringify,parse:parse,replacer:replacer,reviver:reviver}},296:(e,t,r)=>{"use strict";e.exports=r(582)},582:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});t.default=loader;t.pitch=pitch;t.raw=void 0;const i=r(747);const n=r(87);const s=r(622);const a=r(386);const c=r(417);const o=r(327);const d=r(844);const u=r(456);const{getOptions:l}=r(710);const p=r(225);const h=r(612);const f=process.env.NODE_ENV||"development";const m=r(819);const b={cacheContext:"",cacheDirectory:d({name:"cache-loader"})||n.tmpdir(),cacheIdentifier:`cache-loader:${h.version} ${f}`,cacheKey:cacheKey,compare:compare,precision:0,read:read,readOnly:false,write:write};function pathWithCacheContext(e,t){if(!e){return t}if(t.includes(e)){return t.split("!").map(t=>s.relative(e,t)).join("!")}return t.split("!").map(t=>s.resolve(e,t)).join("!")}function roundMs(e,t){return Math.floor(e/t)*t}function loader(...e){const t=Object.assign({},b,l(this));p(m,t,{name:"Cache Loader",baseDataPath:"options"});const{readOnly:r,write:n}=t;if(r){this.callback(null,...e);return}const s=this.async();const{data:c}=this;const o=this.getDependencies().concat(this.loaders.map(e=>e.path));const d=this.getContextDependencies();let u=true;const h=this.fs||i;const f=(e,r)=>{h.stat(e,(i,n)=>{if(i){r(i);return}const s=n.mtime.getTime();if(s/1e3>=Math.floor(c.startTime/1e3)){u=false}r(null,{path:pathWithCacheContext(t.cacheContext,e),mtime:s})})};a.parallel([e=>a.mapLimit(o,20,f,e),e=>a.mapLimit(d,20,f,e)],(r,i)=>{if(r){s(null,...e);return}if(!u){s(null,...e);return}const[a,o]=i;n(c.cacheKey,{remainingRequest:pathWithCacheContext(t.cacheContext,c.remainingRequest),dependencies:a,contextDependencies:o,result:e},()=>{s(null,...e)})})}function pitch(e,t,r){const n=Object.assign({},b,l(this));p(m,n,{name:"Cache Loader (Pitch)",baseDataPath:"options"});const{cacheContext:s,cacheKey:c,compare:o,read:d,readOnly:u,precision:h}=n;const f=this.async();const y=r;y.remainingRequest=e;y.cacheKey=c(n,y.remainingRequest);d(y.cacheKey,(e,t)=>{if(e){f();return}if(pathWithCacheContext(n.cacheContext,t.remainingRequest)!==y.remainingRequest){f();return}const r=this.fs||i;a.each(t.dependencies.concat(t.contextDependencies),(e,t)=>{const i={...e,path:pathWithCacheContext(n.cacheContext,e.path)};r.stat(i.path,(r,n)=>{if(r){t(r);return}if(u){t();return}const s=n;const a=i;if(h>1){["atime","mtime","ctime","birthtime"].forEach(e=>{const t=`${e}Ms`;const r=roundMs(n[t],h);s[t]=r;s[e]=new Date(r)});a.mtime=roundMs(e.mtime,h)}if(o(s,a)!==true){t(true);return}t()})},e=>{if(e){y.startTime=Date.now();f();return}t.dependencies.forEach(e=>this.addDependency(pathWithCacheContext(s,e.path)));t.contextDependencies.forEach(e=>this.addContextDependency(pathWithCacheContext(s,e.path)));f(null,...t.result)})})}function digest(e){return c.createHash("md5").update(e).digest("hex")}const y=new Set;function write(e,t,r){const n=s.dirname(e);const a=u.stringify(t);if(y.has(n)){i.writeFile(e,a,"utf-8",r)}else{o(n,t=>{if(t){r(t);return}y.add(n);i.writeFile(e,a,"utf-8",r)})}}function read(e,t){i.readFile(e,"utf-8",(e,r)=>{if(e){t(e);return}try{const e=u.parse(r);t(null,e)}catch(e){t(e)}})}function cacheKey(e,t){const{cacheIdentifier:r,cacheDirectory:i}=e;const n=digest(`${r}\n${t}`);return s.join(i,`${n}.json`)}function compare(e,t){return e.mtime.getTime()===t.mtime}const g=true;t.raw=g},417:e=>{"use strict";e.exports=require("crypto")},747:e=>{"use strict";e.exports=require("fs")},710:e=>{"use strict";e.exports=require("loader-utils")},844:e=>{"use strict";e.exports=require("next/dist/compiled/find-cache-dir")},327:e=>{"use strict";e.exports=require("next/dist/compiled/mkdirp")},386:e=>{"use strict";e.exports=require("next/dist/compiled/neo-async")},225:e=>{"use strict";e.exports=require("next/dist/compiled/schema-utils")},87:e=>{"use strict";e.exports=require("os")},622:e=>{"use strict";e.exports=require("path")}};var t={};function __nccwpck_require__(r){if(t[r]){return t[r].exports}var i=t[r]={exports:{}};var n=true;try{e[r](i,i.exports,__nccwpck_require__);n=false}finally{if(n)delete t[r]}return i.exports}__nccwpck_require__.ab=__dirname+"/";return __nccwpck_require__(296)})();
\ No newline at end of file
module.exports=(()=>{var e={819:e=>{"use strict";e.exports=JSON.parse('{"type":"object","properties":{"cacheContext":{"description":"The default cache context in order to generate the cache relatively to a path. By default it will use absolute paths.","type":"string"},"cacheKey":{"description":"Allows you to override default cache key generator.","instanceof":"Function"},"cacheIdentifier":{"description":"Provide a cache directory where cache items should be stored (used for default read/write implementation).","type":"string"},"cacheDirectory":{"description":"Provide an invalidation identifier which is used to generate the hashes. You can use it for extra dependencies of loaders (used for default read/write implementation).","type":"string"},"compare":{"description":"Allows you to override default comparison function between the cached dependency and the one is being read. Return true to use the cached resource.","instanceof":"Function"},"precision":{"description":"Round mtime by this number of milliseconds both for stats and deps before passing those params to the comparing function.","type":"number"},"read":{"description":"Allows you to override default read cache data from file.","instanceof":"Function"},"readOnly":{"description":"Allows you to override default value and make the cache read only (useful for some environments where you don\'t want the cache to be updated, only read from it).","type":"boolean"},"write":{"description":"Allows you to override default write cache data to file (e.g. Redis, memcached).","instanceof":"Function"}},"additionalProperties":false}')},612:e=>{"use strict";e.exports=JSON.parse('{"name":"cache-loader","version":"4.1.0","description":"Caches the result of following loaders on disk.","license":"MIT","repository":"webpack-contrib/cache-loader","author":"Tobias Koppers @sokra","homepage":"https://github.com/webpack-contrib/cache-loader","bugs":"https://github.com/webpack-contrib/cache-loader/issues","main":"dist/cjs.js","engines":{"node":">= 8.9.0"},"scripts":{"start":"npm run build -- -w","prebuild":"npm run clean","build":"cross-env NODE_ENV=production babel src -d dist --ignore \\"src/**/*.test.js\\" --copy-files","clean":"del-cli dist","commitlint":"commitlint --from=master","lint:prettier":"prettier \\"{**/*,*}.{js,json,md,yml,css}\\" --list-different","lint:js":"eslint --cache src test","lint":"npm-run-all -l -p \\"lint:**\\"","prepare":"npm run build","release":"standard-version","security":"npm audit","test:only":"cross-env NODE_ENV=test jest","test:watch":"cross-env NODE_ENV=test jest --watch","test:coverage":"cross-env NODE_ENV=test jest --collectCoverageFrom=\\"src/**/*.js\\" --coverage","pretest":"npm run lint","test":"cross-env NODE_ENV=test npm run test:coverage","defaults":"webpack-defaults"},"files":["dist"],"peerDependencies":{"webpack":"^4.0.0"},"dependencies":{"buffer-json":"^2.0.0","find-cache-dir":"^3.0.0","loader-utils":"^1.2.3","mkdirp":"^0.5.1","neo-async":"^2.6.1","schema-utils":"^2.0.0"},"devDependencies":{"@babel/cli":"^7.5.5","@babel/core":"^7.5.5","@babel/preset-env":"^7.5.5","@commitlint/cli":"^8.1.0","@commitlint/config-conventional":"^8.1.0","@webpack-contrib/defaults":"^5.0.2","@webpack-contrib/eslint-config-webpack":"^3.0.0","babel-jest":"^24.8.0","babel-loader":"^8.0.6","commitlint-azure-pipelines-cli":"^1.0.2","cross-env":"^5.2.0","del":"^5.0.0","del-cli":"^2.0.0","eslint":"^6.0.1","eslint-config-prettier":"^6.0.0","eslint-plugin-import":"^2.18.0","file-loader":"^4.1.0","husky":"^3.0.0","jest":"^24.8.0","jest-junit":"^6.4.0","lint-staged":"^9.2.0","memory-fs":"^0.4.1","normalize-path":"^3.0.0","npm-run-all":"^4.1.5","prettier":"^1.18.2","standard-version":"^6.0.1","uuid":"^3.3.2","webpack":"^4.36.1","webpack-cli":"^3.3.6"},"keywords":["webpack"]}')},456:e=>{function stringify(e,t){return JSON.stringify(e,replacer,t)}function parse(e){return JSON.parse(e,reviver)}function replacer(e,t){if(isBufferLike(t)){if(isArray(t.data)){if(t.data.length>0){t.data="base64:"+Buffer.from(t.data).toString("base64")}else{t.data=""}}}return t}function reviver(e,t){if(isBufferLike(t)){if(isArray(t.data)){return Buffer.from(t.data)}else if(isString(t.data)){if(t.data.startsWith("base64:")){return Buffer.from(t.data.slice("base64:".length),"base64")}return Buffer.from(t.data)}}return t}function isBufferLike(e){return isObject(e)&&e.type==="Buffer"&&(isArray(e.data)||isString(e.data))}function isArray(e){return Array.isArray(e)}function isString(e){return typeof e==="string"}function isObject(e){return typeof e==="object"&&e!==null}e.exports={stringify:stringify,parse:parse,replacer:replacer,reviver:reviver}},296:(e,t,r)=>{"use strict";e.exports=r(582)},582:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});t.default=loader;t.pitch=pitch;t.raw=void 0;const i=r(747);const n=r(87);const s=r(622);const c=r(386);const a=r(417);const o=r(327);const d=r(844);const u=r(456);const{getOptions:l}=r(443);const p=r(225);const h=r(612);const f=process.env.NODE_ENV||"development";const m=r(819);const b={cacheContext:"",cacheDirectory:d({name:"cache-loader"})||n.tmpdir(),cacheIdentifier:`cache-loader:${h.version} ${f}`,cacheKey:cacheKey,compare:compare,precision:0,read:read,readOnly:false,write:write};function pathWithCacheContext(e,t){if(!e){return t}if(t.includes(e)){return t.split("!").map(t=>s.relative(e,t)).join("!")}return t.split("!").map(t=>s.resolve(e,t)).join("!")}function roundMs(e,t){return Math.floor(e/t)*t}function loader(...e){const t=Object.assign({},b,l(this));p(m,t,{name:"Cache Loader",baseDataPath:"options"});const{readOnly:r,write:n}=t;if(r){this.callback(null,...e);return}const s=this.async();const{data:a}=this;const o=this.getDependencies().concat(this.loaders.map(e=>e.path));const d=this.getContextDependencies();let u=true;const h=this.fs||i;const f=(e,r)=>{h.stat(e,(i,n)=>{if(i){r(i);return}const s=n.mtime.getTime();if(s/1e3>=Math.floor(a.startTime/1e3)){u=false}r(null,{path:pathWithCacheContext(t.cacheContext,e),mtime:s})})};c.parallel([e=>c.mapLimit(o,20,f,e),e=>c.mapLimit(d,20,f,e)],(r,i)=>{if(r){s(null,...e);return}if(!u){s(null,...e);return}const[c,o]=i;n(a.cacheKey,{remainingRequest:pathWithCacheContext(t.cacheContext,a.remainingRequest),dependencies:c,contextDependencies:o,result:e},()=>{s(null,...e)})})}function pitch(e,t,r){const n=Object.assign({},b,l(this));p(m,n,{name:"Cache Loader (Pitch)",baseDataPath:"options"});const{cacheContext:s,cacheKey:a,compare:o,read:d,readOnly:u,precision:h}=n;const f=this.async();const y=r;y.remainingRequest=e;y.cacheKey=a(n,y.remainingRequest);d(y.cacheKey,(e,t)=>{if(e){f();return}if(pathWithCacheContext(n.cacheContext,t.remainingRequest)!==y.remainingRequest){f();return}const r=this.fs||i;c.each(t.dependencies.concat(t.contextDependencies),(e,t)=>{const i={...e,path:pathWithCacheContext(n.cacheContext,e.path)};r.stat(i.path,(r,n)=>{if(r){t(r);return}if(u){t();return}const s=n;const c=i;if(h>1){["atime","mtime","ctime","birthtime"].forEach(e=>{const t=`${e}Ms`;const r=roundMs(n[t],h);s[t]=r;s[e]=new Date(r)});c.mtime=roundMs(e.mtime,h)}if(o(s,c)!==true){t(true);return}t()})},e=>{if(e){y.startTime=Date.now();f();return}t.dependencies.forEach(e=>this.addDependency(pathWithCacheContext(s,e.path)));t.contextDependencies.forEach(e=>this.addContextDependency(pathWithCacheContext(s,e.path)));f(null,...t.result)})})}function digest(e){return a.createHash("md5").update(e).digest("hex")}const y=new Set;function write(e,t,r){const n=s.dirname(e);const c=u.stringify(t);if(y.has(n)){i.writeFile(e,c,"utf-8",r)}else{o(n,t=>{if(t){r(t);return}y.add(n);i.writeFile(e,c,"utf-8",r)})}}function read(e,t){i.readFile(e,"utf-8",(e,r)=>{if(e){t(e);return}try{const e=u.parse(r);t(null,e)}catch(e){t(e)}})}function cacheKey(e,t){const{cacheIdentifier:r,cacheDirectory:i}=e;const n=digest(`${r}\n${t}`);return s.join(i,`${n}.json`)}function compare(e,t){return e.mtime.getTime()===t.mtime}const g=true;t.raw=g},417:e=>{"use strict";e.exports=require("crypto")},747:e=>{"use strict";e.exports=require("fs")},844:e=>{"use strict";e.exports=require("next/dist/compiled/find-cache-dir")},443:e=>{"use strict";e.exports=require("next/dist/compiled/loader-utils")},327:e=>{"use strict";e.exports=require("next/dist/compiled/mkdirp")},386:e=>{"use strict";e.exports=require("next/dist/compiled/neo-async")},225:e=>{"use strict";e.exports=require("next/dist/compiled/schema-utils")},87:e=>{"use strict";e.exports=require("os")},622:e=>{"use strict";e.exports=require("path")}};var t={};function __nccwpck_require__(r){if(t[r]){return t[r].exports}var i=t[r]={exports:{}};var n=true;try{e[r](i,i.exports,__nccwpck_require__);n=false}finally{if(n)delete t[r]}return i.exports}__nccwpck_require__.ab=__dirname+"/";return __nccwpck_require__(296)})();
\ No newline at end of file
module.exports=(()=>{"use strict";var e={764:e=>{e.exports=JSON.parse('{"additionalProperties":true,"properties":{"name":{"description":"The filename template for the target file(s) (https://github.com/webpack-contrib/file-loader#name).","anyOf":[{"type":"string"},{"instanceof":"Function"}]},"outputPath":{"description":"A filesystem path where the target file(s) will be placed (https://github.com/webpack-contrib/file-loader#outputpath).","anyOf":[{"type":"string"},{"instanceof":"Function"}]},"publicPath":{"description":"A custom public path for the target file(s) (https://github.com/webpack-contrib/file-loader#publicpath).","anyOf":[{"type":"string"},{"instanceof":"Function"}]},"postTransformPublicPath":{"description":"A custom transformation function for post-processing the publicPath (https://github.com/webpack-contrib/file-loader#posttransformpublicpath).","instanceof":"Function"},"context":{"description":"A custom file context (https://github.com/webpack-contrib/file-loader#context).","type":"string"},"emitFile":{"description":"Enables/Disables emit files (https://github.com/webpack-contrib/file-loader#emitfile).","type":"boolean"},"regExp":{"description":"A Regular Expression to one or many parts of the target file path. The capture groups can be reused in the name property using [N] placeholder (https://github.com/webpack-contrib/file-loader#regexp).","anyOf":[{"type":"string"},{"instanceof":"RegExp"}]},"esModule":{"description":"By default, file-loader generates JS modules that use the ES modules syntax.","type":"boolean"}},"type":"object"}')},467:(e,t,i)=>{const r=i(206);e.exports=r.default;e.exports.raw=r.raw},206:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:true});t.default=loader;t.raw=void 0;var r=_interopRequireDefault(i(622));var o=_interopRequireDefault(i(710));var a=_interopRequireDefault(i(225));var n=_interopRequireDefault(i(764));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function loader(e){const t=o.default.getOptions(this);(0,a.default)(n.default,t,{name:"File Loader",baseDataPath:"options"});const i=t.context||this.rootContext;const s=o.default.interpolateName(this,t.name||"[contenthash].[ext]",{context:i,content:e,regExp:t.regExp});let p=s;if(t.outputPath){if(typeof t.outputPath==="function"){p=t.outputPath(s,this.resourcePath,i)}else{p=r.default.posix.join(t.outputPath,s)}}let u=`__webpack_public_path__ + ${JSON.stringify(p)}`;if(t.publicPath){if(typeof t.publicPath==="function"){u=t.publicPath(s,this.resourcePath,i)}else{u=`${t.publicPath.endsWith("/")?t.publicPath:`${t.publicPath}/`}${s}`}u=JSON.stringify(u)}if(t.postTransformPublicPath){u=t.postTransformPublicPath(u)}if(typeof t.emitFile==="undefined"||t.emitFile){this.emitFile(p,e)}const l=typeof t.esModule!=="undefined"?t.esModule:true;return`${l?"export default":"module.exports ="} ${u};`}const s=true;t.raw=s},710:e=>{e.exports=require("loader-utils")},225:e=>{e.exports=require("next/dist/compiled/schema-utils")},622:e=>{e.exports=require("path")}};var t={};function __nccwpck_require__(i){if(t[i]){return t[i].exports}var r=t[i]={exports:{}};var o=true;try{e[i](r,r.exports,__nccwpck_require__);o=false}finally{if(o)delete t[i]}return r.exports}__nccwpck_require__.ab=__dirname+"/";return __nccwpck_require__(467)})();
\ No newline at end of file
module.exports=(()=>{"use strict";var e={764:e=>{e.exports=JSON.parse('{"additionalProperties":true,"properties":{"name":{"description":"The filename template for the target file(s) (https://github.com/webpack-contrib/file-loader#name).","anyOf":[{"type":"string"},{"instanceof":"Function"}]},"outputPath":{"description":"A filesystem path where the target file(s) will be placed (https://github.com/webpack-contrib/file-loader#outputpath).","anyOf":[{"type":"string"},{"instanceof":"Function"}]},"publicPath":{"description":"A custom public path for the target file(s) (https://github.com/webpack-contrib/file-loader#publicpath).","anyOf":[{"type":"string"},{"instanceof":"Function"}]},"postTransformPublicPath":{"description":"A custom transformation function for post-processing the publicPath (https://github.com/webpack-contrib/file-loader#posttransformpublicpath).","instanceof":"Function"},"context":{"description":"A custom file context (https://github.com/webpack-contrib/file-loader#context).","type":"string"},"emitFile":{"description":"Enables/Disables emit files (https://github.com/webpack-contrib/file-loader#emitfile).","type":"boolean"},"regExp":{"description":"A Regular Expression to one or many parts of the target file path. The capture groups can be reused in the name property using [N] placeholder (https://github.com/webpack-contrib/file-loader#regexp).","anyOf":[{"type":"string"},{"instanceof":"RegExp"}]},"esModule":{"description":"By default, file-loader generates JS modules that use the ES modules syntax.","type":"boolean"}},"type":"object"}')},467:(e,t,i)=>{const r=i(206);e.exports=r.default;e.exports.raw=r.raw},206:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:true});t.default=loader;t.raw=void 0;var r=_interopRequireDefault(i(622));var o=_interopRequireDefault(i(443));var a=_interopRequireDefault(i(225));var n=_interopRequireDefault(i(764));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function loader(e){const t=o.default.getOptions(this);(0,a.default)(n.default,t,{name:"File Loader",baseDataPath:"options"});const i=t.context||this.rootContext;const s=o.default.interpolateName(this,t.name||"[contenthash].[ext]",{context:i,content:e,regExp:t.regExp});let p=s;if(t.outputPath){if(typeof t.outputPath==="function"){p=t.outputPath(s,this.resourcePath,i)}else{p=r.default.posix.join(t.outputPath,s)}}let u=`__webpack_public_path__ + ${JSON.stringify(p)}`;if(t.publicPath){if(typeof t.publicPath==="function"){u=t.publicPath(s,this.resourcePath,i)}else{u=`${t.publicPath.endsWith("/")?t.publicPath:`${t.publicPath}/`}${s}`}u=JSON.stringify(u)}if(t.postTransformPublicPath){u=t.postTransformPublicPath(u)}if(typeof t.emitFile==="undefined"||t.emitFile){this.emitFile(p,e)}const l=typeof t.esModule!=="undefined"?t.esModule:true;return`${l?"export default":"module.exports ="} ${u};`}const s=true;t.raw=s},443:e=>{e.exports=require("next/dist/compiled/loader-utils")},225:e=>{e.exports=require("next/dist/compiled/schema-utils")},622:e=>{e.exports=require("path")}};var t={};function __nccwpck_require__(i){if(t[i]){return t[i].exports}var r=t[i]={exports:{}};var o=true;try{e[i](r,r.exports,__nccwpck_require__);o=false}finally{if(o)delete t[i]}return r.exports}__nccwpck_require__.ab=__dirname+"/";return __nccwpck_require__(467)})();
\ No newline at end of file
Copyright JS Foundation and other contributors
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.
此差异已折叠。
{"name":"loader-utils","main":"index.js","author":"Tobias Koppers @sokra","license":"MIT"}
因为 它太大了无法显示 source diff 。你可以改为 查看blob
......@@ -69,8 +69,6 @@
"@next/react-refresh-utils": "10.0.6-canary.1",
"@opentelemetry/api": "0.14.0",
"ast-types": "0.13.2",
"babel-plugin-transform-define": "2.0.0",
"babel-plugin-transform-react-remove-prop-types": "0.4.24",
"browserslist": "4.14.6",
"buffer": "5.6.0",
"caniuse-lite": "^1.0.30001113",
......@@ -82,8 +80,6 @@
"etag": "1.8.1",
"find-cache-dir": "3.3.1",
"jest-worker": "24.9.0",
"klona": "^2.0.4",
"loader-utils": "2.0.0",
"native-url": "0.3.4",
"node-fetch": "2.6.1",
"node-html-parser": "1.4.9",
......@@ -183,6 +179,8 @@
"async-retry": "1.2.3",
"async-sema": "3.0.0",
"babel-plugin-dynamic-import-node": "2.3.3",
"babel-plugin-transform-define": "2.0.0",
"babel-plugin-transform-react-remove-prop-types": "0.4.24",
"cacache": "15.0.5",
"cache-loader": "4.1.0",
"ci-info": "watson/ci-info#f43f6a1cefff47fb361c88cf4b943fdbcaafe540",
......@@ -205,6 +203,7 @@
"is-wsl": "2.2.0",
"json5": "2.1.3",
"jsonwebtoken": "8.5.1",
"loader-utils": "2.0.0",
"lodash.curry": "4.1.1",
"lru-cache": "5.1.1",
"mkdirp": "0.5.3",
......
......@@ -39,22 +39,18 @@ const externals = {
chalk: 'chalk',
'node-fetch': 'node-fetch',
// postcss: 'postcss',
// webpack
'node-libs-browser': 'node-libs-browser',
// css-loader
// postcss: 'postcss',
// sass-loader
// (also responsible for these dependencies in package.json)
'node-sass': 'node-sass',
sass: 'sass',
fibers: 'fibers',
klona: 'klona',
chokidar: 'chokidar',
'loader-utils': 'loader-utils',
'jest-worker': 'jest-worker',
}
// eslint-disable-next-line camelcase
......@@ -329,6 +325,14 @@ export async function ncc_jsonwebtoken(task, opts) {
.target('compiled/jsonwebtoken')
}
// eslint-disable-next-line camelcase
externals['loader-utils'] = 'next/dist/compiled/loader-utils'
export async function ncc_loader_utils(task, opts) {
await task
.source(opts.src || relative(__dirname, require.resolve('loader-utils')))
.ncc({ packageName: 'loader-utils', externals })
.target('compiled/loader-utils')
}
// eslint-disable-next-line camelcase
externals['lodash.curry'] = 'next/dist/compiled/lodash.curry'
export async function ncc_lodash_curry(task, opts) {
await task
......@@ -444,6 +448,7 @@ export async function ncc_sass_loader(task, opts) {
...externals,
'schema-utils': 'next/dist/compiled/schema-utils3',
},
target: 'es5',
})
.target('compiled/sass-loader')
}
......@@ -669,6 +674,7 @@ export async function ncc(task) {
'ncc_is_wsl',
'ncc_json5',
'ncc_jsonwebtoken',
'ncc_loader_utils',
'ncc_lodash_curry',
'ncc_lru_cache',
'ncc_mkdirp',
......
......@@ -24,7 +24,7 @@
/// <reference types="node" />
declare module 'mini-css-extract-plugin'
declare module 'loader-utils'
declare module 'next/dist/compiled/loader-utils'
declare module 'next/dist/compiled/webpack/webpack' {
import webpackSources from 'webpack-sources'
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册