@wyw-in-js/transform 0.1.0 → 0.2.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.
Files changed (142) hide show
  1. package/esm/index.js +5 -1
  2. package/esm/index.js.map +1 -1
  3. package/esm/options/loadBabelOptions.js +1 -1
  4. package/esm/options/loadBabelOptions.js.map +1 -1
  5. package/esm/plugins/babel-transform.js +2 -2
  6. package/esm/plugins/babel-transform.js.map +1 -1
  7. package/esm/plugins/collector.js +4 -4
  8. package/esm/plugins/collector.js.map +1 -1
  9. package/esm/plugins/preeval.js +11 -11
  10. package/esm/plugins/preeval.js.map +1 -1
  11. package/esm/plugins/shaker.js +5 -5
  12. package/esm/plugins/shaker.js.map +1 -1
  13. package/esm/shaker.js +2 -2
  14. package/esm/shaker.js.map +1 -1
  15. package/esm/transform/Entrypoint.helpers.js +1 -2
  16. package/esm/transform/Entrypoint.helpers.js.map +1 -1
  17. package/esm/transform/Entrypoint.js +4 -4
  18. package/esm/transform/Entrypoint.js.map +1 -1
  19. package/esm/transform/generators/collect.js +3 -2
  20. package/esm/transform/generators/collect.js.map +1 -1
  21. package/esm/transform/generators/evalFile.js +6 -6
  22. package/esm/transform/generators/evalFile.js.map +1 -1
  23. package/esm/transform/generators/extract.js +18 -14
  24. package/esm/transform/generators/extract.js.map +1 -1
  25. package/esm/transform/generators/transform.js +2 -2
  26. package/esm/transform/generators/transform.js.map +1 -1
  27. package/esm/transform/generators/workflow.js +3 -3
  28. package/esm/transform/generators/workflow.js.map +1 -1
  29. package/esm/transform/helpers/{loadLinariaOptions.js → loadWywOptions.js} +5 -5
  30. package/esm/transform/helpers/loadWywOptions.js.map +1 -0
  31. package/esm/transform.js +11 -10
  32. package/esm/transform.js.map +1 -1
  33. package/esm/types.js.map +1 -1
  34. package/esm/utils/ShakerMetadata.js +1 -1
  35. package/esm/utils/ShakerMetadata.js.map +1 -1
  36. package/esm/utils/{addIdentifierToLinariaPreval.js → addIdentifierToWywPreval.js} +10 -10
  37. package/esm/utils/addIdentifierToWywPreval.js.map +1 -0
  38. package/esm/utils/collectExportsAndImports.js +141 -53
  39. package/esm/utils/collectExportsAndImports.js.map +1 -1
  40. package/esm/utils/collectTemplateDependencies.js +2 -2
  41. package/esm/utils/collectTemplateDependencies.js.map +1 -1
  42. package/esm/utils/getTagProcessor.js +1 -1
  43. package/esm/utils/getTagProcessor.js.map +1 -1
  44. package/esm/utils/hasWywPreval.js +7 -0
  45. package/esm/utils/hasWywPreval.js.map +1 -0
  46. package/lib/index.js +36 -4
  47. package/lib/index.js.map +1 -1
  48. package/lib/options/loadBabelOptions.js +1 -1
  49. package/lib/options/loadBabelOptions.js.map +1 -1
  50. package/lib/plugins/babel-transform.js +2 -2
  51. package/lib/plugins/babel-transform.js.map +1 -1
  52. package/lib/plugins/collector.js +4 -4
  53. package/lib/plugins/collector.js.map +1 -1
  54. package/lib/plugins/preeval.js +11 -11
  55. package/lib/plugins/preeval.js.map +1 -1
  56. package/lib/plugins/shaker.js +5 -5
  57. package/lib/plugins/shaker.js.map +1 -1
  58. package/lib/shaker.js +2 -2
  59. package/lib/shaker.js.map +1 -1
  60. package/lib/transform/Entrypoint.helpers.js +1 -2
  61. package/lib/transform/Entrypoint.helpers.js.map +1 -1
  62. package/lib/transform/Entrypoint.js +4 -4
  63. package/lib/transform/Entrypoint.js.map +1 -1
  64. package/lib/transform/generators/collect.js +1 -1
  65. package/lib/transform/generators/collect.js.map +1 -1
  66. package/lib/transform/generators/evalFile.js +6 -6
  67. package/lib/transform/generators/evalFile.js.map +1 -1
  68. package/lib/transform/generators/extract.js +18 -14
  69. package/lib/transform/generators/extract.js.map +1 -1
  70. package/lib/transform/generators/transform.js +2 -2
  71. package/lib/transform/generators/transform.js.map +1 -1
  72. package/lib/transform/generators/workflow.js +3 -3
  73. package/lib/transform/generators/workflow.js.map +1 -1
  74. package/lib/transform/helpers/{loadLinariaOptions.js → loadWywOptions.js} +6 -6
  75. package/lib/transform/helpers/loadWywOptions.js.map +1 -0
  76. package/lib/transform/helpers/withDefaultServices.js +2 -2
  77. package/lib/transform/helpers/withDefaultServices.js.map +1 -1
  78. package/lib/transform.js +11 -10
  79. package/lib/transform.js.map +1 -1
  80. package/lib/types.js.map +1 -1
  81. package/lib/utils/ShakerMetadata.js +1 -1
  82. package/lib/utils/ShakerMetadata.js.map +1 -1
  83. package/lib/utils/{addIdentifierToLinariaPreval.js → addIdentifierToWywPreval.js} +12 -12
  84. package/lib/utils/addIdentifierToWywPreval.js.map +1 -0
  85. package/lib/utils/collectExportsAndImports.js +141 -53
  86. package/lib/utils/collectExportsAndImports.js.map +1 -1
  87. package/lib/utils/collectTemplateDependencies.js +2 -2
  88. package/lib/utils/collectTemplateDependencies.js.map +1 -1
  89. package/lib/utils/getTagProcessor.js +2 -2
  90. package/lib/utils/getTagProcessor.js.map +1 -1
  91. package/lib/utils/hasWywPreval.js +13 -0
  92. package/lib/utils/hasWywPreval.js.map +1 -0
  93. package/lib/vm/createVmContext.js +2 -2
  94. package/lib/vm/createVmContext.js.map +1 -1
  95. package/package.json +25 -21
  96. package/types/index.d.ts +6 -2
  97. package/types/index.js +11 -3
  98. package/types/options/loadBabelOptions.js +1 -1
  99. package/types/plugins/babel-transform.js +2 -2
  100. package/types/plugins/collector.js +4 -4
  101. package/types/plugins/preeval.js +11 -11
  102. package/types/plugins/shaker.js +5 -5
  103. package/types/shaker.js +2 -2
  104. package/types/transform/Entrypoint.d.ts +1 -1
  105. package/types/transform/Entrypoint.helpers.js +3 -3
  106. package/types/transform/Entrypoint.js +4 -4
  107. package/types/transform/generators/collect.js +1 -1
  108. package/types/transform/generators/evalFile.js +7 -7
  109. package/types/transform/generators/extract.js +21 -12
  110. package/types/transform/generators/transform.js +2 -4
  111. package/types/transform/generators/workflow.js +3 -3
  112. package/types/transform/helpers/{loadLinariaOptions.d.ts → loadWywOptions.d.ts} +1 -1
  113. package/types/transform/helpers/{loadLinariaOptions.js → loadWywOptions.js} +19 -19
  114. package/types/transform.d.ts +7 -6
  115. package/types/transform.js +11 -10
  116. package/types/types.d.ts +1 -1
  117. package/types/utils/ShakerMetadata.d.ts +1 -1
  118. package/types/utils/ShakerMetadata.js +1 -1
  119. package/types/utils/addIdentifierToWywPreval.d.ts +4 -0
  120. package/types/utils/{addIdentifierToLinariaPreval.js → addIdentifierToWywPreval.js} +12 -12
  121. package/types/utils/collectExportsAndImports.js +157 -58
  122. package/types/utils/collectTemplateDependencies.d.ts +1 -1
  123. package/types/utils/collectTemplateDependencies.js +2 -2
  124. package/types/utils/getTagProcessor.js +2 -2
  125. package/types/utils/hasWywPreval.d.ts +4 -0
  126. package/types/utils/{hasLinariaPreval.js → hasWywPreval.js} +3 -3
  127. package/esm/transform/helpers/loadLinariaOptions.js.map +0 -1
  128. package/esm/utils/addIdentifierToLinariaPreval.js.map +0 -1
  129. package/esm/utils/findPackageJSON.js +0 -22
  130. package/esm/utils/findPackageJSON.js.map +0 -1
  131. package/esm/utils/hasLinariaPreval.js +0 -7
  132. package/esm/utils/hasLinariaPreval.js.map +0 -1
  133. package/lib/transform/helpers/loadLinariaOptions.js.map +0 -1
  134. package/lib/utils/addIdentifierToLinariaPreval.js.map +0 -1
  135. package/lib/utils/findPackageJSON.js +0 -29
  136. package/lib/utils/findPackageJSON.js.map +0 -1
  137. package/lib/utils/hasLinariaPreval.js +0 -13
  138. package/lib/utils/hasLinariaPreval.js.map +0 -1
  139. package/types/utils/addIdentifierToLinariaPreval.d.ts +0 -4
  140. package/types/utils/findPackageJSON.d.ts +0 -1
  141. package/types/utils/findPackageJSON.js +0 -29
  142. package/types/utils/hasLinariaPreval.d.ts +0 -4
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.evalFile = void 0;
7
7
  const evaluators_1 = __importDefault(require("../../evaluators"));
8
- const hasLinariaPreval_1 = __importDefault(require("../../utils/hasLinariaPreval"));
8
+ const hasWywPreval_1 = __importDefault(require("../../utils/hasWywPreval"));
9
9
  const UnprocessedEntrypointError_1 = require("../actions/UnprocessedEntrypointError");
10
10
  const wrap = (fn) => {
11
11
  try {
@@ -23,7 +23,7 @@ const wrap = (fn) => {
23
23
  function* evalFile() {
24
24
  const { entrypoint } = this;
25
25
  const { log } = entrypoint;
26
- log(`>> evaluate __linariaPreval`);
26
+ log(`>> evaluate __wywPreval`);
27
27
  let evaluated;
28
28
  while (evaluated === undefined) {
29
29
  try {
@@ -39,18 +39,18 @@ function* evalFile() {
39
39
  }
40
40
  }
41
41
  }
42
- const linariaPreval = (0, hasLinariaPreval_1.default)(evaluated.value)
43
- ? evaluated.value.__linariaPreval
42
+ const wywPreval = (0, hasWywPreval_1.default)(evaluated.value)
43
+ ? evaluated.value.__wywPreval
44
44
  : undefined;
45
- if (!linariaPreval) {
45
+ if (!wywPreval) {
46
46
  return null;
47
47
  }
48
48
  const valueCache = new Map();
49
- Object.entries(linariaPreval).forEach(([key, lazyValue]) => {
49
+ Object.entries(wywPreval).forEach(([key, lazyValue]) => {
50
50
  const value = wrap(lazyValue);
51
51
  valueCache.set(key, value);
52
52
  });
53
- log(`<< evaluated __linariaPreval %O`, valueCache);
53
+ log(`<< evaluated __wywPreval %O`, valueCache);
54
54
  return [valueCache, evaluated.dependencies];
55
55
  }
56
56
  exports.evalFile = evalFile;
@@ -6,8 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.extract = exports.transformUrl = void 0;
7
7
  const path_1 = __importDefault(require("path"));
8
8
  const source_map_1 = require("source-map");
9
- const stylis_1 = __importDefault(require("stylis"));
10
- const STYLIS_DECLARATION = 1;
9
+ const stylis_1 = require("stylis");
11
10
  const posixSep = path_1.default.posix.sep;
12
11
  function transformUrl(url, outputFilename, sourceFilename, platformPath = path_1.default) {
13
12
  // Replace asset path with new path relative to the output CSS
@@ -20,6 +19,25 @@ function transformUrl(url, outputFilename, sourceFilename, platformPath = path_1
20
19
  return relative.split(platformPath.sep).join(posixSep);
21
20
  }
22
21
  exports.transformUrl = transformUrl;
22
+ function createStylisPreprocessor(options) {
23
+ function stylisPreprocess(selector, text) {
24
+ return (0, stylis_1.serialize)((0, stylis_1.compile)(`${selector} {${text}}\n`), (0, stylis_1.middleware)([
25
+ (element) => {
26
+ const { outputFilename } = options;
27
+ if (element.type === 'decl' && outputFilename) {
28
+ // When writing to a file, we need to adjust the relative paths inside url(..) expressions.
29
+ // It'll allow css-loader to resolve an imported asset properly.
30
+ // eslint-disable-next-line no-param-reassign
31
+ element.return = element.value.replace(/\b(url\((["']?))(\.[^)]+?)(\2\))/g, (match, p1, p2, p3, p4) => p1 + transformUrl(p3, outputFilename, options.filename) + p4);
32
+ }
33
+ },
34
+ stylis_1.namespace,
35
+ stylis_1.prefixer,
36
+ stylis_1.stringify,
37
+ ]));
38
+ }
39
+ return stylisPreprocess;
40
+ }
23
41
  function extractCssFromAst(rules, originalCode, options) {
24
42
  const mappings = [];
25
43
  let cssText = '';
@@ -35,16 +53,7 @@ function extractCssFromAst(rules, originalCode, options) {
35
53
  break;
36
54
  case 'stylis':
37
55
  default:
38
- stylis_1.default.use(null)((context, decl) => {
39
- const { outputFilename } = options;
40
- if (context === STYLIS_DECLARATION && outputFilename) {
41
- // When writing to a file, we need to adjust the relative paths inside url(..) expressions
42
- // It'll allow css-loader to resolve an imported asset properly
43
- return decl.replace(/\b(url\((["']?))(\.[^)]+?)(\2\))/g, (match, p1, p2, p3, p4) => p1 + transformUrl(p3, outputFilename, options.filename) + p4);
44
- }
45
- return decl;
46
- });
47
- preprocessor = stylis_1.default;
56
+ preprocessor = createStylisPreprocessor(options);
48
57
  }
49
58
  }
50
59
  Object.keys(rules).forEach((selector, index) => {
@@ -22,7 +22,7 @@ function runPreevalStage(babel, evalConfig, pluginOptions, code, originalAst, ev
22
22
  ];
23
23
  const transformConfig = (0, buildOptions_1.buildOptions)({
24
24
  ...evalConfig,
25
- envName: 'linaria',
25
+ envName: 'wyw-in-js',
26
26
  plugins,
27
27
  });
28
28
  const result = babel.transformFromAstSync(originalAst, code, transformConfig);
@@ -42,9 +42,7 @@ const prepareCode = (services, item, originalAst) => {
42
42
  const { pluginOptions } = options;
43
43
  const preevalStageResult = eventEmitter.perf('transform:preeval', () => runPreevalStage(babel, evalConfig, pluginOptions, code, originalAst, eventEmitter));
44
44
  const transformMetadata = (0, TransformMetadata_1.getTransformMetadata)(preevalStageResult.metadata);
45
- if (only.length === 1 &&
46
- only[0] === '__linariaPreval' &&
47
- !transformMetadata) {
45
+ if (only.length === 1 && only[0] === '__wywPreval' && !transformMetadata) {
48
46
  log('[evaluator:end] no metadata');
49
47
  return [preevalStageResult.code, null, null];
50
48
  }
@@ -29,10 +29,10 @@ function* workflow() {
29
29
  }
30
30
  const originalCode = entrypoint.loadedAndParsed.code ?? '';
31
31
  // File is ignored or does not contain any tags. Return original code.
32
- if (!entrypoint.hasLinariaMetadata()) {
32
+ if (!entrypoint.hasWywMetadata()) {
33
33
  if (entrypoint.generation === 1) {
34
- // 1st generation here means that it's __linariaPreval entrypoint
35
- // without __linariaPreval, so we don't need it cached
34
+ // 1st generation here means that it's __wywPreval entrypoint
35
+ // without __wywPreval, so we don't need it cached
36
36
  cache.delete('entrypoints', entrypoint.name);
37
37
  }
38
38
  return {
@@ -3,4 +3,4 @@ import type { PluginOptions } from '../../types';
3
3
  export type PartialOptions = Partial<Omit<PluginOptions, 'features'>> & {
4
4
  features?: Partial<FeatureFlags>;
5
5
  };
6
- export declare function loadLinariaOptions(overrides?: PartialOptions): StrictOptions;
6
+ export declare function loadWywOptions(overrides?: PartialOptions): StrictOptions;
@@ -3,30 +3,30 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.loadLinariaOptions = void 0;
6
+ exports.loadWywOptions = void 0;
7
7
  const cosmiconfig_1 = require("cosmiconfig");
8
8
  const shaker_1 = __importDefault(require("../../shaker"));
9
9
  const searchPlaces = [
10
- `.linariarc`,
11
- `.linariarc.json`,
12
- `.linariarc.yaml`,
13
- `.linariarc.yml`,
14
- `.linariarc.js`,
15
- `.linariarc.cjs`,
16
- `.config/linariarc`,
17
- `.config/linariarc.json`,
18
- `.config/linariarc.yaml`,
19
- `.config/linariarc.yml`,
20
- `.config/linariarc.js`,
21
- `.config/linariarc.cjs`,
22
- `linaria.config.js`,
23
- `linaria.config.cjs`,
10
+ `.wyw-in-jsrc`,
11
+ `.wyw-in-jsrc.json`,
12
+ `.wyw-in-jsrc.yaml`,
13
+ `.wyw-in-jsrc.yml`,
14
+ `.wyw-in-jsrc.js`,
15
+ `.wyw-in-jsrc.cjs`,
16
+ `.config/wyw-in-jsrc`,
17
+ `.config/wyw-in-jsrc.json`,
18
+ `.config/wyw-in-jsrc.yaml`,
19
+ `.config/wyw-in-jsrc.yml`,
20
+ `.config/wyw-in-jsrc.js`,
21
+ `.config/wyw-in-jsrc.cjs`,
22
+ `wyw-in-js.config.js`,
23
+ `wyw-in-js.config.cjs`,
24
24
  ];
25
- const explorerSync = (0, cosmiconfig_1.cosmiconfigSync)('linaria', { searchPlaces });
25
+ const explorerSync = (0, cosmiconfig_1.cosmiconfigSync)('wyw-in-js', { searchPlaces });
26
26
  const cache = new WeakMap();
27
27
  const defaultOverrides = {};
28
28
  const nodeModulesRegExp = /[\\/]node_modules[\\/]/;
29
- function loadLinariaOptions(overrides = defaultOverrides) {
29
+ function loadWywOptions(overrides = defaultOverrides) {
30
30
  if (cache.has(overrides)) {
31
31
  return cache.get(overrides);
32
32
  }
@@ -65,7 +65,7 @@ function loadLinariaOptions(overrides = defaultOverrides) {
65
65
  return false;
66
66
  }
67
67
  // If a file contains `export` or `import` keywords, we assume it's an ES-module
68
- return /(?:^|\*\/|;)\s*(?:export|import)\s/m.test(code);
68
+ return /(?:^|\*\/|;|})\s*(?:export|import)[\s{]/m.test(code);
69
69
  },
70
70
  action: shaker_1.default,
71
71
  },
@@ -83,4 +83,4 @@ function loadLinariaOptions(overrides = defaultOverrides) {
83
83
  cache.set(overrides, options);
84
84
  return options;
85
85
  }
86
- exports.loadLinariaOptions = loadLinariaOptions;
86
+ exports.loadWywOptions = loadWywOptions;
@@ -1,12 +1,13 @@
1
1
  /**
2
- * This file exposes transform function that:
2
+ * This file exposes sync and async transform functions that:
3
3
  * - parse the passed code to AST
4
- * - transforms the AST using Linaria babel preset ('./babel/index.js) and additional config defined in Linaria config file or passed to bundler configuration.
5
- * - runs generated CSS files through default of user-defined preprocessor
6
- * - generates source maps for CSS files
7
- * - return transformed code (without Linaria template literals), generated CSS, source maps and babel metadata from transform step.
4
+ * - builds a dependency graph for the file
5
+ * - shakes each dependency and removes unused code
6
+ * - runs generated code in a sandbox
7
+ * - collects artifacts
8
+ * - returns transformed code (without WYW template literals), generated CSS, source maps and babel metadata from transform step.
8
9
  */
9
- import type { PartialOptions } from './transform/helpers/loadLinariaOptions';
10
+ import type { PartialOptions } from './transform/helpers/loadWywOptions';
10
11
  import type { Handlers, Services } from './transform/types';
11
12
  import type { Result } from './types';
12
13
  type PartialServices = Partial<Omit<Services, 'options'>> & {
@@ -1,25 +1,26 @@
1
1
  "use strict";
2
2
  /**
3
- * This file exposes transform function that:
3
+ * This file exposes sync and async transform functions that:
4
4
  * - parse the passed code to AST
5
- * - transforms the AST using Linaria babel preset ('./babel/index.js) and additional config defined in Linaria config file or passed to bundler configuration.
6
- * - runs generated CSS files through default of user-defined preprocessor
7
- * - generates source maps for CSS files
8
- * - return transformed code (without Linaria template literals), generated CSS, source maps and babel metadata from transform step.
5
+ * - builds a dependency graph for the file
6
+ * - shakes each dependency and removes unused code
7
+ * - runs generated code in a sandbox
8
+ * - collects artifacts
9
+ * - returns transformed code (without WYW template literals), generated CSS, source maps and babel metadata from transform step.
9
10
  */
10
11
  Object.defineProperty(exports, "__esModule", { value: true });
11
12
  exports.transform = exports.transformSync = void 0;
12
13
  const shared_1 = require("@wyw-in-js/shared");
14
+ const loadWywOptions_1 = require("./transform/helpers/loadWywOptions");
13
15
  const cache_1 = require("./cache");
14
16
  const Entrypoint_1 = require("./transform/Entrypoint");
15
17
  const actionRunner_1 = require("./transform/actions/actionRunner");
16
18
  const generators_1 = require("./transform/generators");
17
19
  const resolveImports_1 = require("./transform/generators/resolveImports");
18
- const loadLinariaOptions_1 = require("./transform/helpers/loadLinariaOptions");
19
20
  const withDefaultServices_1 = require("./transform/helpers/withDefaultServices");
20
21
  function transformSync(partialServices, originalCode, syncResolve, customHandlers = {}) {
21
22
  const { options } = partialServices;
22
- const pluginOptions = (0, loadLinariaOptions_1.loadLinariaOptions)(options.pluginOptions);
23
+ const pluginOptions = (0, loadWywOptions_1.loadWywOptions)(options.pluginOptions);
23
24
  const services = (0, withDefaultServices_1.withDefaultServices)({
24
25
  ...partialServices,
25
26
  options: {
@@ -31,7 +32,7 @@ function transformSync(partialServices, originalCode, syncResolve, customHandler
31
32
  // If global cache is disabled, we need to create a new cache for each file
32
33
  services.cache = new cache_1.TransformCacheCollection();
33
34
  }
34
- const entrypoint = Entrypoint_1.Entrypoint.createRoot(services, options.filename, ['__linariaPreval'], originalCode);
35
+ const entrypoint = Entrypoint_1.Entrypoint.createRoot(services, options.filename, ['__wywPreval'], originalCode);
35
36
  if (entrypoint.ignored) {
36
37
  return {
37
38
  code: originalCode,
@@ -66,7 +67,7 @@ function transformSync(partialServices, originalCode, syncResolve, customHandler
66
67
  exports.transformSync = transformSync;
67
68
  async function transform(partialServices, originalCode, asyncResolve, customHandlers = {}) {
68
69
  const { options } = partialServices;
69
- const pluginOptions = (0, loadLinariaOptions_1.loadLinariaOptions)(options.pluginOptions);
70
+ const pluginOptions = (0, loadWywOptions_1.loadWywOptions)(options.pluginOptions);
70
71
  const services = (0, withDefaultServices_1.withDefaultServices)({
71
72
  ...partialServices,
72
73
  options: {
@@ -86,7 +87,7 @@ async function transform(partialServices, originalCode, asyncResolve, customHand
86
87
  * but the "only" option has changed, the file will be re-processed using
87
88
  * the combined "only" option.
88
89
  */
89
- const entrypoint = Entrypoint_1.Entrypoint.createRoot(services, options.filename, ['__linariaPreval'], originalCode);
90
+ const entrypoint = Entrypoint_1.Entrypoint.createRoot(services, options.filename, ['__wywPreval'], originalCode);
90
91
  if (entrypoint.ignored) {
91
92
  return {
92
93
  code: originalCode,
package/types/types.d.ts CHANGED
@@ -22,7 +22,7 @@ export interface IPluginState extends PluginPass {
22
22
  dependencies: Dependencies;
23
23
  file: BabelFile & {
24
24
  metadata: {
25
- linaria?: WYWTransformMetadata;
25
+ wywInJS?: WYWTransformMetadata;
26
26
  };
27
27
  };
28
28
  processors: BaseProcessor[];
@@ -2,6 +2,6 @@ export interface IShakerMetadata {
2
2
  imports: Map<string, string[]>;
3
3
  }
4
4
  export interface IMetadata {
5
- linariaEvaluator: IShakerMetadata;
5
+ wywEvaluator: IShakerMetadata;
6
6
  }
7
7
  export declare const hasShakerMetadata: (metadata: object | undefined) => metadata is IMetadata;
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.hasShakerMetadata = void 0;
4
- const hasShakerMetadata = (metadata) => metadata !== undefined && 'linariaEvaluator' in metadata;
4
+ const hasShakerMetadata = (metadata) => metadata !== undefined && 'wywEvaluator' in metadata;
5
5
  exports.hasShakerMetadata = hasShakerMetadata;
@@ -0,0 +1,4 @@
1
+ import type { NodePath, Scope } from '@babel/traverse';
2
+ import type { ObjectExpression } from '@babel/types';
3
+ export declare function getOrAddWywPreval(scope: Scope): NodePath<ObjectExpression>;
4
+ export declare function addIdentifierToWywPreval(scope: Scope, name: string): void;
@@ -1,17 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.addIdentifierToLinariaPreval = exports.getOrAddLinariaPreval = void 0;
3
+ exports.addIdentifierToWywPreval = exports.getOrAddWywPreval = void 0;
4
4
  const createId_1 = require("./createId");
5
5
  const scopeHelpers_1 = require("./scopeHelpers");
6
- function getOrAddLinariaPreval(scope) {
6
+ function getOrAddWywPreval(scope) {
7
7
  const rootScope = scope.getProgramParent();
8
8
  const programPath = rootScope.path;
9
- let object = programPath.getData('__linariaPreval');
9
+ let object = programPath.getData('__wywPreval');
10
10
  if (object) {
11
11
  return object;
12
12
  }
13
13
  if (programPath.node.sourceType === 'script') {
14
- // CJS exports.__linariaPreval = {};
14
+ // CJS exports.__wywPreval = {};
15
15
  const prevalExport = {
16
16
  expression: {
17
17
  type: 'AssignmentExpression',
@@ -19,7 +19,7 @@ function getOrAddLinariaPreval(scope) {
19
19
  left: {
20
20
  computed: false,
21
21
  object: (0, createId_1.createId)('exports'),
22
- property: (0, createId_1.createId)('__linariaPreval'),
22
+ property: (0, createId_1.createId)('__wywPreval'),
23
23
  type: 'MemberExpression',
24
24
  },
25
25
  right: {
@@ -33,12 +33,12 @@ function getOrAddLinariaPreval(scope) {
33
33
  object = inserted.get('expression.right');
34
34
  }
35
35
  else {
36
- // ESM export const __linariaPreval = {};
36
+ // ESM export const __wywPreval = {};
37
37
  const prevalExport = {
38
38
  declaration: {
39
39
  declarations: [
40
40
  {
41
- id: (0, createId_1.createId)('__linariaPreval'),
41
+ id: (0, createId_1.createId)('__wywPreval'),
42
42
  init: {
43
43
  properties: [],
44
44
  type: 'ObjectExpression',
@@ -55,13 +55,13 @@ function getOrAddLinariaPreval(scope) {
55
55
  const [inserted] = programPath.pushContainer('body', [prevalExport]);
56
56
  object = inserted.get('declaration.declarations.0.init');
57
57
  }
58
- programPath.setData('__linariaPreval', object);
58
+ programPath.setData('__wywPreval', object);
59
59
  return object;
60
60
  }
61
- exports.getOrAddLinariaPreval = getOrAddLinariaPreval;
62
- function addIdentifierToLinariaPreval(scope, name) {
61
+ exports.getOrAddWywPreval = getOrAddWywPreval;
62
+ function addIdentifierToWywPreval(scope, name) {
63
63
  const rootScope = scope.getProgramParent();
64
- const object = getOrAddLinariaPreval(rootScope);
64
+ const object = getOrAddWywPreval(rootScope);
65
65
  const newProperty = {
66
66
  type: 'ObjectProperty',
67
67
  key: (0, createId_1.createId)(name),
@@ -72,4 +72,4 @@ function addIdentifierToLinariaPreval(scope, name) {
72
72
  const [inserted] = object.pushContainer('properties', [newProperty]);
73
73
  (0, scopeHelpers_1.reference)(inserted.get('value'));
74
74
  }
75
- exports.addIdentifierToLinariaPreval = addIdentifierToLinariaPreval;
75
+ exports.addIdentifierToWywPreval = addIdentifierToWywPreval;