@lwc/babel-plugin-component 2.33.0 → 2.35.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "bugs": {
11
11
  "url": "https://github.com/salesforce/lwc/issues"
12
12
  },
13
- "version": "2.33.0",
13
+ "version": "2.35.0",
14
14
  "main": "src/index.js",
15
15
  "typings": "src/index.d.ts",
16
16
  "license": "MIT",
@@ -21,8 +21,8 @@
21
21
  ],
22
22
  "dependencies": {
23
23
  "@babel/helper-module-imports": "~7.18.6",
24
- "@lwc/errors": "2.33.0",
25
- "@lwc/shared": "2.33.0",
24
+ "@lwc/errors": "2.35.0",
25
+ "@lwc/shared": "2.35.0",
26
26
  "line-column": "~1.0.2"
27
27
  },
28
28
  "peerDependencies": {
package/src/index.js CHANGED
@@ -12,6 +12,7 @@ const {
12
12
  } = require('./decorators');
13
13
  const dedupeImports = require('./dedupe-imports');
14
14
  const dynamicImports = require('./dynamic-imports');
15
+ const scopeCssImports = require('./scope-css-imports');
15
16
  const compilerVersionNumber = require('./compiler-version-number');
16
17
  const { getEngineImportSpecifiers } = require('./utils');
17
18
 
@@ -43,6 +44,9 @@ module.exports = function LwcClassTransform(api) {
43
44
 
44
45
  // Validate the usage of LWC decorators.
45
46
  validateImportedLwcDecoratorUsage(engineImportSpecifiers);
47
+
48
+ // Add ?scoped=true to *.scoped.css imports
49
+ scopeCssImports(api, path);
46
50
  },
47
51
  exit(path) {
48
52
  const engineImportSpecifiers = getEngineImportSpecifiers(path);
@@ -0,0 +1,23 @@
1
+ /*
2
+ * Copyright (c) 2020, salesforce.com, inc.
3
+ * All rights reserved.
4
+ * SPDX-License-Identifier: MIT
5
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6
+ */
7
+
8
+ // Add ?scoped=true to any imports ending with .scoped.css. This signals that the stylesheet
9
+ // should be treated as "scoped".
10
+ module.exports = function ({ types: t }, path) {
11
+ const programPath = path.isProgram() ? path : path.findParent((node) => node.isProgram());
12
+
13
+ return programPath.get('body').forEach((node) => {
14
+ const source = node.get('source');
15
+ if (
16
+ node.isImportDeclaration() &&
17
+ source.type === 'StringLiteral' &&
18
+ source.node.value.endsWith('.scoped.css')
19
+ ) {
20
+ source.replaceWith(t.stringLiteral(source.node.value + '?scoped=true'));
21
+ }
22
+ });
23
+ };