Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .parcelrc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"*.html": "parcel-packager-ssg"
},
"optimizers": {
"*.js": ["@parcel/optimizer-terser"]
"*.js": ["@parcel/optimizer-terser"],
"**/spectrum-theme.cjs": ["parcel-optimizer-strict-mode"]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The exact path of packages/@react-spectrum/s2/style/dist/spectrum-theme.cjsdoesn't work, but this works.

}
}
5 changes: 4 additions & 1 deletion .parcelrc-build
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,8 @@
"@parcel/transformer-react-refresh-wrap"
]
},
"namers": ["parcel-namer-s2", "parcel-namer-intl", "..."]
"namers": ["parcel-namer-s2", "parcel-namer-intl", "..."],
"optimizers": {
"**/spectrum-theme.cjs": ["parcel-optimizer-strict-mode"]
}
}
32 changes: 32 additions & 0 deletions packages/dev/parcel-optimizer-strict-mode/StrictModeOptimizer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright 2024 Adobe. All rights reserved.
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/

const {Optimizer} = require('@parcel/plugin');

export default new Optimizer({
async optimize({bundle, contents, map}) {
if (bundle.target.env.outputFormat !== 'commonjs') {
return {contents, map};
}

let newContents = `"use strict";\n${contents}`;

if (map) {
map.offsetLines(1, 1);
}

return {
contents: newContents,
map
};
}
});
12 changes: 12 additions & 0 deletions packages/dev/parcel-optimizer-strict-mode/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "parcel-optimizer-strict-mode",
"version": "1.0.0",
"private": true,
"main": "StrictModeOptimizer.ts",
"engines": {
"parcel": "2.0.0"
},
"dependencies": {
"@parcel/plugin": "2.0.0"
}
}
8 changes: 8 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -27202,6 +27202,14 @@ __metadata:
languageName: unknown
linkType: soft

"parcel-optimizer-strict-mode@workspace:packages/dev/parcel-optimizer-strict-mode":
version: 0.0.0-use.local
resolution: "parcel-optimizer-strict-mode@workspace:packages/dev/parcel-optimizer-strict-mode"
dependencies:
"@parcel/plugin": "npm:2.0.0"
languageName: unknown
linkType: soft

"parcel-packager-docs@workspace:packages/dev/parcel-packager-docs":
version: 0.0.0-use.local
resolution: "parcel-packager-docs@workspace:packages/dev/parcel-packager-docs"
Expand Down